Skip to content

prashantrathi8579/orderbot-ai-react-fastapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🍕 OrderBot — React + FastAPI

Course Certificate Python FastAPI React Vite

A conversational AI pizza-ordering bot built with React + Vite (frontend) and FastAPI (backend), powered by the OpenAI Chat Completions API. Built as a hands-on project after completing ChatGPT Prompt Engineering for Developers by DeepLearning.AI (Andrew Ng & Isa Fulford).

The bot greets the customer, takes their pizza order conversationally, confirms pickup vs. delivery, summarises the order, and collects payment — all driven by a carefully crafted system prompt.


📸 Demo

OrderBot chat screenshot

https://github.com/prashantrathi8579/orderbot-react-fastapi/assets/demo.mp4


🚀 Tech Stack

Layer Technology
Frontend React 19 + Vite
Backend FastAPI (Python) + Uvicorn
AI OpenAI Chat Completions (gpt-3.5-turbo)
Styling Plain CSS
Dev Tool Claude Code (AI-assisted development)

💡 Course Learnings — What Went Into This Project

This project directly applies concepts from the "ChatGPT Prompt Engineering for Developers" course.

1. 🧠 Prompting Principles

  • Writing clear and specific instructions — the model does better when you eliminate ambiguity
  • Using delimiters to separate instructions from input content
  • Asking for structured outputs where the response needs to be programmatically usable

2. 🔄 Iterative Prompt Development

  • Prompts rarely work perfectly on the first try — iterative refinement is the real skill
  • Testing with varied inputs to understand model behaviour
  • Using temperature settings to control creativity vs. determinism (this project uses temperature=0 for deterministic order-taking)

3. 💬 Chat Completions & Conversation Context

  • Understanding the system / user / assistant message roles
  • Maintaining conversation history across turns — the model is stateless, so the full history is sent on every request
  • That is exactly how this app works: the frontend keeps the conversation array and POSTs it on every turn

4. ⚙️ Prompt Patterns Applied

Pattern Where Used
System-prompt persona Defines OrderBot's tone and ordering flow
Menu grounding Pricing and options are baked into the prompt
Output formatting Bot summarises order in a structured way

5. 🌐 LLM-Agnostic Thinking

The course uses Python + OpenAI in Jupyter. I deliberately rebuilt this as a React + FastAPI full-stack app to:

  • Deepen practical understanding by switching frameworks
  • Verify the prompt-engineering concepts work outside the notebook
  • Simulate a real-world full-stack AI app setup

🏗️ Project Structure

orderbot-react-fastapi/
├── frontend/                # React + Vite app
│   ├── src/
│   │   ├── App.jsx          # Chat UI and conversation state
│   │   ├── App.css
│   │   ├── main.jsx
│   │   └── index.css
│   ├── index.html
│   ├── vite.config.js
│   └── package.json
│
├── backend/                 # FastAPI app
│   ├── main.py              # /chat route + OpenAI integration
│   ├── requirements.txt
│   └── .env.example         # Copy to .env and add your key
│
├── .gitignore
└── README.md

⚙️ Getting Started

Prerequisites


🖥️ Backend Setup (FastAPI)

cd backend

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Create your .env file from the template
cp .env.example .env
# Then edit .env and set OPENAI_API_KEY=sk-...

# Start the FastAPI server (port 8000)
uvicorn main:app --reload

Backend runs at: http://localhost:8000 Swagger docs at: http://localhost:8000/docs


🌐 Frontend Setup (React + Vite)

cd frontend
npm install
npm run dev

Frontend runs at: http://localhost:5173 (CORS is whitelisted for this origin in backend/main.py).


🔐 Environment Variables

Create a .env file in the backend/ folder:

OPENAI_API_KEY=your_openai_api_key_here

⚠️ Never commit your .env file. It is excluded via the repo's root .gitignore.


🔄 How It Works

User types message
        ↓
React frontend POSTs /chat with the full message history
        ↓
FastAPI prepends the OrderBot system prompt and forwards to OpenAI
        ↓
OpenAI returns the assistant reply
        ↓
Backend returns { reply } to the frontend
        ↓
React appends the reply to history and re-renders

Key insight: conversation history lives on the frontend and is sent with every request, because the OpenAI Chat Completions API is stateless.


📖 About the Course

ChatGPT Prompt Engineering for DevelopersDeepLearning.AI Instructors: Andrew Ng & Isa Fulford (OpenAI)

🏆 View my completion certificate

"A very crisp, clear and concise course. Though named ChatGPT Prompt Engineering, the explanations are effectively LLM-agnostic — you can swap the underlying model and compare outputs. The hands-on Jupyter notebooks with pre-configured LLM keys make experimentation frictionless." — Prashant Rathi

The course teaches prompt engineering in Python + Jupyter. I extended it by rebuilding the OrderBot exercise as a full-stack React + FastAPI app — a useful exercise for applying these concepts in production-like environments.

🔗 Read my full LinkedIn review of the course


🛠️ Built With Claude Code

The codebase was developed using Claude Code by Anthropic — an agentic AI coding tool. I guided it with requirements and architectural decisions while Claude Code produced the working implementation.

A practical demonstration of AI-assisted development — a core skill for modern engineering teams.


👤 Author

Prashant Rathi Senior Engineering Manager | Agentic AI Enthusiast 📍 Dubai, UAE


📄 License

MIT License — feel free to use and adapt for your own learning.

About

A conversational AI pizza-ordering bot built with React + Vite (frontend) and FastAPI (backend), powered by the OpenAI Chat Completions API. Built as a hands-on project after completing ChatGPT Prompt Engineering for Developers by DeepLearning.AI (Andrew Ng & Isa Fulford).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors