A real-time AI-powered traffic management dashboard designed for city traffic authorities to monitor intersections, control signals, manage emergency corridors, and detect incidents โ all from a single command center interface.
๐ด Live Demo | ๐ฅ Demo Video
๐ Getting Started ยท ๐ Features ยท ๐๏ธ Architecture ยท ๐ก API Reference ยท ๐ฏ Pages
Urban traffic congestion leads to โน1.5 lakh crore annual economic losses in India. Current traffic management relies on:
- โ Fixed-timer signals that ignore real-time conditions
- โ Manual monitoring with limited camera coverage
- โ Delayed emergency response due to congested routes
- โ No predictive capabilities for congestion prevention
TrafficAI solves this with an AI-driven, real-time adaptive system that brings intelligence to every intersection.
|
|
|
|
|
|
graph TD
A["๐น Traffic Signal Cameras"] --> B["๐ง Edge AI Processing Node"]
B --> C["๐ Vehicle Detection<br/>(Deep Learning - YOLOv8)"]
B --> D["๐ Grid-Based Traffic<br/>Density Analysis"]
C --> E["โ๏ธ Traffic Data Processing"]
D --> E
E --> F["๐ง Intersection Signal Intelligence"]
F --> G["๐ค Reinforcement Learning<br/>Signal Controller"]
F --> H["๐ Zone Traffic Coordinator"]
G --> I["๐ฆ Traffic Signal Hardware"]
H --> J["๐๏ธ City Traffic Brain"]
J --> K["๐ Traffic Prediction Engine"]
J --> L["๐ Emergency Response System"]
J --> M["๐ฅ Accident Detection System"]
J --> N["๐ฑ Citizen Traffic App"]
L --> O["๐ Emergency Vehicle App"]
L --> P["๐ข Green Corridor<br/>Signal Control"]
L --> Q["๐ก Cell Tower<br/>Broadcast Alerts"]
Q --> R["๐ฑ Citizen Mobile Phones"]
M --> S["๐ Traffic Rerouting Engine"]
S --> T["๐ด Dynamic Red Direction<br/>Indicators"]
N --> U["๐ Live Traffic Updates"]
N --> V["๐ Accident Reporting"]
N --> W["๐บ๏ธ Route Optimization"]
style A fill:#1a1a2e,stroke:#06b6d4,color:#e2e8f0
style B fill:#1a1a2e,stroke:#06b6d4,color:#e2e8f0
style C fill:#1a1a2e,stroke:#10b981,color:#e2e8f0
style D fill:#1a1a2e,stroke:#10b981,color:#e2e8f0
style E fill:#1a1a2e,stroke:#a855f7,color:#e2e8f0
style F fill:#1a1a2e,stroke:#f59e0b,color:#e2e8f0
style G fill:#1a1a2e,stroke:#f59e0b,color:#e2e8f0
style H fill:#1a1a2e,stroke:#f59e0b,color:#e2e8f0
style I fill:#1a1a2e,stroke:#ef4444,color:#e2e8f0
style J fill:#0f172a,stroke:#06b6d4,color:#06b6d4,stroke-width:3px
style K fill:#1a1a2e,stroke:#a855f7,color:#e2e8f0
style L fill:#1a1a2e,stroke:#ef4444,color:#e2e8f0
style M fill:#1a1a2e,stroke:#ef4444,color:#e2e8f0
style N fill:#1a1a2e,stroke:#06b6d4,color:#e2e8f0
style O fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style P fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style Q fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style R fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style S fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style T fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style U fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style V fill:#1e293b,stroke:#94a3b8,color:#94a3b8
style W fill:#1e293b,stroke:#94a3b8,color:#94a3b8
graph LR
subgraph Frontend["๐ฅ๏ธ Frontend (Next.js + React)"]
direction TB
UI["Dashboard UI"]
MAPS["Leaflet Maps"]
CHARTS["Chart.js Analytics"]
SOCKET_C["Socket.IO Client"]
API_C["REST API Client"]
end
subgraph Backend["โ๏ธ Backend (Flask + Python)"]
direction TB
REST["REST API Layer"]
SOCKET_S["Socket.IO Server"]
SIM["Traffic Simulation Engine"]
DATA["Data Store (In-Memory)"]
end
subgraph AI["๐ค AI/ML Pipeline (Future)"]
direction TB
YOLO["YOLOv8 Detection"]
RL["RL Signal Controller"]
PRED["Prediction Engine"]
end
API_C <-->|"HTTP REST"| REST
SOCKET_C <-->|"WebSocket"| SOCKET_S
REST <--> DATA
SOCKET_S <--> SIM
SIM <--> DATA
AI -.->|"Model Inference"| REST
style Frontend fill:#0f172a,stroke:#06b6d4,color:#e2e8f0,stroke-width:2px
style Backend fill:#0f172a,stroke:#10b981,color:#e2e8f0,stroke-width:2px
style AI fill:#0f172a,stroke:#f59e0b,color:#e2e8f0,stroke-width:2px,stroke-dasharray: 5 5
sequenceDiagram
participant C as ๐น Camera/Sensor
participant E as ๐ง Edge AI Node
participant B as โ๏ธ Flask Backend
participant S as ๐ Socket.IO
participant F as ๐ฅ๏ธ Frontend Dashboard
C->>E: Raw video feed
E->>E: YOLOv8 vehicle detection
E->>B: Processed traffic data
B->>B: Update intersection state
B->>S: Emit traffic_update event
S-->>F: Real-time push update
F->>F: Re-render map markers & stats
Note over B,S: Every 5 seconds
B->>B: Signal countdown tick
B->>S: Emit signal_update_batch
S-->>F: Update signal displays
Note over F: User Action
F->>B: POST /api/signals/:id/control
B->>B: Force green / Pause / Reset
B->>S: Emit signal_update
S-->>F: Instant UI update
The command center view โ A bird's-eye view of the entire city traffic network
| Component | Description |
|---|---|
| ๐ KPI Widgets | Active Intersections, Avg Congestion Score, Emergency Corridors, Active Incidents |
| ๐บ๏ธ City Map | Leaflet map with color-coded intersection markers (green/yellow/red) |
| ๐ Charts | Traffic Density over Time, Average Wait Time, Signal Efficiency |
Deep-dive into any intersection โ Three-panel real-time monitoring layout
| Panel | Content |
|---|---|
| ๐ฅ Left โ Camera Feed | Simulated live feed with AI vehicle detection bounding boxes |
| ๐บ๏ธ Center โ Map | Zoomed intersection map with signal phase diagram |
| ๐ Right โ Statistics | Lane-wise vehicle counts, density bars, queue lengths, signal countdown |
AI-assisted traffic signal management with manual override
| Feature | Details |
|---|---|
| ๐ฆ Traffic Lights | Animated red/yellow/green with glow effects |
| ๐ค AI Timing | Recommended green/yellow/red durations from RL model |
| ๐ฎ Controls | Force Green, Pause Signal, Reset to Auto buttons |
| โฑ๏ธ Countdown | Live countdown timer with animated transitions |
Emergency vehicle tracking and green corridor activation
| Feature | Details |
|---|---|
| ๐บ๏ธ Route Map | Emergency vehicle positions + highlighted route paths |
| ๐ Vehicle List | ID, type (๐๐๐), status, clickable selection |
| โน๏ธ Info Panel | Current location, destination, ETA |
| ๐ข Corridor Toggle | Activate/Deactivate emergency corridor buttons |
Real-time incident detection with smart rerouting
| Feature | Details |
|---|---|
| ๐บ๏ธ Incident Map | Markers for accidents ( |
| ๐ Filters | Filter by type: All / Accident / Blockage / Congestion |
| ๐ Detail Cards | Type, location, severity badge, status, description |
| ๐ Alt Routes | AI-suggested alternate routes displayed on map |
Comprehensive traffic analytics and predictive insights
| Feature | Details |
|---|---|
| ๐ 6 Charts | Congestion by Hour, Signal Efficiency, Emergency Response, Traffic Prediction, Density by Zone, Wait Time |
| ๐๏ธ Filters | Date range, Zone selector, Intersection dropdown |
| ๐ Performance Table | All intersections with congestion %, vehicles, wait time, signal phase |
| ๐ KPI Cards | Avg Congestion, Signal Efficiency, Response Time, Incidents Today |
๐ Traffic & Intersections
| Method | Endpoint | Description |
|---|---|---|
GET |
/intersections |
List all intersections with real-time data |
GET |
/intersections/:id |
Get single intersection details |
GET |
/intersections/stats |
Aggregate stats (avg congestion, vehicle count) |
Example Response โ /api/intersections/stats
{
"totalActive": 12,
"avgCongestionScore": 56,
"heavyCount": 4,
"moderateCount": 4,
"lowCount": 4,
"totalVehicles": 2557
}๐ฆ Signal Control
| Method | Endpoint | Description |
|---|---|---|
GET |
/signals |
List all signals |
GET |
/signals/:id |
Get signal details |
POST |
/signals/:id/control |
Manual control (force_green / pause / reset) |
POST Body:
{ "action": "force_green" }โ ๏ธ Incidents
| Method | Endpoint | Description |
|---|---|---|
GET |
/incidents |
List incidents (filterable: ?type=accident&severity=high) |
GET |
/incidents/:id |
Get incident with alternate routes |
GET |
/incidents/summary |
Count by type and status |
๐ Emergency
| Method | Endpoint | Description |
|---|---|---|
GET |
/emergency/vehicles |
List all emergency vehicles |
GET |
/emergency/vehicles/:id |
Get vehicle details with route |
POST |
/emergency/vehicles/:id/corridor |
Activate/deactivate corridor |
๐ Analytics
| Method | Endpoint | Description |
|---|---|---|
GET |
/analytics/traffic-density |
Traffic density by zone over time |
GET |
/analytics/congestion-by-hour |
Hourly congestion averages |
GET |
/analytics/signal-efficiency |
Per-intersection signal efficiency |
GET |
/analytics/emergency-response |
Weekly response time trends |
GET |
/analytics/prediction |
6-hour traffic prediction |
GET |
/analytics/summary |
KPI summary stats |
๐ Socket.IO Events
| Event | Direction | Description |
|---|---|---|
traffic_update |
Server โ Client | Real-time intersection data (every 5s) |
signal_update_batch |
Server โ Client | All signal countdown updates |
signal_update |
Server โ Client | Individual signal state change |
corridor_update |
Server โ Client | Emergency corridor toggle |
incident_alert |
Server โ Client | New incident detected |
INDIA_INNOVATES/
โ
โโโ ๐ backend/ # Python Flask Backend
โ โโโ app.py # Main server (REST + Socket.IO + Simulation)
โ โโโ requirements.txt # Python dependencies
โ
โโโ ๐ src/ # Next.js Frontend
โ โโโ ๐ app/ # Pages (App Router)
โ โ โโโ layout.tsx # Root layout (Sidebar + TopBar)
โ โ โโโ globals.css # Dark cyberpunk theme
โ โ โโโ page.tsx # Dashboard Overview
โ โ โโโ ๐ intersections/ # Intersection Monitoring
โ โ โโโ ๐ signals/ # Signal Control
โ โ โโโ ๐ emergency/ # Emergency Corridor
โ โ โโโ ๐ incidents/ # Incident Monitoring
โ โ โโโ ๐ analytics/ # Analytics & Reports
โ โ
โ โโโ ๐ components/ # Reusable UI Components
โ โ โโโ ๐ layout/ # Sidebar, TopBar
โ โ โโโ ๐ maps/ # MapView (Leaflet)
โ โ โโโ ๐ traffic/ # StatsCard, CameraFeed
โ โ โโโ ๐ signals/ # SignalControlPanel
โ โ โโโ ๐ alerts/ # IncidentAlertPanel
โ โ โโโ ๐ charts/ # AnalyticsChart (Chart.js)
โ โ
โ โโโ ๐ services/ # API & Socket.IO Client
โ โ โโโ api.ts # REST API service layer
โ โ โโโ socket.ts # Socket.IO real-time client
โ โ
โ โโโ ๐ lib/ # Utilities & Mock Data
โ โโโ mockData.ts # Hardcoded demo data
โ
โโโ package.json
โโโ tailwind.config.ts
โโโ tsconfig.json
โโโ README.md
| Tool | Version |
|---|---|
| Node.js | >= 18.x |
| Python | >= 3.9 |
| npm | >= 9.x |
# 1. Clone the repository
git clone https://github.com/your-username/INDIA_INNOVATES.git
cd INDIA_INNOVATES
# 2. Install frontend dependencies
npm install
# 3. Install backend dependencies
cd backend
pip3 install -r requirements.txt
cd ..# Terminal 1 โ Frontend (http://localhost:3000)
npm run dev
# Terminal 2 โ Backend (http://localhost:5001)
cd backend
python3 app.py๐ก Open http://localhost:3000 in your browser to access the dashboard.
npm run build
npm startgraph TB
subgraph Presentation["๐จ Presentation Layer"]
NEXT["Next.js 16 (App Router)"]
REACT["React 19"]
TW["Tailwind CSS 4"]
FM["Framer Motion"]
end
subgraph Visualization["๐ Visualization Layer"]
LEAF["Leaflet + CartoDB Dark Tiles"]
CHART["Chart.js + react-chartjs-2"]
HERO["Heroicons"]
end
subgraph Communication["๐ Communication Layer"]
REST_C["REST API (fetch)"]
WS_C["Socket.IO Client"]
end
subgraph Server["โ๏ธ Server Layer"]
FLASK["Flask 3.0"]
CORS["Flask-CORS"]
SIO["Flask-SocketIO"]
SIM2["Background Simulator Thread"]
end
subgraph Future["๐ฎ Future: AI/ML Layer"]
YOLO2["YOLOv8 Object Detection"]
RL2["Deep RL Signal Optimization"]
LSTM["LSTM Traffic Prediction"]
CV["OpenCV Video Processing"]
end
Presentation --> Visualization
Presentation --> Communication
Communication --> Server
Future -.-> Server
style Presentation fill:#0f172a,stroke:#06b6d4,color:#e2e8f0,stroke-width:2px
style Visualization fill:#0f172a,stroke:#a855f7,color:#e2e8f0,stroke-width:2px
style Communication fill:#0f172a,stroke:#10b981,color:#e2e8f0,stroke-width:2px
style Server fill:#0f172a,stroke:#f59e0b,color:#e2e8f0,stroke-width:2px
style Future fill:#0f172a,stroke:#ef4444,color:#e2e8f0,stroke-width:2px,stroke-dasharray: 5 5
| Component | Technology | Purpose |
|---|---|---|
| Vehicle Detection | YOLOv8 + OpenCV | Real-time vehicle counting and classification from camera feeds |
| Signal Optimization | Deep Reinforcement Learning (DQN) | Adaptive signal timing that learns from traffic patterns |
| Traffic Prediction | LSTM Neural Network | 6-hour congestion forecasting for proactive management |
| Accident Detection | CNN-based Anomaly Detection | Automatic accident identification from camera feeds |
| Density Analysis | Grid-based Heatmap Algorithm | Lane-wise traffic density calculation |
The UI is designed as a professional traffic command center with:
| Aspect | Implementation |
|---|---|
| ๐ Dark Theme | Navy/slate background (#0a0e1a) reducing eye strain for 24/7 operators |
| โจ Neon Accents | Cyan, green, amber, red โ following traffic signal conventions |
| ๐ฎ Glassmorphism | Frosted glass panels with backdrop-blur for depth |
| ๐ก Glowing Indicators | CSS box-shadow glow effects on traffic signals and status dots |
| ๐ฌ Micro-animations | Framer Motion transitions, pulsing dots, scanner lines |
| ๐ฑ Responsive | Adapts from 1080p monitors to ultrawide command center displays |
This project is licensed under the MIT License โ see the LICENSE file for details.