FastAPI-based backend for a voice-based retail assistant used in physical stores.
🧴 Product Information - Get details about ingredients, size, brand
📦 Availability Check - Check stock and variants
🔄 Product Comparison - Compare with similar products
🧭 Store Navigation - Find aisle/shelf locations
🗣️ Voice Interaction - Natural speech processing with local Whisper v3 Turbo STT, LLM, and TTS
- API: FastAPI
- Database: MongoDB with Motor (async)
- STT: Local Whisper v3 Turbo (offline)
- LLM: OpenAI GPT-4
- TTS: Sesame TTS API
-
Install dependencies:
pip install -e . -
Setup environment:
cp .env.example .env # Edit .env with your API keys -
Run the server:
python main.py
-
API Documentation: Visit
http://localhost:8000/docs
POST /store/connect- Connect to store via QRGET /store/{store_id}- Get store detailsGET /store/- List all stores
POST /product/scan- Scan product barcodeGET /product/{id}- Get product detailsGET /product/store/{store_id}- List products in store
POST /voice-agent/query- Process voice input and return audio responseWebSocket /voice-agent/stream- Real-time voice interaction
- Connect to a store by providing store_id
- Optionally scan product barcode for context
- Speak to voice agent
- Backend processes: Audio → STT → LLM → TTS → Audio response
# MongoDB
MONGODB_URL=mongodb://localhost:27017
DATABASE_NAME=voice_agent
# OpenAI
OPENAI_API_KEY=your-openai-api-key
# Sesame (for TTS)
SESAME_TTS_API_URL=https://api.sesame.com/v1/tts
SESAME_API_KEY=your-sesame-api-key
# Deepgram (for STT)
DEEPGRAM_API_KEY=your-deepgram-api-key{
"_id": "store123",
"name": "Walmart MG Road",
"location": "Bangalore"
}{
"_id": "prod987",
"store_id": "store123",
"product_code": "XYZ123",
"name": "Amul Butter",
"brand": "Amul",
"ingredients": "Pasteurized cream, salt",
"price": 55,
"stock": 20,
"variants": ["100g", "500g"],
"comparison_tags": ["butter", "dairy"],
"shelf_location": "Aisle 4, Left"
}The project follows a modular structure:
routers/- API route handlersservices/- Business logic and external API integrationsmodels/- Pydantic schemasdb/- Database connection and operations
Ready for deployment on Railway, Render, or AWS EC2. Make sure to:
- Set environment variables
- Configure MongoDB connection
- Add domain to CORS origins
- Setup SSL certificates for production
Comprehensive documentation is available in the docs/ directory, including:
- API reference
- Setup and installation guide
- Usage examples
- Contribution guidelines
- Set environment variables
- Configure MongoDB connection
- Add domain to CORS origins
- Setup SSL certificates for production
Comprehensive documentation is available in the docs/ directory, including:
- API reference
- Setup and installation guide
- Usage examples
- Contribution guidelines
- Setup and installation guide
- Usage examples
- Contribution guidelines