A comprehensive AI-powered chatbot system for ZUS Coffee, featuring semantic product search, outlet location queries, and conversational AI capabilities. The project consists of two main components: a FastAPI backend service and a Streamlit frontend interface.
Deployment repository: zus-api-deployment on Render
The ZUS Coffee Chatbot system is designed as a modular, cloud-ready architecture that connects users to rich product and outlet data using advanced AI and search technologies. Below is a detailed conceptual framework:
+-------------------------------+
| User (Web Browser) |
+-------------------------------+
|
v
+-------------------------------+
| Streamlit Frontend (UI) |
|-------------------------------|
| - Chat interface |
| - Login/Register |
| - Session state (JWT, cache) |
| - Calls FastAPI endpoints |
+-------------------------------+
|
v
+-------------------------------+
| FastAPI Backend |
|-------------------------------|
| - /chat, /products, /outlets |
| - /register, /login, /health |
| - Reads config/env vars |
| - Handles session/cache |
+-------------------------------+
| | | | |
| v v v |
| Auth/Rate Intent Routers |
| Limiting Detection (Chat, |
| (JWT, (OpenAI Product,|
| Throttle) LLM) Outlet) |
+-------------------------------+
| | | | |
| v v v |
|-------------------------------|
| Core Logic & Chains |
|-------------------------------|
| - Product Chain |
| - Outlet Chain |
| - Intent Chain |
+-------------------------------+
| | | | |
| v v v |
|-------------------------------|
| Data & External Services |
|-------------------------------|
| - Pinecone Vector DB |
| (Semantic Product Search) |
| - SQLite DB |
| (Outlet Data) |
| - OpenAI API (LLM) |
| (Intent, Summaries, Chat) |
+-------------------------------+
| | | | |
| v v v |
|-------------------------------|
| Data Pipeline (ETL) |
|-------------------------------|
| - Web Scraping (Products, |
| Outlets) |
| - Data Cleaning/Processing |
| - Embedding Generation |
| - Updates Pinecone/SQLite |
+-------------------------------+
| | | | |
| v v v |
+-------------------------------+
| Config & Environment |
|-------------------------------|
| - config.json |
| - .env / Render dashboard |
+-------------------------------+
Key Flows:
- User interacts with the Streamlit UI, which manages session and sends requests to FastAPI.
- FastAPI handles authentication, rate limiting, intent detection, and routes requests to the appropriate logic chain.
- Product and outlet queries use Pinecone (semantic search) and SQLite (structured data).
- OpenAI API is used for intent classification and generating natural language responses.
- Data pipeline (scraping/ETL) keeps Pinecone and SQLite up to date.
- All components use configuration and environment variables for settings and secrets.
This project is organized into two separate repositories:
1. ZUS API Deployment (Repository)
- FastAPI Backend Service - Production-ready REST API
- Docker Containerization - Optimized for cloud deployment
- Render Deployment - Auto-deploying sync service
- Vector Database Integration - Pinecone for semantic search
- SQL Database - SQLite for outlet data
2. RAG Chatbot Agent (Repository)
- Development & Documentation - Project documentation and assets
- Streamlit Interface - User-friendly chatbot frontend
- Data Pipeline - Web scraping (notebbok) and data processing
- Notebooks - Jupyter notebooks for development
The API is automatically deployed on Render and ready to use:
- API Base URL:
https://zus-api-deployment.onrender.com/
- API Documentation:
https://zus-api-deployment.onrender.com/docs
- Health Check:
https://zus-api-deployment.onrender.com/api/v1/health
- Python 3.11+
- OpenAI API Key
- Pinecone API Key
-
Clone the API repository
git clone https://github.com/EASONTAN03/zus-api-deployment.git cd rag-chatbot-agent/zus-api-deployment
-
Install dependencies
conda create -n zus-api-test python=3.11 conda activate zus-api-test pip install -r requirements.txt
-
Set environment variables
# Create .env file echo "OPENAI_API_KEY=your-openai-key" > .env echo "PINECONE_API_KEY=your-pinecone-key" >> .env echo "PINECONE_API_KEY=website/api/v1" >> .env
website can be replace by domain e.g "https://zus-api-deployment.onrender.com/api/v1"
-
Run the API locally
cd app uvicorn app:app --host 0.0.0.0 --port 8000 --reload
-
Access the API
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/api/v1/health
-
Install dependencies pip install streamlit
-
Run the UI locally cd ../../ streamlit run streamlit_app.py
zus-api-deployment/
βββ app/
β βββ app.py # FastAPI application entry point
β βββ src/
β β βββ vectorstore.py # Pinecone vector search logic
β β βββ text2SQL.py # SQLite database operations
β β βββ utils.py # Configuration and utilities
β β βββ openai_chain.py # LLM prompt chains
β β βββ rate_limit.py # Rate limiting and auth
β β βββ router.py # API route handlers
β βββ data/ # Data files (CSV, SQL, DB)
βββ Dockerfile # Production containerization
βββ render.yaml # Render deployment configuration
βββ requirements.txt # Python dependencies
βββ README.md # The top-level README for developers using this project.
rag-chatbot-agent/
βββ zus-api-deployment/ # API deployment files
βββ docs/ # Documentation
βββ notebooks/ # Development notebooks
βββ assets/ # Images and assets
βββ streamlit_app.py # Chatbot UI
βββ .gitignore # Git ignore rules
βββ README.md # The top-level README for developers using this project.
GET /
- API status and versionGET /api/v1/health
- Health checkPOST /api/v1/chat
- Conversational chatbotGET /api/v1/products
- Product searchGET /api/v1/outlets
- Outlet location search
# Health check
curl https://zus-coffee-chatbot.onrender.com/api/v1/health
# Chat with the bot
curl -X POST "https://zus-coffee-chatbot.onrender.com/api/v1/chat" \
-H "Content-Type: application/json" \
-d '{"message": "What products do you have?"}'
# Search products
curl "https://zus-coffee-chatbot.onrender.com/api/v1/products?query=tumbler"
- Conversational Interface - Natural language interaction
- Intent Classification - Automatic query understanding
- Context Awareness - Maintains conversation context
- Multi-turn Dialogues - Complex conversation handling
- Vector Database - Pinecone for semantic similarity
- Product Recommendations - AI-driven suggestions
- Detailed Product Info - Complete product descriptions
- Visual Search - Product images and details
- SQL Database - Fast location queries
- Geographic Search - Location-based filtering
- Store Information - Complete outlet details
- Real-time Data - Up-to-date information
- Docker Containerization - Consistent deployment
- Auto-deployment - Render sync deployment
- Health Monitoring - Built-in health checks
- Security Headers - Production security
- Rate Limiting - API protection
- CORS Support - Cross-origin requests
OPENAI_API_KEY=your-openai-api-key
PINECONE_API_KEY=your-pinecone-api-key
API_BASE_URL={website}/api/v1
CORS_ORIGINS=* # CORS configuration
PYTHONPATH=/app # Python path
LOG_LEVEL=INFO # Logging level
ALGORITHM=HS256 # JWT algorithm
# Build the image
docker build -t zus-chatbot .
# Run the container
docker run -p 8000:8000 \
-e OPENAI_API_KEY=your-key \
-e PINECONE_API_KEY=your-key \
zus-chatbot
The application is automatically deployed on Render with:
- Auto-deploy on code changes
- Health monitoring
- SSL certificates
- Custom domain support
- Web Scraping - Automated data collection
- Vector Embeddings - Semantic search capabilities
- Product Categories - Organized product hierarchy
- Pricing Information - Real-time pricing
- Location Database - Geographic information
- Store Details - Complete outlet information
- Operating Hours - Business hours
- Contact Information - Store contact details
# Clone both repositories
git clone https://github.com/EASONTAN03/zus-api-deployment.git
git clone https://github.com/EASONTAN03/rag-chatbot-agent.git
# Set up development environment
cd zus-api-deployment
pip install -r requirements.txt
cd app && python app.py
# API health check
curl http://localhost:8000/api/v1/health
# Test chat endpoint
curl -X POST "http://localhost:8000/api/v1/chat" \
-H "Content-Type: application/json" \
-d '{"message": "Hello"}'
-
Module Import Errors
- Ensure
PYTHONPATH=/app
is set - Check that all dependencies are installed
- Ensure
-
API Key Issues
- Verify environment variables are set correctly
- Check API key permissions and quotas
-
Database Connection
- SQLite database auto-creates from CSV
- Ensure data files are in the correct location
-
Vector Store Issues
- Verify Pinecone API key and environment
- Check vector index configuration
# Enable debug logging
export LOG_LEVEL=DEBUG
python app.py
- Docker Layer Caching - Faster builds
- Production Requirements - Optimized dependencies
- Health Checks - Automatic monitoring
- Security Headers - Production security
- Memory: ~512MB (Render Free Tier)
- CPU: Optimized for single-core
- Storage: Minimal disk usage
- Network: Efficient API responses
-
Fork the repositories
-
Create feature branches
git checkout -b feature/your-feature-name
-
Make your changes
- Follow the existing code style
- Add tests for new features
- Update documentation
-
Submit pull requests
- Clear description of changes
- Include test results
- Update relevant documentation
This project is licensed under the MIT License. See the LICENSE file for details.
- GitHub Issues: Report bugs and feature requests
- API Documentation: Available at
/docs
endpoint - Health Check: Monitor service status
- Deployment Status: Check Render dashboard
- Enhanced Semantic Search - Improved product matching
- Real-time Updates - Live data synchronization
- Mobile API Client - Native mobile app
- Analytics Dashboard - Usage analytics
- Multi-language Support - Internationalization
- Advanced Caching - Redis integration
- WebSocket Support - Real-time chat
- User Authentication - JWT-based auth system
- CDN Integration - Faster content delivery
- Database Optimization - Query performance
- Caching Layer - Response caching
- Load Balancing - Horizontal scaling
- GitHub: EASONTAN03
- API Status: Health Check
- Documentation: API Docs
Built with β€οΈ for ZUS Coffee enthusiasts
Each screenshot above demonstrates a real interaction with the chatbot, using the prompts shown in the tables. The UI and rate limit images show the user experience and system protection in action. The Render dashboard image shows the deployment and live log monitoring for the API.