An intelligent voice-powered ordering system for restaurants with AI-driven upselling, analytics, and real-time conversation handling.
This project consists of a Next.js frontend and a FastAPI backend working together to provide:
- AI Voice Ordering: Natural language voice conversations for placing orders
- Real-time Analytics: Revenue insights, item profitability, and sales velocity
- Conversation Management: View and manage AI-customer conversations
- Multi-language Support: Hindi, English, and Hinglish support
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Next.js │────▶│ FastAPI │────▶│ Supabase │
│ Frontend │◄────│ Backend │◄────│ Database │
│ (Port 3000) │ │ (Port 8000) │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
│ ┌────────┴────────┐
│ │ │
▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐
│ OpenRouter│ │ Sarvam │ │ Sarvam │
│ (LLM) │ │ (STT) │ │ (TTS) │
└──────────┘ └──────────┘ └──────────┘
Frontend:
- Next.js 16 with App Router
- TypeScript
- Tailwind CSS + shadcn/ui
- Recharts for analytics
Backend:
- FastAPI
- Python 3.12
- Supabase client
- Sarvam AI SDK
AI/ML Services:
- OpenRouter (
stepfun/step-3.5-flash:free) - LLM for conversation & tool calling - Sarvam AI - Speech-to-Text (STT) and Text-to-Speech (TTS)
Database:
- Supabase (PostgreSQL)
- Tables:
order,menu,restaurant,voice_orders,voice_order_items
hackathon2/
├── frontend/ # Next.js application
│ ├── src/
│ │ ├── app/
│ │ │ ├── api/agent/ # AI agent API routes
│ │ │ ├── dashboard/ # Analytics dashboard
│ │ │ ├── voice-copilot/ # Voice session viewer
│ │ │ └── order/ # Order management
│ │ ├── components/ui/ # shadcn components
│ │ └── lib/
│ │ └── api.ts # API client
│ └── .env # Environment variables
│
├── fastapi-endpoint/ # FastAPI backend
│ ├── main.py # Main FastAPI app
│ ├── ai_agent.py # AI agent logic
│ └── .env # Environment variables
│
└── README.md
- Node.js 18+ with bun or npm
- Python 3.12+ with uv
- Git
git clone <repository-url>
cd hackathon2cd frontend
# Install dependencies
bun install
# or: npm install
# Create environment file
cp .env.example .env
# Edit .env with your API keys (see Environment Variables section)cd fastapi-endpoint
# Install dependencies with uv
uv sync
# Create environment file
cp .env.example .env
# Edit .env with your API keys (see Environment Variables section)Create .env files in both directories:
frontend/.env:
# Server-side secrets (used in Next.js API routes)
SARVAM_API_KEY=your_sarvam_api_key
OPENROUTER_API_KEY=your_openrouter_api_key
SUPABASE_URL=https://maplbnfnthpjpfkbsgfs.supabase.co
SUPABASE_KEY=your_supabase_key
# Public env vars
NEXT_PUBLIC_FASTAPI_URL=http://localhost:8000fastapi-endpoint/.env:
SUPABASE_URL=https://maplbnfnthpjpfkbsgfs.supabase.co
SUPABASE_KEY=your_supabase_key
SARVAM_API_KEY=your_sarvam_api_keyRequired API Keys:
-
Sarvam AI - Get from dashboard.sarvam.ai
- Used for STT (speech-to-text) and TTS (text-to-speech)
-
OpenRouter - Get from openrouter.ai
- Used for LLM (stepfun/step-3.5-flash:free model)
-
Supabase - Get from supabase.com
- Database URL and service role key
Ensure your Supabase project has these tables:
restaurant- Restaurant informationmenu- Menu items with pricesorder- Order recordsvoice_orders- AI voice order sessionsvoice_order_items- Items in voice orders
Open two terminal windows:
# Terminal 1 - Frontend (http://localhost:3000)
cd frontend
bun run dev
# Terminal 2 - FastAPI Backend (http://localhost:8000)
cd fastapi-endpoint
uvicorn main:app --reload- Natural Conversations: Customers can speak naturally in Hindi/English
- Tool Calling: AI automatically calls tools to:
- Fetch menu items
- Add items to order
- Modify quantities
- Confirm orders
- Real-time: Streaming responses with voice output
- KPI Cards: Total revenue, orders, average order value
- Charts: Revenue by category (pie), top items (bar)
- Insights: Star items, under-promoted items, risk items
- Session Viewer: Browse all AI-customer conversations
- Order Details: View complete order information
- Conversation Logs: See full back-and-forth between AI and customer
- Real-time order status
- Item modifications
- Payment tracking
| Endpoint | Method | Description |
|---|---|---|
/api/agent/stream |
POST | Streaming AI conversation |
/api/agent/stt |
POST | Speech-to-text conversion |
/api/agent/tts |
POST | Text-to-speech conversion |
/api/agent |
DELETE | Delete session |
| Endpoint | Method | Description |
|---|---|---|
/api/analytics/{restaurant_id} |
GET | Revenue analytics |
/api/ai/voice-agent/sessions |
GET | Voice session list |
/api/ai/voice-agent/sessions/{id} |
GET | Session details |
- Customer speaks → Audio captured in browser
- STT (Sarvam) → Converts speech to text
- LLM (OpenRouter) → Processes text, decides action
- Tool Execution → Fetches menu/adds items/confirms order
- Response → LLM generates natural response
- TTS (Sarvam) → Converts text to Hindi speech
- Audio plays → Customer hears response
The LLM has access to these tools:
get_menu_items- Fetch restaurant menuadd_item_to_order- Add items to current orderget_order_summary- Show current order detailsmodify_order_item- Change item quantity/sizeremove_item_from_order- Remove itemsconfirm_order- Finalize and save ordercancel_order- Cancel current order
- Frontend: ESLint + Prettier configured
- Backend: Ruff for Python linting
frontend/src/app/api/agent/stream/route.ts- Main AI streaming logicfrontend/src/app/api/agent/prompts.ts- LLM system promptsfrontend/src/app/api/agent/tools.ts- Tool implementationsfastapi-endpoint/main.py- FastAPI routes
cd frontend
vercel --prodAdd environment variables in Vercel dashboard.
cd fastapi-endpoint
# Deploy using Dockerfile or Procfile- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit changes:
git commit -am 'Add feature' - Push to branch:
git push origin feature-name - Submit a pull request
MIT License - feel free to use for your restaurant projects!
For issues or questions:
- Open an issue on GitHub
- Contact: devagarwal@example.com
Built with ❤️ for the Hackathon