# kumarjesh/on-road-emergency-support-system architecture

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

- Interactive diagram: https://gitdiagram.com/kumarjesh/on-road-emergency-support-system
- Repository: https://github.com/kumarjesh/on-road-emergency-support-system

## Overview

ResQRoad is a driver-facing roadside emergency app paired with a dispatcher console. Drivers choose a roadside or medical service, share incident and vehicle details, and create a request; dispatchers review and assign it, while the driver can follow progress. The client also supports sensor-triggered crash alerts, location selection and tracking, emergency contacts, and WhatsApp sharing. The README documents mapping and communication capabilities whose implementation was not sampled; those links are shown only where documented. Backend detail is limited to the sampled routes and store.

Main entry points: [`client/src/App.jsx`](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/App.jsx) (App Shell), [`client/src/context/EmergencyContext.jsx`](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/context/EmergencyContext.jsx) (Emergency State), [`server/server.js`](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/server.js) (API & Realtime Server), [`client/src/hooks/useCrashDetection.js`](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/hooks/useCrashDetection.js) (Crash Detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Driver App"]
  node_app["App Shell<br/>[App.jsx]"]
  node_context["Emergency State"]
  node_services["Service Requests<br/>[ServiceGrid.jsx]"]
  node_location["Location Picker"]
  node_tracking["Live Tracking<br/>[LiveTracking.jsx]"]
end

subgraph group_safety["Safety &amp; Sharing"]
  node_contacts["Emergency Contacts"]
  node_whatsapp["WhatsApp SOS"]
  node_crashhook["Crash Detection"]
  node_crashalert["Crash Alert"]
  node_crashwidget["Crash Sensor UI"]
  node_checklist["Safety Checklist"]
  node_beacon["Night Beacon"]
  node_vehicle["Vehicle Profile"]
end

subgraph group_dispatch["Dispatch Operations"]
  node_dispatcher["Dispatcher Console"]
end

subgraph group_backend["Emergency Backend"]
  node_server["API &amp; Realtime Server<br/>[server.js]"]
  node_store[("Emergency Store<br/>[db.js]")]
  node_jsondata["Emergency Records<br/>[emergencies.json]"]
end

node_driver(("Driver"))
node_geoservice["IP Geolocation"]
node_maps["Mapping Services"]
node_messaging["WhatsApp &amp; SMS"]

node_driver -->|"uses"| node_app
node_app -->|"provides state"| node_context
node_app -->|"renders"| node_services
node_services -->|"requests service"| node_context
node_app -->|"opens"| node_location
node_location -->|"sets location"| node_context
node_context -->|"requests fallback"| node_geoservice
node_context -.->|"uses geocoding"| node_maps
node_app -->|"renders"| node_tracking
node_context -->|"sends requests"| node_server
node_server -->|"reads and updates"| node_store
node_store -->|"persists records"| node_jsondata
node_server -->|"serves ticket data"| node_dispatcher
node_dispatcher -.->|"manages tickets"| node_server
node_context -.->|"receives live updates"| node_dispatcher
node_app -->|"renders"| node_crashwidget
node_crashwidget -.->|"uses telemetry"| node_crashhook
node_crashhook -.->|"raises alert"| node_crashalert
node_crashhook -.->|"dispatches incident"| node_context
node_app -->|"opens"| node_contacts
node_contacts -->|"manages contacts"| node_context
node_app -->|"opens"| node_whatsapp
node_whatsapp -.->|"prepares dispatch"| node_messaging
node_app -->|"renders"| node_checklist
node_app -->|"renders"| node_beacon
node_app -->|"renders"| node_vehicle

click node_app "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/App.jsx"
click node_context "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/context/EmergencyContext.jsx"
click node_services "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/ServiceGrid.jsx"
click node_location "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/LocationPickerModal.jsx"
click node_tracking "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/LiveTracking.jsx"
click node_contacts "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/EmergencyContactsModal.jsx"
click node_whatsapp "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/WhatsAppWizardModal.jsx"
click node_crashhook "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/hooks/useCrashDetection.js"
click node_crashalert "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/CrashAlertModal.jsx"
click node_crashwidget "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/CrashSensorWidget.jsx"
click node_checklist "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/SafetyChecklistModal.jsx"
click node_beacon "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/NightStrobeModal.jsx"
click node_vehicle "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/VehicleProfileModal.jsx"
click node_dispatcher "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/DispatcherDashboard.jsx"
click node_server "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/server.js"
click node_store "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/db.js"
click node_jsondata "https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/data/emergencies.json"

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_services,node_location,node_tracking toneBlue
class node_contacts,node_whatsapp,node_crashhook,node_crashalert,node_crashwidget,node_checklist,node_beacon,node_vehicle toneAmber
class node_dispatcher toneMint
class node_server,node_store,node_jsondata toneRose
class node_driver,node_geoservice,node_maps,node_messaging toneIndigo
```

## Components

### Driver App

- [App Shell](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Emergency State](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/context/EmergencyContext.jsx): `client/src/context/EmergencyContext.jsx`
- [Service Requests](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/ServiceGrid.jsx): `client/src/components/ServiceGrid.jsx`
- [Location Picker](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/LocationPickerModal.jsx): `client/src/components/LocationPickerModal.jsx`
- [Live Tracking](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/LiveTracking.jsx): `client/src/components/LiveTracking.jsx`

### Safety & Sharing

- [Emergency Contacts](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/EmergencyContactsModal.jsx): `client/src/components/EmergencyContactsModal.jsx`
- [WhatsApp SOS](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/WhatsAppWizardModal.jsx): `client/src/components/WhatsAppWizardModal.jsx`
- [Crash Detection](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/hooks/useCrashDetection.js): `client/src/hooks/useCrashDetection.js`
- [Crash Alert](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/CrashAlertModal.jsx): `client/src/components/CrashAlertModal.jsx`
- [Crash Sensor UI](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/CrashSensorWidget.jsx): `client/src/components/CrashSensorWidget.jsx`
- [Safety Checklist](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/SafetyChecklistModal.jsx): `client/src/components/SafetyChecklistModal.jsx`
- [Night Beacon](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/NightStrobeModal.jsx): `client/src/components/NightStrobeModal.jsx`
- [Vehicle Profile](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/VehicleProfileModal.jsx): `client/src/components/VehicleProfileModal.jsx`

### Dispatch Operations

- [Dispatcher Console](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/client/src/components/DispatcherDashboard.jsx): `client/src/components/DispatcherDashboard.jsx`

### Emergency Backend

- [API & Realtime Server](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/server.js): `server/server.js`
- [Emergency Store](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/db.js): `server/db.js`
- [Emergency Records](https://github.com/kumarjesh/on-road-emergency-support-system/blob/main/server/data/emergencies.json): `server/data/emergencies.json`

### Other components

- **Driver**
- **IP Geolocation**
- **Mapping Services**
- **WhatsApp & SMS**

## Connections

- Driver → App Shell: uses (evidence: `README.md`)
- App Shell → Emergency State: provides state (evidence: `client/src/App.jsx`)
- App Shell → Service Requests: renders (evidence: `client/src/App.jsx`)
- Service Requests → Emergency State: requests service (evidence: `client/src/components/ServiceGrid.jsx`)
- App Shell → Location Picker: opens (evidence: `client/src/App.jsx`)
- Location Picker → Emergency State: sets location (evidence: `client/src/components/LocationPickerModal.jsx`)
- Emergency State → IP Geolocation: requests fallback (evidence: `client/src/context/EmergencyContext.jsx`)
- Emergency State → Mapping Services: uses geocoding (evidence: `README.md`)
- App Shell → Live Tracking: renders (evidence: `client/src/App.jsx`)
- Emergency State → API & Realtime Server: sends requests (evidence: `client/src/context/EmergencyContext.jsx`)
- API & Realtime Server → Emergency Store: reads and updates (evidence: `server/server.js`)
- Emergency Store → Emergency Records: persists records (evidence: `server/db.js`)
- API & Realtime Server → Dispatcher Console: serves ticket data (evidence: `server/server.js`)
- Dispatcher Console → API & Realtime Server: manages tickets (evidence: `README.md`)
- Emergency State → Dispatcher Console: receives live updates (evidence: `README.md`)
- App Shell → Crash Sensor UI: renders (evidence: `client/src/App.jsx`)
- Crash Sensor UI → Crash Detection: uses telemetry (evidence: `README.md`)
- Crash Detection → Crash Alert: raises alert (evidence: `README.md`)
- Crash Detection → Emergency State: dispatches incident (evidence: `README.md`)
- App Shell → Emergency Contacts: opens (evidence: `client/src/App.jsx`)
- Emergency Contacts → Emergency State: manages contacts (evidence: `client/src/components/EmergencyContactsModal.jsx`)
- App Shell → WhatsApp SOS: opens (evidence: `client/src/App.jsx`)
- WhatsApp SOS → WhatsApp & SMS: prepares dispatch (evidence: `README.md`)
- App Shell → Safety Checklist: renders (evidence: `client/src/App.jsx`)
- App Shell → Night Beacon: renders (evidence: `client/src/App.jsx`)
- App Shell → Vehicle Profile: renders (evidence: `client/src/App.jsx`)
