Smart City Traffic Operations Intelligence — Predictive ML, MIP Optimization, Digital Twin Simulation, Offline LLM Copilot for Bengaluru's 8,173 ASTRAM incidents.
Five sequential tiers — from raw ASTRAM CSV through ML inference, LLM intelligence, REST API, to the React command dashboard. Each tier communicates through typed interfaces.
Hover or click any architecture component in the diagram to inspect mathematical models, data schemas, code references, and exact metrics.
Three Random Forest models trained on 80/20 stratified splits from 8,173 ASTRAM incidents. One TF-IDF vectorizer. All serialized to .joblib files, loaded at FastAPI startup for <50ms inference.
Random Forest · n_estimators=50 · max_depth=12 · Predicts High / Low incident priority before dispatch
Random Forest · Same feature set · Predicts road closure requirement for pre-activating diversion routes
RF Regressor · Predicts incident duration in minutes · closure prediction used as additional input
10,000 feature sparse matrix on composite text: {cause} {description} at {address} in {zone} near {junction}. Cosine similarity against all 8,173 events. Returns top-K with historical action taken.
Use in Copilot: New incident query → retrieves closest match → injects that match's response record into Naxerion as evidence. Prevents hallucination by grounding in real outcomes.
SCIP Mixed-Integer Program. Objective: Min 100x + 20y (x=officers, y=barricades) subject to reduction target constraint.
Not using GPT-4 or Gemini — we built and fine-tuned our own traffic-domain language model. Runs on CPU, zero cloud, zero API keys. Full voice pipeline under 3 seconds.
100% offline capable on a single device. Global publish-subscribe store synchronizes incident context across all 6 screens in <16ms.
Pub/sub store.ts — no Redux. setActiveEvent(patch) → all 6 screens re-render in <16ms via useActiveEvent() hook.
eventCause · zone · junction · lat/lon · priority · roadClosure · durationMin · officers · barricades · diversions[]
FastAPI 0.137 · Uvicorn 0.49 · Pydantic v2 · Auto OpenAPI at http://127.0.0.1:8000/docs
| METHOD | ENDPOINT | MODULE | PURPOSE | KEY RESPONSE FIELDS |
|---|---|---|---|---|
| GET | /health | System | Backend health + loaded model list | status, data_loaded, models_loaded[] |
| GET | /api/analysis/summary | Analysis | Aggregate KPI metrics from 8,173 incidents | total_events, avg_duration_min, road_closures_required |
| GET | /api/analysis/cause-distribution | Analysis | Incident count per cause (11 categories) | [ {cause, count} ] |
| GET | /api/analysis/hotspots | Analysis | 1,000 geo-tagged incidents for Leaflet map | [ {lat, lon, cause, priority, road_closure, address} ] |
| GET | /api/analysis/timeline | Analysis | Monthly planned vs unplanned trend | [ {month, planned, unplanned, total} ] |
| GET | /api/analysis/junction-ranking | Analysis | Top 15 junctions ranked by incident count | [ {junction, count} ] |
| GET | /api/analysis/lessons-learned | Analysis | High-risk junctions + zone + delay causes | top_repeat_junctions[], top_zones[], causes_by_delay[] |
| POST | /api/predict/predict-all | Predict | RF inference chain → priority + closure + duration | predicted_priority, priority_confidence, predicted_duration_minutes |
| GET | /api/predict/feature-importances | Predict | RF feature importance for explainability chart | { "junction": 0.31, "longitude": 0.21, ... } |
| POST | /api/optimize | Optimize | OR-Tools MIP → optimal officers + barricades | recommended_officers, barricades, expected_reduction_percentage |
| POST | /api/similarity | RAG | TF-IDF cosine → top-K historical matches | matches[]: { similarity_score, historical_action, address } |
| POST | /api/simulate | Simulate | Queue-theoretic twin — before vs after intervention | simulation_timeline[], metrics.overall_delay_reduction_percentage |
Key findings extracted directly from the Bengaluru incident dataset — used to drive Naxerion prompting, OR-Tools constraints, and risk gauge calibration.
SilkBoard Junction flagged for permanent officer deployment — highest avg duration + most road closures.
| JUNCTION | INCIDENTS | AVG DURATION | CLOSURES |
|---|---|---|---|
| SilkBoardJunc | 54 | ~112 min | 18 |
| MekhriCircle | 64 | ~95 min | 12 |
| KRCircle | 43 | ~91 min | 11 |
| AyyappaTempleJunc | 58 | ~88 min | 9 |
| BTMLayout2ndStage | 47 | ~78 min | 6 |
Vehicle Breakdown dominates frequency. Water Logging causes longest delays. Accidents drive road closures.
| CAUSE | COUNT / SHARE | AVG DELAY | CAPACITY REDUCTION |
|---|---|---|---|
| Vehicle Breakdown | 4,896 (59.9%) | — | 25% |
| Water Logging | — | ~145 min | 65% |
| Protest | — | ~132 min | 70% |
| VIP Movement | — | — | 60% |
| Accident | — | — | 50% + closures |
| Procession | — | — | 55% |
120-min accident · 6 officers · 25 barricades
Six precise differentiators — each verifiable in the codebase and backed by real metrics from the ASTRAM dataset.
double-click start.bat