# jagadesh7575/road-risk-ai architecture

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

- Interactive diagram: https://gitdiagram.com/jagadesh7575/road-risk-ai
- Repository: https://github.com/jagadesh7575/road-risk-ai

## Overview

RoadRisk AI combines citizen risk-aware navigation with emergency-response operations and a supporting live-data backend. Users enter through portal-based interfaces: the application presents maps and navigation or dispatch controls, while server routes and ingestion services expose operational data. Other product areas include authority and fleet portals, analytics, simulation, source health, alerts, and offline regional maps and routing. The supplied excerpts show selected wiring; unsampled client integrations and backend routes are not inferred.

Main entry points: [`src/App.tsx`](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/App.tsx) (Portal application), [`server/ingestion/index.cjs`](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/ingestion/index.cjs) (Provider ingestion), [`server/index.cjs`](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/index.cjs) (HTTP API server), [`server/repositories/index.cjs`](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/repositories/index.cjs) (Persistence repositories)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application and portals"]
  node_app["Portal application<br/>[App.tsx]"]
  node_context["Shared app state<br/>[AppContext.tsx]"]
  node_header["Global header<br/>[Header.tsx]"]
end

subgraph group_navigation["Navigation and safety"]
  node_map["Map experience<br/>[MapContainer.tsx]"]
  node_citizen["Citizen navigation"]
  node_mode["Travel modes<br/>[modeService.ts]"]
  node_offlineui["Offline map manager"]
  node_offlinemaps["Regional map service"]
  node_offlineengine["Offline route engine"]
  node_offlinestore[("Offline data store")]
  node_traffic["Traffic service<br/>[trafficService.ts]"]
  node_alertrules["Alert pipeline<br/>[alertEngine.ts]"]
  node_voicealerts["Voice alerts"]
  node_eventbus["Client event bus<br/>[eventBus.ts]"]
end

subgraph group_operations["Operations and insights"]
  node_emergency["Emergency routing"]
  node_authority["Authority portal"]
  node_fleet["Fleet portal<br/>[FleetPortal.tsx]"]
  node_analytics["Risk analytics<br/>[AnalyticsView.tsx]"]
  node_simulator["Event simulator"]
  node_sources["Data source health"]
end

subgraph group_backend["Data backend"]
  node_server["HTTP API server<br/>[index.cjs]"]
  node_ingestion["Provider ingestion<br/>[index.cjs]"]
  node_normalization["Data normalization<br/>[index.cjs]"]
  node_repositories["Persistence repositories<br/>[index.cjs]"]
  node_database[("SQLite database<br/>[database.cjs]")]
  node_workers["Ingestion workers<br/>[index.cjs]"]
  node_serverbus["Server event bus<br/>[index.cjs]"]
end

node_user(("RoadRisk user"))
node_externaldata{{"External data providers"}}

node_user -->|"uses"| node_app
node_app -->|"provides state"| node_context
node_app -->|"renders"| node_header
node_app -->|"renders"| node_map
node_app -->|"renders"| node_citizen
node_app -->|"renders"| node_emergency
node_app -->|"routes to"| node_authority
node_app -->|"routes to"| node_fleet
node_app -->|"routes to"| node_analytics
node_app -->|"routes to"| node_simulator
node_app -->|"routes to"| node_sources
node_offlineui -->|"manages"| node_offlinemaps
node_offlineui -->|"reads status"| node_offlinestore
node_offlineengine -->|"loads graph"| node_offlinestore
node_offlineengine -->|"uses geometry"| node_externaldata
node_alertrules -->|"dispatches"| node_voicealerts
node_alertrules -->|"publishes events"| node_eventbus
node_server -->|"queries"| node_database
node_server -->|"uses"| node_ingestion
node_server -->|"uses"| node_repositories
node_server -->|"uses"| node_serverbus
node_ingestion -->|"normalizes with"| node_normalization
node_ingestion -->|"persists through"| node_repositories
node_ingestion -->|"publishes to"| node_serverbus
node_ingestion -->|"fetches from"| node_externaldata
node_repositories -->|"queries"| node_database
node_workers -->|"runs"| node_ingestion

click node_app "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/App.tsx"
click node_context "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/context/AppContext.tsx"
click node_header "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/layout/Header.tsx"
click node_map "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/map/MapContainer.tsx"
click node_citizen "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/navigation/CitizenNavigationControl.tsx"
click node_mode "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/modeService.ts"
click node_offlineui "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/navigation/OfflineMapManagerModal.tsx"
click node_offlinemaps "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/offlineMapService.ts"
click node_offlineengine "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/offlineRoutingEngine.ts"
click node_offlinestore "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/offlineStorageService.ts"
click node_traffic "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/trafficService.ts"
click node_alertrules "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/alertEngine.ts"
click node_voicealerts "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/voiceAlertService.ts"
click node_eventbus "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/eventBus.ts"
click node_emergency "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/operator/EmergencyRouteControl.tsx"
click node_authority "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/authority/AuthorityPortal.tsx"
click node_fleet "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/fleet/FleetPortal.tsx"
click node_analytics "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/analytics/AnalyticsView.tsx"
click node_simulator "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/simulation/EventSimulatorView.tsx"
click node_sources "https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/settings/DataSourcesView.tsx"
click node_server "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/index.cjs"
click node_ingestion "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/ingestion/index.cjs"
click node_normalization "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/normalization/index.cjs"
click node_repositories "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/repositories/index.cjs"
click node_database "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/database.cjs"
click node_workers "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/workers/index.cjs"
click node_serverbus "https://github.com/jagadesh7575/road-risk-ai/blob/main/server/eventBus/index.cjs"

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_app,node_context,node_header,node_user toneBlue
class node_map,node_citizen,node_mode,node_offlineui,node_offlinemaps,node_offlineengine,node_offlinestore,node_traffic,node_alertrules,node_voicealerts,node_eventbus toneAmber
class node_emergency,node_authority,node_fleet,node_analytics,node_simulator,node_sources toneMint
class node_server,node_ingestion,node_normalization,node_repositories,node_database,node_workers,node_serverbus toneRose
class node_externaldata toneIndigo
```

## Components

### Application and portals

- [Portal application](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/App.tsx): `src/App.tsx`
- [Shared app state](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/context/AppContext.tsx): `src/context/AppContext.tsx`
- [Global header](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/layout/Header.tsx): `src/components/layout/Header.tsx`

### Navigation and safety

- [Map experience](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/map/MapContainer.tsx): `src/components/map/MapContainer.tsx`
- [Citizen navigation](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/navigation/CitizenNavigationControl.tsx): `src/components/navigation/CitizenNavigationControl.tsx`
- [Travel modes](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/modeService.ts): `src/services/modeService.ts`
- [Offline map manager](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/navigation/OfflineMapManagerModal.tsx): `src/components/navigation/OfflineMapManagerModal.tsx`
- [Regional map service](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/offlineMapService.ts): `src/services/offlineMapService.ts`
- [Offline route engine](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/offlineRoutingEngine.ts): `src/services/offlineRoutingEngine.ts`
- [Offline data store](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/offlineStorageService.ts): `src/services/offlineStorageService.ts`
- [Traffic service](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/trafficService.ts): `src/services/trafficService.ts`
- [Alert pipeline](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/alertEngine.ts): `src/services/alertEngine.ts`
- [Voice alerts](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/voiceAlertService.ts): `src/services/voiceAlertService.ts`
- [Client event bus](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/services/eventBus.ts): `src/services/eventBus.ts`

### Operations and insights

- [Emergency routing](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/operator/EmergencyRouteControl.tsx): `src/components/operator/EmergencyRouteControl.tsx`
- [Authority portal](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/authority/AuthorityPortal.tsx): `src/components/authority/AuthorityPortal.tsx`
- [Fleet portal](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/fleet/FleetPortal.tsx): `src/components/fleet/FleetPortal.tsx`
- [Risk analytics](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/analytics/AnalyticsView.tsx): `src/components/analytics/AnalyticsView.tsx`
- [Event simulator](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/simulation/EventSimulatorView.tsx): `src/components/simulation/EventSimulatorView.tsx`
- [Data source health](https://github.com/jagadesh7575/road-risk-ai/blob/main/src/components/settings/DataSourcesView.tsx): `src/components/settings/DataSourcesView.tsx`

### Data backend

- [HTTP API server](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/index.cjs): `server/index.cjs`
- [Provider ingestion](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/ingestion/index.cjs): `server/ingestion/index.cjs`
- [Data normalization](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/normalization/index.cjs): `server/normalization/index.cjs`
- [Persistence repositories](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/repositories/index.cjs): `server/repositories/index.cjs`
- [SQLite database](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/database.cjs): `server/database.cjs`
- [Ingestion workers](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/workers/index.cjs): `server/workers/index.cjs`
- [Server event bus](https://github.com/jagadesh7575/road-risk-ai/blob/main/server/eventBus/index.cjs): `server/eventBus/index.cjs`

### Other components

- **RoadRisk user**
- **External data providers**

## Connections

- RoadRisk user → Portal application: uses (evidence: `src/App.tsx`)
- Portal application → Shared app state: provides state (evidence: `src/App.tsx`)
- Portal application → Global header: renders (evidence: `src/App.tsx`)
- Portal application → Map experience: renders (evidence: `src/App.tsx`)
- Portal application → Citizen navigation: renders (evidence: `src/App.tsx`)
- Portal application → Emergency routing: renders (evidence: `src/App.tsx`)
- Portal application → Authority portal: routes to (evidence: `src/App.tsx`)
- Portal application → Fleet portal: routes to (evidence: `src/App.tsx`)
- Portal application → Risk analytics: routes to (evidence: `src/App.tsx`)
- Portal application → Event simulator: routes to (evidence: `src/App.tsx`)
- Portal application → Data source health: routes to (evidence: `src/App.tsx`)
- Offline map manager → Regional map service: manages (evidence: `src/components/navigation/OfflineMapManagerModal.tsx`)
- Offline map manager → Offline data store: reads status (evidence: `src/components/navigation/OfflineMapManagerModal.tsx`)
- Offline route engine → Offline data store: loads graph (evidence: `src/services/offlineRoutingEngine.ts`)
- Offline route engine → External data providers: uses geometry (evidence: `src/services/offlineRoutingEngine.ts`)
- Alert pipeline → Voice alerts: dispatches (evidence: `src/services/alertEngine.ts`)
- Alert pipeline → Client event bus: publishes events (evidence: `src/services/alertEngine.ts`)
- HTTP API server → SQLite database: queries (evidence: `server/index.cjs`)
- HTTP API server → Provider ingestion: uses (evidence: `server/index.cjs`)
- HTTP API server → Persistence repositories: uses (evidence: `server/index.cjs`)
- HTTP API server → Server event bus: uses (evidence: `server/index.cjs`)
- Provider ingestion → Data normalization: normalizes with (evidence: `server/ingestion/index.cjs`)
- Provider ingestion → Persistence repositories: persists through (evidence: `server/ingestion/index.cjs`)
- Provider ingestion → Server event bus: publishes to (evidence: `server/ingestion/index.cjs`)
- Provider ingestion → External data providers: fetches from (evidence: `server/ingestion/index.cjs`)
- Persistence repositories → SQLite database: queries (evidence: `server/repositories/index.cjs`)
- Ingestion workers → Provider ingestion: runs (evidence: `server/workers/index.cjs`)
