================================================================================ PHASE 1 — SIMULATION TIER (City Data Firehose)
┌────────────────────┐ ┌────────────────────┐ ┌────────────────────┐ │ 🚗 Traffic Simulator│ │ ⚡ Power Simulator │ │ ☣️ Env Simulator │ └──────────┬─────────┘ └──────────┬─────────┘ └──────────┬─────────┘ │ │ │ └───────────────┬──────────┴──────────┬───────────────┘ ▼ ▼
┌─────────────────────────────────────┐
│ 🔄 NGINX API Gateway / Load Balancer│
│ Routes based on API path │
│ │
│ /api/traffic │
│ /api/power │
│ /api/environment │
└───────────────┬───────────┬─────────┘
│ │
================================================================================ PHASE 2 — EDGE PROCESSING TIER (Fast Layer)
┌────────────────────┐ ┌────────────────────┐ ┌────────────────────┐
│ 🚦 Traffic Worker │ │ 🔌 Power Worker │ │ ☁️ Env Worker │
│ Port :5000 │ │ Port :5001 │ │ Port :5002 │
└──────────┬─────────┘ └──────────┬─────────┘ └──────────┬─────────┘
│ │ │
│ │ │
└───────────────┬────────┴────────┬───────────────┘
▼ ▼
(Maintains 60-second rolling state memory)
================================================================================ DATA DECISION LAYER
┌─────────────────────────────┐
│ Edge Anomaly Detection │
│ │
│ Normal Data → Store │
│ Anomaly → AI Trigger │
└──────────────┬──────────────┘
│
▼
================================================================================ PHASE 3 — DURABLE STORAGE
┌─────────────────────────────┐
│ 🗄️ PostgreSQL Telemetry DB │
│ Batch logs sensor data │
└──────────────┬──────────────┘
│
▼
================================================================================ PHASE 4 — AGENTIC AI BRAIN
┌─────────────────────────────┐
│ 🧠 Agentic AI Orchestrator │
│ │
│ Queries 5-min context │
│ across all sensors │
└──────────────┬──────────────┘
│
▼
┌─────────────────────────────┐
│ 🌐 Groq / Gemini LLM API │
│ Generates incident report │
└──────────────┬──────────────┘
│
▼
================================================================================ PHASE 5 — OPERATIONS & HUMAN CONTROL
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ 📊 Grafana Monitoring │ │ 💻 React Command Center │
│ Live telemetry charts │ │ Displays AI Incident Report │
└──────────────┬──────────────┘ └──────────────┬──────────────┘
│ │
▼ ▼
┌─────────────────────────────────────────────┐
│ 👨💼 Human-in-the-Loop (City Operator) │
│ │
│ [ APPROVE ] | [ REJECT ] │
└─────────────────────────────────────────────┘