# erick5940/sih2026 architecture

> Architecture diagram of the GitHub repository erick5940/sih2026, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/erick5940/sih2026
- Repository: https://github.com/erick5940/sih2026

## Overview

This is a regional logistics-intelligence command center for monitoring disruptions, vehicles, accessibility, and essential supplies, with separate field-reporting and driver/model views. The main workflow is the command dashboard: it combines live vehicle data and incident reports with GIS, impact, route-risk, alternate-routing, and logistics-priority views; priority actions can request rerouting. Field officers can submit GPS-tagged reports offline and synchronize them later. Edges follow visible imports, calls, or documented API/storage behavior; unsampled route and prediction integrations are shown without inferred callers.

Main entry points: [`src/app/page.tsx`](https://github.com/erick5940/sih2026/blob/main/src/app/page.tsx) (Command center), [`src/app/api/incidents/route.ts`](https://github.com/erick5940/sih2026/blob/main/src/app/api/incidents/route.ts) (Incident API), [`src/app/field/page.tsx`](https://github.com/erick5940/sih2026/blob/main/src/app/field/page.tsx) (Field reporting), [`src/components/GISMap.tsx`](https://github.com/erick5940/sih2026/blob/main/src/components/GISMap.tsx) (GIS map)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_command["Command dashboard"]
  node_dashboard["Command center<br/>[page.tsx]"]
  node_map["GIS map<br/>[GISMap.tsx]"]
  node_impact["Impact analysis<br/>[ImpactPanel.tsx]"]
  node_alerts["Alert system<br/>[AlertSystem.tsx]"]
  node_nav["Command navigation<br/>[CommandNav.tsx]"]
  node_language["Language switching"]
  node_i18n["Translations<br/>[i18n.ts]"]
end

subgraph group_routing["Routing and logistics"]
  node_route_risk["Disruption predictor"]
  node_alternate["Alternate routes"]
  node_priority["Logistics priority"]
  node_supply["Supply gaps<br/>[SupplyGapPanel.tsx]"]
  node_hubs["Supply hubs<br/>[hubs.ts]"]
  node_spatial["Spatial analysis<br/>[spatial.ts]"]
end

subgraph group_incidents["Incident response"]
  node_incident_ui["Incident reporting"]
  node_emergency["Emergency mode<br/>[EmergencyMode.tsx]"]
end

subgraph group_operations["Field and vehicle operations"]
  node_field["Field reporting<br/>[page.tsx]"]
  node_field_map["Field mini-map<br/>[FieldMiniMap.tsx]"]
  node_offline[("Offline report queue<br/>[offlineDB.ts]")]
  node_gps_tracker["Live GPS tracker<br/>[LiveGPSTracker.tsx]"]
  node_vehicle_tracking["Vehicle tracking"]
  node_driver["Driver view<br/>[page.tsx]"]
  node_model["Model view<br/>[page.tsx]"]
end

subgraph group_services["API and persistence"]
  node_live_hook["Live vehicle polling<br/>[useLiveVehicles.ts]"]
  node_gps_api["GPS ingest API<br/>[route.ts]"]
  node_incident_api["Incident API<br/>[route.ts]"]
  node_reroute_api["Reroute API<br/>[route.ts]"]
  node_valhalla_api["Valhalla route API<br/>[route.ts]"]
  node_osrm_api["OSRM route API<br/>[route.ts]"]
  node_predict_api["Prediction API<br/>[route.ts]"]
  node_weather_api["Live weather API<br/>[route.ts]"]
  node_supabase_client["Supabase client<br/>[supabase.ts]"]
  node_incident_store[("Incident records")]
end

node_operator(("Operations user"))

node_operator -->|"uses"| node_dashboard
node_dashboard -->|"renders"| node_map
node_dashboard -->|"renders"| node_route_risk
node_dashboard -->|"renders"| node_alternate
node_dashboard -->|"renders"| node_priority
node_dashboard -->|"renders"| node_incident_ui
node_dashboard -->|"renders"| node_vehicle_tracking
node_dashboard -->|"renders"| node_alerts
node_dashboard -->|"renders"| node_emergency
node_dashboard -->|"renders"| node_nav
node_dashboard -->|"renders"| node_language
node_dashboard -->|"renders"| node_impact
node_dashboard -->|"renders"| node_supply
node_dashboard -->|"polls via"| node_live_hook
node_language -->|"uses"| node_i18n
node_map -->|"reads"| node_hubs
node_impact -->|"uses"| node_spatial
node_spatial -->|"reads"| node_hubs
node_field -->|"renders"| node_field_map
node_field -->|"queues reports"| node_offline
node_field -->|"submits reports"| node_incident_api
node_offline -->|"synchronizes"| node_incident_api
node_live_hook -->|"polls"| node_gps_api
node_priority -->|"requests reroute"| node_reroute_api
node_alternate -->|"requests routes"| node_valhalla_api
node_incident_api -->|"uses"| node_supabase_client
node_incident_api -->|"reads and writes"| node_incident_store

click node_dashboard "https://github.com/erick5940/sih2026/blob/main/src/app/page.tsx"
click node_map "https://github.com/erick5940/sih2026/blob/main/src/components/GISMap.tsx"
click node_impact "https://github.com/erick5940/sih2026/blob/main/src/components/ImpactPanel.tsx"
click node_alerts "https://github.com/erick5940/sih2026/blob/main/src/components/AlertSystem.tsx"
click node_nav "https://github.com/erick5940/sih2026/blob/main/src/components/CommandNav.tsx"
click node_language "https://github.com/erick5940/sih2026/blob/main/src/components/LanguageSwitcher.tsx"
click node_i18n "https://github.com/erick5940/sih2026/blob/main/src/lib/i18n.ts"
click node_route_risk "https://github.com/erick5940/sih2026/blob/main/src/components/RouteDisruptionPredictor.tsx"
click node_alternate "https://github.com/erick5940/sih2026/blob/main/src/components/SmartAlternateRouteEngine.tsx"
click node_priority "https://github.com/erick5940/sih2026/blob/main/src/components/LogisticsPriorityEngine.tsx"
click node_supply "https://github.com/erick5940/sih2026/blob/main/src/components/SupplyGapPanel.tsx"
click node_hubs "https://github.com/erick5940/sih2026/blob/main/src/lib/hubs.ts"
click node_spatial "https://github.com/erick5940/sih2026/blob/main/src/lib/spatial.ts"
click node_incident_ui "https://github.com/erick5940/sih2026/blob/main/src/components/IncidentReporting.tsx"
click node_emergency "https://github.com/erick5940/sih2026/blob/main/src/components/EmergencyMode.tsx"
click node_field "https://github.com/erick5940/sih2026/blob/main/src/app/field/page.tsx"
click node_field_map "https://github.com/erick5940/sih2026/blob/main/src/components/FieldMiniMap.tsx"
click node_offline "https://github.com/erick5940/sih2026/blob/main/src/lib/offlineDB.ts"
click node_gps_tracker "https://github.com/erick5940/sih2026/blob/main/src/components/LiveGPSTracker.tsx"
click node_vehicle_tracking "https://github.com/erick5940/sih2026/blob/main/src/components/VehicleTracking.tsx"
click node_driver "https://github.com/erick5940/sih2026/blob/main/src/app/driver/page.tsx"
click node_model "https://github.com/erick5940/sih2026/blob/main/src/app/model/page.tsx"
click node_live_hook "https://github.com/erick5940/sih2026/blob/main/src/lib/useLiveVehicles.ts"
click node_gps_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/gps/ingest/route.ts"
click node_incident_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/incidents/route.ts"
click node_reroute_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/reroute/route.ts"
click node_valhalla_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/route-valhalla/route.ts"
click node_osrm_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/route-osrm/route.ts"
click node_predict_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/predict/route.ts"
click node_weather_api "https://github.com/erick5940/sih2026/blob/main/src/app/api/weather/live/route.ts"
click node_supabase_client "https://github.com/erick5940/sih2026/blob/main/src/lib/supabase.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_map,node_impact,node_alerts,node_nav,node_language,node_i18n,node_operator toneBlue
class node_route_risk,node_alternate,node_priority,node_supply,node_hubs,node_spatial toneAmber
class node_incident_ui,node_emergency toneMint
class node_field,node_field_map,node_offline,node_gps_tracker,node_vehicle_tracking,node_driver,node_model toneRose
class node_live_hook,node_gps_api,node_incident_api,node_reroute_api,node_valhalla_api,node_osrm_api,node_predict_api,node_weather_api,node_supabase_client,node_incident_store toneIndigo
```

## Components

### Command dashboard

- [Command center](https://github.com/erick5940/sih2026/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [GIS map](https://github.com/erick5940/sih2026/blob/main/src/components/GISMap.tsx): `src/components/GISMap.tsx`
- [Impact analysis](https://github.com/erick5940/sih2026/blob/main/src/components/ImpactPanel.tsx): `src/components/ImpactPanel.tsx`
- [Alert system](https://github.com/erick5940/sih2026/blob/main/src/components/AlertSystem.tsx): `src/components/AlertSystem.tsx`
- [Command navigation](https://github.com/erick5940/sih2026/blob/main/src/components/CommandNav.tsx): `src/components/CommandNav.tsx`
- [Language switching](https://github.com/erick5940/sih2026/blob/main/src/components/LanguageSwitcher.tsx): `src/components/LanguageSwitcher.tsx`
- [Translations](https://github.com/erick5940/sih2026/blob/main/src/lib/i18n.ts): `src/lib/i18n.ts`

### Routing and logistics

- [Disruption predictor](https://github.com/erick5940/sih2026/blob/main/src/components/RouteDisruptionPredictor.tsx): `src/components/RouteDisruptionPredictor.tsx`
- [Alternate routes](https://github.com/erick5940/sih2026/blob/main/src/components/SmartAlternateRouteEngine.tsx): `src/components/SmartAlternateRouteEngine.tsx`
- [Logistics priority](https://github.com/erick5940/sih2026/blob/main/src/components/LogisticsPriorityEngine.tsx): `src/components/LogisticsPriorityEngine.tsx`
- [Supply gaps](https://github.com/erick5940/sih2026/blob/main/src/components/SupplyGapPanel.tsx): `src/components/SupplyGapPanel.tsx`
- [Supply hubs](https://github.com/erick5940/sih2026/blob/main/src/lib/hubs.ts): `src/lib/hubs.ts`
- [Spatial analysis](https://github.com/erick5940/sih2026/blob/main/src/lib/spatial.ts): `src/lib/spatial.ts`

### Incident response

- [Incident reporting](https://github.com/erick5940/sih2026/blob/main/src/components/IncidentReporting.tsx): `src/components/IncidentReporting.tsx`
- [Emergency mode](https://github.com/erick5940/sih2026/blob/main/src/components/EmergencyMode.tsx): `src/components/EmergencyMode.tsx`

### Field and vehicle operations

- [Field reporting](https://github.com/erick5940/sih2026/blob/main/src/app/field/page.tsx): `src/app/field/page.tsx`
- [Field mini-map](https://github.com/erick5940/sih2026/blob/main/src/components/FieldMiniMap.tsx): `src/components/FieldMiniMap.tsx`
- [Offline report queue](https://github.com/erick5940/sih2026/blob/main/src/lib/offlineDB.ts): `src/lib/offlineDB.ts`
- [Live GPS tracker](https://github.com/erick5940/sih2026/blob/main/src/components/LiveGPSTracker.tsx): `src/components/LiveGPSTracker.tsx`
- [Vehicle tracking](https://github.com/erick5940/sih2026/blob/main/src/components/VehicleTracking.tsx): `src/components/VehicleTracking.tsx`
- [Driver view](https://github.com/erick5940/sih2026/blob/main/src/app/driver/page.tsx): `src/app/driver/page.tsx`
- [Model view](https://github.com/erick5940/sih2026/blob/main/src/app/model/page.tsx): `src/app/model/page.tsx`

### API and persistence

- [Live vehicle polling](https://github.com/erick5940/sih2026/blob/main/src/lib/useLiveVehicles.ts): `src/lib/useLiveVehicles.ts`
- [GPS ingest API](https://github.com/erick5940/sih2026/blob/main/src/app/api/gps/ingest/route.ts): `src/app/api/gps/ingest/route.ts`
- [Incident API](https://github.com/erick5940/sih2026/blob/main/src/app/api/incidents/route.ts): `src/app/api/incidents/route.ts`
- [Reroute API](https://github.com/erick5940/sih2026/blob/main/src/app/api/reroute/route.ts): `src/app/api/reroute/route.ts`
- [Valhalla route API](https://github.com/erick5940/sih2026/blob/main/src/app/api/route-valhalla/route.ts): `src/app/api/route-valhalla/route.ts`
- [OSRM route API](https://github.com/erick5940/sih2026/blob/main/src/app/api/route-osrm/route.ts): `src/app/api/route-osrm/route.ts`
- [Prediction API](https://github.com/erick5940/sih2026/blob/main/src/app/api/predict/route.ts): `src/app/api/predict/route.ts`
- [Live weather API](https://github.com/erick5940/sih2026/blob/main/src/app/api/weather/live/route.ts): `src/app/api/weather/live/route.ts`
- [Supabase client](https://github.com/erick5940/sih2026/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- **Incident records**

### Other components

- **Operations user**

## Connections

- Operations user → Command center: uses
- Command center → GIS map: renders (evidence: `src/app/page.tsx`)
- Command center → Disruption predictor: renders (evidence: `src/app/page.tsx`)
- Command center → Alternate routes: renders (evidence: `src/app/page.tsx`)
- Command center → Logistics priority: renders (evidence: `src/app/page.tsx`)
- Command center → Incident reporting: renders (evidence: `src/app/page.tsx`)
- Command center → Vehicle tracking: renders (evidence: `src/app/page.tsx`)
- Command center → Alert system: renders (evidence: `src/app/page.tsx`)
- Command center → Emergency mode: renders (evidence: `src/app/page.tsx`)
- Command center → Command navigation: renders (evidence: `src/app/page.tsx`)
- Command center → Language switching: renders (evidence: `src/app/page.tsx`)
- Command center → Impact analysis: renders (evidence: `src/app/page.tsx`)
- Command center → Supply gaps: renders (evidence: `src/app/page.tsx`)
- Command center → Live vehicle polling: polls via (evidence: `src/app/page.tsx`)
- Language switching → Translations: uses (evidence: `src/components/LanguageSwitcher.tsx`)
- GIS map → Supply hubs: reads (evidence: `src/components/GISMap.tsx`)
- Impact analysis → Spatial analysis: uses (evidence: `src/components/ImpactPanel.tsx`)
- Spatial analysis → Supply hubs: reads (evidence: `src/lib/spatial.ts`)
- Field reporting → Field mini-map: renders (evidence: `src/app/field/page.tsx`)
- Field reporting → Offline report queue: queues reports (evidence: `src/app/field/page.tsx`)
- Field reporting → Incident API: submits reports
- Offline report queue → Incident API: synchronizes (evidence: `src/lib/offlineDB.ts`)
- Live vehicle polling → GPS ingest API: polls (evidence: `src/lib/useLiveVehicles.ts`)
- Logistics priority → Reroute API: requests reroute (evidence: `src/components/LogisticsPriorityEngine.tsx`)
- Alternate routes → Valhalla route API: requests routes (evidence: `src/components/SmartAlternateRouteEngine.tsx`)
- Incident API → Supabase client: uses (evidence: `src/app/api/incidents/route.ts`)
- Incident API → Incident records: reads and writes (evidence: `src/app/api/incidents/route.ts`)
