System Architecture
Architecture Diagram
System Architecture
┌──────────────────────────────────┐
│ CLIENT LAYER │
│ Web • Mobile • External API │
└─────────────────┬────────────────┘
│
│ HTTPS (TLS 1.3)
│
┌───────────────────▼──────────────────┐
│ JAVA API GATEWAY (Port 8080) │
│ Spring Boot 3.2.3 │
├──────────────────────────────────────┤
│ • JWT Authentication (HS256) │
│ • Request Validation │
│ • Fallback Logic (RED signal) │
│ • Circuit Breaker Pattern │
└───────────────────┬──────────────────┘
│
┌───────────┴─────────────┐
│ │
┌────────────▼────────┐ ┌────────────▼────────────┐
│ HEALTH CHECK │ │ PREDICTION REQUESTS │
│ /health │ │ /traffic/action │
└─────────────────────┘ └─┬───────────────────────┘
│
┌────────────▼────────────┐
│ INFERENCE SERVICE │
│ (Port 8000) │
│ Python/FastAPI │
├─────────────────────────┤
│ • MAPPO RL Model │
│ • 5-Junction Support │
│ • GRU State Mgmt │
│ • Action Masking │
└────────────┬────────────┘
│
┌──────────────┴────────────┐
│ │
┌────────────▼──────────┐ ┌────────────▼────────────┐
│ LSTM PREDICTOR │ │ ACTION SELECTION │
│ (Port 8001) │ │ (MAPPO Output) │
│ Python/FastAPI │ │ │
├───────────────────────┤ │ Actions: │
│ • Time-series LSTM │ │ 0: RED │
│ • 15-min Forecast │ │ 1: YELLOW │
│ • MAE < 10% │ │ 2: GREEN │
│ • Data Pipeline │ │ 3: GREEN_EXTENDED │
└───────────────────────┘ └────────────┬────────────┘
│
│ Signal State
│
┌────────────▼────────────┐
│ RESPONSE TO CLIENT │
│ { │
│ action: 0-3, │
│ signalState: "RED", │
│ confidence: 0.87 │
│ } │
└─────────────────────────┘
Overview
The AI Traffic Control API is a distributed, microservices-based system designed to provide real-time traffic signal control recommendations using trained Reinforcement Learning (RL) models.
🗂️ Project Structure
Start here to understand the codebase organization: - Project Structure — Complete directory layout and file descriptions
📚 Conceptual Understanding
Build foundational knowledge about the system design:
- High-Level Overview — Bird's-eye view of the architecture
- System Components — Key services and their responsibilities
- Request-Response Flow — How requests move through the system
🔄 Data & Processing
Understand how data flows and is processed:
- Data Flow Through System — Complete data journey from input to output
- Detailed Internal Flow - Action Prediction — Deep dive into prediction logic
- Model Loading & Caching Strategy — How models are initialized and cached
🔗 Workflows & Protocols
Learn about complete workflows and inter-service communication:
- Complete End-to-End Workflow — Full lifecycle from client request to response
- Inter-Service Communication Protocol — How services talk to each other
- Error Handling Flow — Exception handling and fallback mechanisms
🚀 Operations & Deployment
Learn how the system runs in production:
- Deployment Architecture — Cloud deployment setup and infrastructure
- Deployment Patterns — Deployment strategies and best practices
- Monitoring & Observability Points — Logging, metrics, and health checks
🎯 Design & Optimization
Understand design decisions and optimization considerations:
- Architecture Decision Rationale — Why key decisions were made
- Security Architecture — Security mechanisms and JWT implementation
- Performance Characteristics — Latency, throughput, and performance metrics
- Scalability Considerations — How the system scales and handles load
Quick Navigation
For different audiences:
- 👤 New to the project? Start with High-Level Overview → System Components
- 🛠️ Setting up locally? See Deployment Architecture + Setup guides in the nav
- 🔍 Debugging an issue? Check Error Handling Flow → Monitoring & Observability Points
- 📈 Optimizing performance? Read Performance Characteristics → Scalability Considerations
- 🔐 Security review? Start with Security Architecture