A complete implementation of an intelligent admin homepage with natural language analytics capabilities. This project demonstrates a fully functional real-time analytics chatbot that can query loyalty program databases and generate visualizations using natural language, built with modern MCP (Model Context Protocol) integration.
Quick Setup:
git clone <your-repo-url>
cd rops_h1_poc_analytics
make install
make docker-up
make init-db
make setup-mcp
make startAccess: http://localhost:3000
The Makefile handles all the complexity - just follow the commands above!
This is a working implementation of a dynamic, intelligent "mission control" for loyalty program analytics. The system allows non-technical users to ask plain English questions about merchants, users, and redemption data, receiving interactive data visualizations in real-time.
- Natural Language Queries: Ask questions like "Show me the top 10 merchants by redemption volume this month"
- Interactive Chart.js Visualizations: Automatic chart and table generation with export/fullscreen capabilities
- Complete Tool Ecosystem: Database queries, Python code execution, and MCP-UI visualization generation
- Real-time Chat Interface: WebSocket-based communication for instant responses
- Database Integration: Direct PostgreSQL connection with loyalty program data
- MCP Integration: Model Context Protocol with automated PostgreSQL Toolbox setup
- Advanced AI Agent: LangGraph-based ReAct agent with multi-iteration reasoning and composite tools
- Code Sandbox: Python code execution for custom analytics and data processing
- Environment-Based Configuration: Flexible configuration using environment variables
- Automated Setup: One-command setup for MCP servers and database initialization
βββββββββββββββββββ WebSocket βββββββββββββββββββ MCP βββββββββββββββββββ
β Frontend βββββββββββββββββΊβ Backend βββββββββββββΊβ MCP Servers β
β (React) β β (FastAPI) β β β
β β β β β β’ DB Toolbox β
β Chat Interface β β ReAct Agent β β β’ MCP-UI β
β MCPUI UIResource|
| Charts β β WebSocket Hub β β β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β
βΌ
βββββββββββββββββββ
β PostgreSQL β
β β
βββββββββββββββββββ
- Docker and Docker Compose
- Python 3.11+
- Node.js 18+
- Git
git clone <your-repo-url>
cd rops_h1_poc_analytics# Install all dependencies and setup everything
make installThe Makefile simplifies the running process. Follow these steps in order:
make setup-frontend
make start-frontendmake setup-backend # Creates .env file automatically
make init-db # Initialize database with sample data
make setup-mcp # Download and configure MCP Toolbox
make start-backend # Start backend with MCP servers- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
# Complete setup and start both services
make install
make docker-up # Start PostgreSQL
make init-db # Initialize database
make setup-mcp # Setup MCP servers
make start # Start both frontend and backendThis project has been updated with several key improvements:
- Environment-Based Setup: All configuration now uses environment variables
- Automatic .env Creation: Template file created during setup
- Flexible Database Configuration: Individual postgres connection parameters
- Automated MCP Setup:
mcp_setup.pydownloads and configures PostgreSQL Toolbox - Working MCP Configuration: Uses proven format from mcpui-sandbox-chat
- Environment-Driven Config: MCP servers configured from environment variables
- Loyalty Program Schema: Complete loyalty program database with realistic data
- Environment-Driven Init: Database initialization uses environment settings
- Better Error Handling: Improved logging and error management
- One-Command Setup:
make install && make setup-mcp && make init-db && make start - Automatic Downloads: MCP Toolbox downloaded automatically
- Consistent Naming: Fixed case sensitivity issues across the codebase
This project demonstrates a complete implementation of the MCP UI Chat Analytics system. It serves as both a working example and a foundation for further development.
- Architect a real-time, full-stack application using WebSockets
- Integrate and orchestrate multiple MCP servers
- Translate natural language queries into database queries and visualizations
- Utilize AI agents to accelerate development
- Description & Delegation: Clear, context-rich instructions for complex systems
- Discernment & Diligence: Critical evaluation of generated code and queries
- Problem-solving Style: Adaptive vs. Innovative approaches
This template follows a structured approach for AI-assisted development:
- Plan First: Provide context and collaboratively refine architecture
- IDE Configuration: Use AI to configure MCP toolchain
- TDD Setup: Convert plans into failing tests
- Implementation: Build minimal code to pass tests
- Integration: Connect frontend and backend
- Validation: End-to-end testing and documentation
# Development
make install # Install all dependencies
make setup-backend # Setup Python environment
make setup-frontend # Setup Node.js dependencies
make setup-mcp # Configure MCP servers
# Running
make start # Start both servers
make start-backend # Start backend only
make start-frontend # Start frontend only
make dev # Initialize DB and start servers
# Testing
make test # Run all tests
make test-backend # Run backend tests
make test-frontend # Run frontend tests
make test-mcp # Test MCP integration
# Database
make init-db # Initialize with sample data
make docker-up # Start PostgreSQL
make docker-down # Stop PostgreSQL
make check-db # Test database connection
# Utilities
make clean # Clean build artifacts
make status # Check service status
make logs-backend # View backend logsrops_h1_poc_analytics/
βββ backend/ # FastAPI backend
β βββ models/ # Database models
β βββ tests/ # Backend tests
β βββ mcp_servers/ # MCP server configurations
β βββ notebooks/ # Jupyter notebooks for testing
β βββ main.py # FastAPI application
β βββ langgraph_agent.py # ReAct agent implementation
β βββ mcp_multi_client.py # MCP client manager
β βββ websocket_manager.py # WebSocket handling
β βββ requirements.txt # Python dependencies
βββ frontend/ # React frontend
β βββ src/
β β βββ components/ # React components
β β βββ hooks/ # Custom hooks
β β βββ types/ # TypeScript types
β β βββ app/ # Next.js app directory
β βββ package.json # Node.js dependencies
β βββ next.config.ts # Next.js configuration
βββ docs/ # Documentation
β βββ AI_GUIDE.md # AI assistant instructions
β βββ CHALLENGE_BRIEF.md # Hackathon challenge
β βββ DEVELOPMENT_PATTERNS.md # Coding standards
β βββ MCP_INTEGRATION_GUIDE.md # MCP setup guide
βββ scripts/ # Utility scripts
βββ docker-compose.yml # Docker services
βββ Makefile # Development commands
βββ README.md # This file
The template includes a sample analytics database
This template is designed to work seamlessly with AI coding assistants. Key features:
- Comprehensive Context: Detailed system documentation for AI understanding
- Structured Prompts: Pre-written prompts for common development tasks
- Clear Patterns: Consistent coding patterns and architecture
- Progressive Implementation: Step-by-step development approach
Create a .env file in the root directory:
# Database
DATABASE_URL=postgresql://analytics:password@localhost:5432/analytics_db
REDIS_URL=redis://localhost:6379
# API Keys (for production)
OPENAI_API_KEY=your_openai_key_here
GEMINI_API_KEY=your_gemini_key_here
# Development
LOG_LEVEL=INFO
DEBUG=trueThe template includes pre-configured MCP servers:
- Database Toolbox: For PostgreSQL queries
- MCP UI: For visualization generation
# Run all backend tests
make test-backend
# Run specific test categories
cd backend && python -m pytest tests/ -v
cd backend && python -m pytest tests/test_websocket.py -v
cd backend && python -m pytest tests/test_orchestration.py -v# Run frontend tests
make test-frontend
# Run component tests
cd frontend && npm test# Test MCP integration
make test-mcp
# Test MCP UI integration
make test-mcp-ui# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop services
docker-compose down- Configure proper environment variables
- Set up SSL certificates
- Configure reverse proxy (nginx)
- Set up monitoring and logging
- Configure database backups
- AI Assistant Guide - Instructions for AI coding assistants
- Challenge Brief - Detailed hackathon requirements
- Development Patterns - Coding standards and patterns
- MCP Integration Guide - MCP server setup and usage
- Fork the repository
- Create a feature branch
- Make your changes following the development patterns
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Database Connection Issues:
# Check if PostgreSQL is running
make check-db
# Restart database
make docker-down
make docker-up
make init-dbMCP Server Issues:
# Re-setup MCP servers
make setup-mcp
# Check MCP status
make statusFrontend Not Loading:
# Restart frontend
make start-frontend
# Check if backend is running
make statusBackend Not Starting:
# Check logs
make logs-backend
# Restart backend
make start-backend# Check all services
make status
# View logs
make logs-backend
make logs-frontendFor support and questions:
- Check the documentation in the
docs/directory - Review the troubleshooting section above
- Create an issue in the repository
-
Database Toolbox for multi-database tool integration
-
LLM Sandbox for secure code execution and agent tool orchestration
-
MCP-UI Specification for unified tool and UI protocol
-
LangGraph for agent orchestration
-
FastMCP to build MCP servers and clients
-
FastAPI for the backend framework
-
Next.js for the frontend framework