An intelligent AI-powered geometry tutor that combines LangGraph state management, Google Gemini AI, and advanced visualization with Asymptote to provide interactive Vietnamese geometry problem solving with real-time hints, solution validation, and professional geometric figure generation.
At the current stage, it supports text-based problem solving and image-based problem extraction, with a focus on Vietnamese geometry education for secondary Vietnamese students with planar geometry.
- Multi-Modal Input: Supports both text problems and image uploads for problem extraction
- Vietnamese Language Support: Native Vietnamese geometry problem parsing and explanation
- Progressive Hints: Intelligent 3-level hint system that guides without giving away answers
- Solution Validation: AI-powered scoring and feedback on student solutions
- Image Recognition: Extract geometry problems directly from uploaded images
- Asymptote Integration: Professional mathematical diagrams using Asymptote rendering
- AI-Generated Figures: Automatic geometric figure creation from problem descriptions
- Interactive Plots: Real-time visualization during problem-solving sessions
- Multiple Geometry Types: Support for triangles, circles, quadrilaterals, complex constructions
- LangGraph Workflow: Graph-based state management for complex AI interactions
- FastAPI Backend: High-performance REST API with automatic OpenAPI documentation
- Next.js Frontend: Modern React-based user interface with TypeScript
- Containerized Deployment: Docker-ready for easy development and production deployment
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Next.js β β FastAPI β β LangGraph β
β Frontend βββββΊβ Backend βββββΊβ Workflow β
β β β β β β
β β’ React UI β β β’ REST API β β β’ State Mgmt β
β β’ TypeScript β β β’ CORS Support β β β’ AI Agents β
β β’ Tailwind CSS β β β’ File Upload β β β’ Node Routing β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β Google β
β Gemini AI β
β β
β β’ Problem Parse β
β β’ Hint Generate β
β β’ Solution Val. β
β β’ Image Extract β
βββββββββββββββββββ
- Docker & Docker Compose (recommended)
- Python 3.11+ (for local development)
- Node.js 18+ (for frontend development)
- Google API Key (for Gemini AI access)
-
Clone the repository:
git clone https://github.com/your-username/Math-tutor-VAS.git cd Math-tutor-VAS
-
Configure environment variables:
cd backend cp .env.template .env # Edit .env and add your GOOGLE_API_KEY
-
Launch with Docker Compose:
docker-compose up --build
-
Access the application:
- API Server: http://localhost:8000
- API Documentation: http://localhost:8000/docs
- Frontend: Configure separately or use existing Dash app
cd backend
pip install -r requirements.txt
export GOOGLE_API_KEY="your-api-key-here"
uvicorn api.main:app --reload --host 0.0.0.0 --port 8000
cd frontend
npm install
npm run dev
# Available at http://localhost:3000
cd app
pip install dash dash-bootstrap-components
python app.py
# Available at http://localhost:8050
-
Create a new session with a Vietnamese geometry problem:
POST /sessions { "problem_text": "Cho tam giΓ‘c ABC cΓ³ AB = 3, BC = 4, CA = 5. Chα»©ng minh rαΊ±ng tam giΓ‘c ABC vuΓ΄ng tαΊ‘i B.", "is_img": false } Response: { "session_id": "uuid-string", "message": "Session created successfully", "total_questions": 1 }
-
Get progressive hints:
POST /hint { "session_id": "uuid-string" } Response: { "success": true, "hint_text": "HΓ£y xem xΓ©t mα»i quan hα» giα»―a cΓ‘c cαΊ‘nh cα»§a tam giΓ‘c...", "hint_level": 1, "max_hints_reached": false }
-
Submit solution for validation:
POST /validate { "session_id": "uuid-string", "user_input": "Γp dα»₯ng Δα»nh lΓ½ Pythagoras: ABΒ² + BCΒ² = 3Β² + 4Β² = 9 + 16 = 25 = 5Β² = CAΒ²" } Response: { "success": true, "is_correct": true, "feedback": "ChΓnh xΓ‘c! BαΊ‘n ΔΓ£ Γ‘p dα»₯ng ΔΓΊng Δα»nh lΓ½ Pythagoras...", "score": 95, "moved_to_next": true, "session_complete": true }
-
Get complete solution:
GET /solution { "session_id": "uuid-string" } Response: { "success": true, "solution_text": "GiαΊ£i chi tiαΊΏt: Ta cΓ³ AB = 3, BC = 4, CA = 5...", "moved_to_next": true, "session_complete": true }
POST /sessions
{
"is_img": true,
"img": "data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD..."
}
Response:
{
"session_id": "uuid-string",
"message": "Session created successfully",
"total_questions": 2
}
GET /illustration
{
"session_id": "uuid-string"
}
Response:
{
"success": true,
"message": "Illustration generated successfully",
"b64_string_viz": "iVBORw0KGgoAAAANSUhEUgAAAB..."
}
# Get session status
GET /status
{
"session_id": "uuid-string"
}
# List all active sessions
GET /sessions
# Delete a session
DELETE /sessions
{
"session_id": "uuid-string"
}
Method | Endpoint | Description |
---|---|---|
POST |
/sessions |
Create new problem session (text or image) |
GET |
/status |
Get current session status and progress |
POST |
/hint |
Request progressive hint for current question |
POST |
/validate |
Submit solution for validation and scoring |
GET |
/solution |
Get complete solution for current question |
GET |
/illustration |
Generate geometric visualization |
GET |
/sessions |
List all active sessions (admin) |
DELETE |
/sessions |
Delete a specific session |
GET |
/health |
Health check endpoint |
GET |
/docs |
Interactive API documentation (Swagger UI) |
GET |
/redoc |
Alternative API documentation (ReDoc) |
class GraphState(TypedDict):
# Problem Setup
original_problem: str
parsed_elements: Dict[str, Any]
questions: List[str]
# Dynamic State
current_question_index: int
known_facts: List[str]
ai_discovered_facts: List[str]
reasoning_chain: List[Dict[str, str]]
# User Interaction
user_solution_attempt: str
hint_level: int
generated_hints: List[str]
validation_score: int
# Visualization
illustration_steps: List[str]
# Control Flow
user_action: str
session_complete: bool
- π Parsing Agent: Extracts structured data from Vietnamese geometry problems
- π― Reasoning Agent: Generates step-by-step solution paths
- π‘ Hint Agent: Creates progressive educational hints
- β Validation Agent: Scores and provides feedback on solutions
- πΌοΈ Visualization Agent: Generates geometric figures and diagrams
[START] β Parse Problem β Generate Solution β Setup Questions
β
Get User Input β Classify Input β Route Action
β β β
Process Hint β Generate Hint Validate Solution
β β β
Update State β Update State Update State
β β β
Check Complete β Check Complete β Check Complete
β
[END/NEXT QUESTION]
- π Python 3.11+: Core backend language
- β‘ FastAPI: Modern, fast web framework for APIs
- π€ Google Gemini: Large language model for AI reasoning
- π LangGraph: State management and workflow orchestration
- π Matplotlib: Mathematical plotting and visualization
- πΌοΈ Asymptote: Professional mathematical diagram generation
- π³ Docker: Containerization and deployment
- βοΈ Next.js 15.3: React-based frontend framework
- π TypeScript: Type-safe JavaScript development
- π¨ Tailwind CSS: Utility-first CSS framework
- π Dash: Alternative Python-based web interface
- π Radix UI: Accessible component library
- π LangChain: LLM application framework
- π Pydantic: Data validation and serialization
- π’ NumPy: Numerical computing
- π Matplotlib: Plotting and visualization
Math-tutor-VAS/
βββ π backend/ # FastAPI backend server
β βββ π api/ # REST API endpoints
β β βββ main.py # FastAPI application entry
β β βββ tutor.py # API tutor implementation
β β βββ π asymptote/ # Visualization engine
β βββ π geometry_tutor/ # Core LangGraph implementation
β β βββ agents.py # AI agent node implementations
β β βββ core.py # State management & data structures
β β βββ graph.py # LangGraph workflow definition
β β βββ prompts.py # AI prompt templates
β β βββ llm_utils.py # LLM initialization & chains
β βββ requirements.txt # Python dependencies
β βββ Dockerfile # Backend container configuration
β βββ docker-compose.yml # Multi-service orchestration
βββ π frontend/ # Next.js frontend application
β βββ π src/ # TypeScript source code
β β βββ π app/ # Next.js app router
β β βββ π components/ # React components
β βββ package.json # Node.js dependencies
β βββ next.config.ts # Next.js configuration
βββ π app/ # Alternative Dash frontend
β βββ app.py # Dash application entry
β βββ π pages/ # Dash page components
β βββ π assets/ # Static assets (CSS, JS)
βββ π README.md # Project documentation
Variable | Description | Default | Required |
---|---|---|---|
GOOGLE_API_KEY |
Google Gemini API key | - | β |
LLM_TEMPERATURE |
AI response creativity (0.0-1.0) | 0.1 | β |
MAX_OUTPUT_TOKENS |
Maximum AI response length | 2048 | β |
ASYMPTOTE_TEXPATH |
LaTeX binary path | /usr/bin | β |
ASYMPTOTE_MAGICKPATH |
ImageMagick path | /usr/bin | β |
# docker-compose.yml
services:
geometry-tutor:
build: .
ports:
- "8000:8000"
environment:
- GOOGLE_API_KEY=${GOOGLE_API_KEY}
volumes:
- asymptote_temp:/tmp/asymptote
# Backend tests
cd backend
python -m pytest tests/
# Frontend tests
cd frontend
npm run test
# Python formatting
black backend/
flake8 backend/
# TypeScript formatting
cd frontend
npm run lint
npm run format
- Backend: FastAPI auto-reload on file changes
- Frontend: Next.js hot module replacement
- Docker: Multi-stage builds for optimization
- Fork the repository
- Create feature branch:
git checkout -b feature/amazing-feature
- Commit changes:
git commit -m 'Add amazing feature'
- Push to branch:
git push origin feature/amazing-feature
- Open Pull Request
- Follow PEP 8 for Python code
- Use TypeScript for all frontend code
- Write comprehensive docstrings
- Add tests for new features
- Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini: Advanced AI language model
- LangGraph: State management framework
- FastAPI: High-performance web framework
- Next.js: React-based frontend framework
- Asymptote: Mathematical diagram generation
- Issues: GitHub Issues
- Documentation: API Docs
- Community: Discussions
Built with β€οΈ for Vietnamese geometry education