A powerful full-stack analytics platform for restaurant/hotel management using FastAPI, LangGraph, FastMCP (Model Context Protocol), and React. Ask natural language questions and get intelligent insights from your MongoDB data with AI-powered analytics and chart generation.
| Feature | Description |
|---|---|
| π£οΈ Natural Language Queries | Ask questions like "What are the top selling items?" or "Show me revenue trends" |
| π§ 19+ MCP Tools | Comprehensive analytics tools for revenue, customers, menu, orders, and operations |
| π€ LangGraph Agent | Intelligent AI orchestration using Google Gemini 3 Flash |
| π Chart Generation | Automatic visualization of data with Matplotlib & Seaborn |
| β‘ Real-time Analytics | Direct MongoDB connection for live data insights |
| π¨ Modern React UI | Beautiful chat interface with Markdown support |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β React Frontend β
β (Vite + React 19.2) β
β Port: 5173 β
βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Server β
β (REST API + LangGraph Agent) β
β Port: 8001 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β LangGraph Agent (Gemini 3) β β
β β - Natural Language Processing β β
β β - Tool Selection & Orchestration β β
β β - Response Generation β β
β ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β MCP Protocol (Streamable HTTP)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FastMCP Server β
β (Model Context Protocol) β
β Port: 8000 β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β 19+ MCP Tools β β
β β - mongodb_query, mongodb_aggregate, mongodb_insert β β
β β - get_revenue_analytics, get_customer_insights β β
β β - get_menu_performance, generate_chart, etc. β β
β ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββ
β PyMongo
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MongoDB β
β (restaurant_analytics DB) β
β Port: 27017 β
β Collections: orders, customers, menu_items, delivery_details β
β users, audit_logs, inventory, feedback, staff β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
MongoDB_mcp/
βββ main_dir/ # Main application directory
β βββ server.py # MCP Server entry point
β βββ seed_db.py # Database seeding script
β βββ requirements.txt # Python dependencies
β βββ api_server/ # FastAPI Application
β β βββ fastapi_server.py # REST API server (Port 8001)
β β βββ agents/
β β β βββ langgraph_agent.py # LangGraph + Gemini Agent
β β βββ helpers/
β β βββ chart_generator.py # Chart generation utilities
β βββ mcp_server/ # MCP Server Components
β βββ tools/ # 19+ MCP Tool implementations
β βββ models/ # Pydantic data models
β βββ utils/ # Database client & utilities
βββ frontend/
β βββ mongo_mcp_frontend/ # React Frontend (Vite)
β βββ src/
β β βββ App.js # Main chat interface
β β βββ index.js # React entry point
β βββ package.json
βββ data/ # Sample JSON datasets
βββ Database_query/ # Educational MongoDB examples
β βββ mongodb_concepts/ # Query patterns & concepts
βββ pyproject.toml # Project configuration
βββ Dockerfile # Container configuration
βββ ARCHITECTURE.md # Detailed architecture docs
| Tool | Description |
|---|---|
mongodb_query |
Execute find queries on any collection |
mongodb_aggregate |
Run aggregation pipelines |
mongodb_insert |
Insert new documents |
mongodb_update |
Update existing documents |
mongodb_get_collections |
List all available collections |
mongodb_describe_collection |
Get collection schema and stats |
| Tool | Description |
|---|---|
get_revenue_analytics |
Comprehensive revenue insights |
get_revenue_by_date |
Revenue for specific date ranges |
get_menu_revenue |
Revenue breakdown by menu items |
quick_stats |
Quick overview of key metrics |
| Tool | Description |
|---|---|
get_customer_insights |
Deep customer behavior analysis |
get_customer_segments |
Customer segmentation data |
| Tool | Description |
|---|---|
get_order_status |
Order status distribution |
get_order_types |
Order type breakdown (dine-in, delivery, etc.) |
get_operational_metrics |
Operational performance metrics |
search_orders |
Search orders by various criteria |
| Tool | Description |
|---|---|
get_menu_performance |
Menu item performance analysis |
generate_chart |
Create visualizations from data |
get_data_range |
Check available data date ranges |
- Python 3.13+ (recommended) or 3.11+
- Node.js 18+ & npm
- MongoDB (running on
localhost:27017) - Google API Key (for Gemini 3 Flash)
git clone https://github.com/sanskaryo/MongoDB_mcp.git
cd MongoDB_mcp# Navigate to main directory
cd main_dir
# Create virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Create .env file
echo "GOOGLE_API_KEY=your_google_api_key_here" > .env
# Seed the database with sample data
python seed_db.pyTerminal 1 - MCP Server (Port 8000):
cd main_dir
python server.pyTerminal 2 - API Server (Port 8001):
cd main_dir/api_server
python fastapi_server.py# In a new terminal
cd frontend/mongo_mcp_frontend
# Install dependencies
npm install
# Start development server (Port 5173)
npm run devOpen your browser and navigate to: http://localhost:5173
Try asking these questions in the chat interface:
π "What are the top 5 selling menu items?"
π° "Show me revenue trends for the last 30 days"
π₯ "What are my customer segments?"
π "Generate a chart showing order types distribution"
π "Which menu category generates the most revenue?"
π¦ "What's the status of pending orders?"
π "Search for orders over $50"
π "Show me operational metrics for this month"
# Build the image
docker build -t mongodb-analytics-agent .
# Run with MongoDB
docker run -p 8000:8000 -p 8001:8001 \
-e GOOGLE_API_KEY=your_key \
-e MONGO_URI=mongodb://host.docker.internal:27017 \
mongodb-analytics-agent| Variable | Description | Required |
|---|---|---|
GOOGLE_API_KEY |
Google API key for Gemini 3 | β Yes |
MONGO_URI |
MongoDB connection string | β No (defaults to localhost:27017) |
- FastAPI - High-performance REST API framework
- FastMCP - Model Context Protocol server implementation
- LangGraph - Agent orchestration and workflow management
- LangChain - LLM integration and tool management
- Google Gemini 3 Flash - AI model for natural language processing
- PyMongo - MongoDB driver for Python
- Pandas - Data manipulation and analysis
- Matplotlib/Seaborn - Chart and visualization generation
- React 19.2 - Modern UI library
- Vite 7 - Fast build tool and dev server
- Axios - HTTP client
- React-Markdown - Markdown rendering in chat
- Lucide React - Icon library
- MongoDB - NoSQL document database
- ARCHITECTURE.md - Detailed system architecture
- Database_query/mongodb_concepts/ - MongoDB query examples and patterns
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
Sanskar Yadav
- GitHub: @sanskaryo
Made with β€οΈ using MongoDB, FastMCP, and AI