A sophisticated educational platform powered by Google's Gemini AI, featuring specialized agents for Math and Physics tutoring with integrated computational tools.
- Frontend: https://multi-ai-tutor.vercel.app/
- Backend API: Render Deployment
- Overview
- Architecture
- Features
- Tech Stack
- Installation
- Usage
- API Documentation
- Agent System
- Tools
- Deployment
- Contributing
This multi-agent tutoring system leverages Google's Gemini AI to provide personalized educational assistance across Math and Physics domains. The system intelligently delegates user queries to specialized agents equipped with domain-specific tools and knowledge bases.
- Intelligent Query Routing: Automatically determines the most appropriate agent for each question
- Specialized Domain Expertise: Dedicated Math and Physics agents with tailored responses
- Computational Tools: Built-in calculator and physics constants database
- Real-time Interaction: Smooth, responsive chat interface with typing indicators
- Modern UI/UX: Dark mode, animations, and mobile-responsive design
The system follows a clean multi-agent architecture with clear separation of concerns:
βββββββββββββββββββββββββββββββββββββββ
β USER INTERFACE β
β (Next.js Frontend) β
β β
β βββββββββββββββββββββββββββββββ β
β β Chat Interface β β
β β β’ Message Input/Output β β
β β β’ Agent Response Display β β
β β β’ Real-time Updates β β
β βββββββββββββββββββββββββββββββ β
βββββββββββββββββββ¬ββββββββββββββββββββ
β HTTP/REST API
βΌ
βββββββββββββββββββββββββββββββββββββββ
β FLASK API GATEWAY β
β β
β βββββββββββββββββββββββββββββββ β
β β Tutor Agent β β
β β (Request Router) β β
β β β β
β β β’ Query Analysis β β
β β β’ Agent Selection Logic β β
β β β’ Response Coordination β β
β βββββββββββββββ¬ββββββββββββββββ β
β β β
β ββββββββββ΄βββββββββ β
β βΌ βΌ β
β ββββββββββββ ββββββββββββ β
β β MATH β β PHYSICS β β
β β AGENT β β AGENT β β
β β β β β β
β β β’ Algebraβ β β’ Mechanics β
β β β’ Calculusβ β β’ Thermodynamicsβ
β β β’ Geometryβ β β’ Electromagnetismβ
β ββββββ¬ββββββ βββββββ¬βββββ β
β β β β
β ββββββββββ¬ββββββββββ β
β βΌ β
β βββββββββββββββββββββββββββββββ β
β β TOOL LAYER β β
β β β β
β β βββββββββββ ββββββββββββββββ β
β β βCalculatorβ βPhysics ββ β
β β βTool β βConstants ββ β
β β β β βDatabase ββ β
β β βββββββββββ ββββββββββββββββ β
β βββββββββββββββββββββββββββββββ β
βββββββββββββββββββ¬ββββββββββββββββββββ
β
βΌ
βββββββββββββββββββββββββββββββββββββββ
β GEMINI AI SERVICE β
β β
β β’ Natural Language Processing β
β β’ Mathematical Reasoning β
β β’ Physics Knowledge Base β
β β’ Contextual Understanding β
βββββββββββββββββββββββββββββββββββββββ
- User Query Flow: User inputs question β Frontend sends to Flask API
- Agent Routing: Tutor Agent analyzes query and selects appropriate specialist agent
- Tool Integration: Specialist agents utilize computational tools when needed
- AI Processing: Agents leverage Gemini AI for intelligent responses
- Response Delivery: Formatted response sent back through the chain to user
- Interactive Chat Interface: Real-time messaging with message history
- Agent Identification: Visual badges showing which agent responded
- Responsive Design: Optimized for desktop, tablet, and mobile devices
- Dark Mode: Eye-friendly interface with theme persistence
- Typing Indicators: Visual feedback during AI processing
- Smooth Animations: Framer Motion powered transitions
- Copy to Clipboard: Easy sharing of responses
- Error Handling: Graceful error display and recovery
- Multi-Agent Architecture: Specialized agents for different domains
- Intelligent Routing: Context-aware query delegation
- Tool Integration: Seamless access to computational tools
- Error Recovery: Robust error handling and fallback mechanisms
- CORS Support: Secure cross-origin resource sharing
- Environment Management: Secure API key handling
- Framework: Next.js 14 with TypeScript
- Styling: Tailwind CSS + shadcn/ui components
- Animations: Framer Motion
- State Management: React hooks (useState, useEffect)
- HTTP Client: Axios with interceptors
- Icons: Lucide React
- Framework: Flask (Python)
- AI Integration: Google Generative AI (Gemini)
- CORS: Flask-CORS
- Environment: python-dotenv
- Error Handling: Custom middleware
- Frontend: Vercel (Global CDN)
- Backend: Render (Containerized deployment)
- Environment: Secure environment variable management
- Node.js 18+ and npm/yarn
- Python 3.8+
- Google AI API key (Get it here)
-
Clone the repository
git clone https://github.com/Paulie-Aditya/ai-tutor-multi-agent.git cd ai-tutor-multi-agent/backend
-
Create virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Environment setup
cp .env.example .env # Add your GEMINI_API_KEY to .env
-
Run the backend
python app.py
Backend will start on
http://localhost:5000
-
Navigate to frontend directory
cd ../frontend
-
Install dependencies
npm install # or yarn install
-
Environment setup
cp .env.example .env.local # Add NEXT_PUBLIC_API_URL=http://localhost:5000
-
Run the frontend
npm run dev # or yarn dev
Frontend will start on
http://localhost:3000
- Open the application at
http://localhost:3000
- Type your question in the chat input
- Send your message - the system will automatically route it to the appropriate agent
- View the response with agent identification badges
Math Questions:
- "Solve the quadratic equation xΒ² + 5x + 6 = 0"
- "Calculate the integral of sin(x) from 0 to Ο"
- "What is the derivative of e^(2x)?"
Physics Questions:
- "Explain Newton's second law of motion"
- "What is the speed of light in vacuum?"
- "Calculate the kinetic energy of a 2kg object moving at 10 m/s"
Calculation Requests:
- "Calculate 15 * 23 + 47"
- "What is the square root of 144?"
- "Evaluate (5 + 3) * 2 - 4"
- Development:
http://localhost:5000
- Production:
https://ai-tutor-multi-agent.onrender.com
Send a message to the tutor system.
Request Body:
{
"messages": [{ "role": "user", "content": "What is the derivative of xΒ²?" }]
}
Response:
{
"response": "The derivative of xΒ² is 2x.",
"agent": "MathAgent",
"reason": "The user is asking for the derivative of xΒ² which falls under mathematics."
}
Check API health status.
Response:
{
"status": "healthy",
"timestamp": "2024-01-20T10:30:00Z"
}
Get information about available agents.
Response:
{
"agents": [
{
"name": "math",
"description": "Specialized in mathematical problems and calculations",
"tools": ["calculator"]
},
{
"name": "physics",
"description": "Expert in physics concepts and calculations",
"tools": ["physics_constants", "calculator"]
}
]
}
All agents inherit from the BaseAgent
class, providing:
- Consistent API interface
- Error handling mechanisms
- Response formatting
- Tool integration capabilities
- Specialization: Algebra, calculus, geometry, statistics
- Tools: Calculator, equation solver
- Capabilities:
- Solve equations and inequalities
- Perform complex calculations
- Explain mathematical concepts
- Step-by-step problem solving
- Specialization: Mechanics, thermodynamics, electromagnetism, optics
- Tools: Physics constants database, calculator
- Capabilities:
- Explain physical phenomena
- Perform physics calculations
- Provide relevant constants and formulas
- Solve physics problems
- Function: Intelligent query routing and orchestration
- Logic: Keyword analysis and context understanding
- Fallback: Direct Gemini consultation for ambiguous queries
- Purpose: Perform mathematical calculations safely
- Features:
- Basic arithmetic operations
- Trigonometric functions
- Logarithmic functions
- Expression evaluation with safety checks
- Purpose: Provide accurate physical constants
- Database: 20+ fundamental constants including:
- Speed of light (c)
- Planck's constant (h)
- Gravitational constant (G)
- Electron mass and charge
- And more...
-
Connect to Vercel
npm install -g vercel vercel login vercel
-
Environment Variables
NEXT_PUBLIC_API_URL
: Your backend URL
-
Connect to Render
- Connect your GitHub repository
- Add environment variables:
GEMINI_API_KEY
- Deploy automatically on push
-
Environment Variables
GEMINI_API_KEY
: Your Google AI API keyPORT
: Automatically set by Render
Frontend (.env.local):
NEXT_PUBLIC_API_URL=https://your-backend-url.onrender.com
Backend (.env):
GEMINI_API_KEY=your_gemini_api_key_here
ai-tutor-multi-agent/
βββ backend/
β βββ agents/
β β βββ base_agent.py # Base agent class
β β βββ math_agent.py # Math-specialized agent
β β βββ physics_agent.py # Physics-specialized agent
β β βββ tutor_agent.py # Main routing agent
β βββ tools/
β β βββ calculator.py # Mathematical calculator
β β βββ physics_constants.py # Physics constants database
β βββ app.py # Flask application
β βββ requirements.txt # Python dependencies
βββ frontend/
β βββ components/
β β βββ ui/ # shadcn/ui components
β β βββ Chat/ # Chat-related components
β β βββ Layout/ # Layout components
β βββ pages/
β β βββ api/ # API routes (if needed)
β β βββ index.tsx # Main page
β βββ styles/ # Global styles
β βββ utils/ # Utility functions
β βββ types/ # TypeScript type definitions
βββ README.md
Backend:
# Run development server
python app.py
# Install dependencies
pip install -r requirements.txt
Frontend:
# Run development server
npm run dev
# Build for production
npm run build
# Start production server
npm start
# Lint code
npm run lint
- Fork the repository
- Create a 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
- Follow existing code style and structure
- Add comprehensive comments for complex logic
- Test all agent interactions thoroughly
- Ensure responsive design for new UI components
- Update documentation for new features
This project is licensed under the MIT License - see the LICENSE file for details.
- Google AI for providing the Gemini API
- Vercel for frontend hosting
- Render for backend deployment
- shadcn/ui for beautiful UI components
- Next.js and Flask communities for excellent documentation
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Include steps to reproduce any bugs
Built with β€οΈ using modern web technologies and AI