# dakshin10/roadsaftey_harrington_iitm architecture

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

- Interactive diagram: https://gitdiagram.com/dakshin10/roadsaftey_harrington_iitm
- Repository: https://github.com/dakshin10/roadsaftey_harrington_iitm

## Overview

RoadSOS combines a rider mobile app, a Flask emergency backend, and a command-center dashboard. The documented rider workflow is sensor-driven crash detection, a cancellable countdown, and an alert carrying location into incident tracking and response; the dashboard monitors incidents, dispatches resources, and reviews history and response analytics. The supplied mobile tree exposes only platform launch scaffolding, so its detection and SMS implementation cannot be mapped. Backend excerpts establish incident, dispatch, helper, and Firestore behavior; other documented capabilities are retained with cautious, unverified links.

Main entry points: [`frontend_dashboard/src/App.js`](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/App.js) (Dashboard shell), [`backend/app.py`](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/app.py) (HTTP API), [`backend/services/firestore_service.py`](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/firestore_service.py) (Firestore adapter), [`backend/services/dispatch_service.py`](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/dispatch_service.py) (Resource dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Rider app"]
  node_mobileapp["Mobile client"]
  node_detection["Crash detection"]
  node_countdown["Safety countdown"]
  node_sms["SMS alerts"]
end

subgraph group_backend["Emergency backend"]
  node_api["HTTP API<br/>[app.py]"]
  node_incidents["Incident routes<br/>[incident_routes.py]"]
  node_severity["Severity scoring"]
  node_demo["Demo incidents<br/>[demo_routes.py]"]
  node_incidentlogic["Incident lifecycle"]
  node_dispatchroutes["Dispatch routes<br/>[dispatch_routes.py]"]
  node_dispatch["Resource dispatch"]
  node_helperroutes["Helper routes<br/>[helper_routes.py]"]
  node_helpers["Volunteer network<br/>[helper_service.py]"]
  node_realtime["Socket events<br/>[extensions.py]"]
end

subgraph group_dashboard["Command dashboard"]
  node_dashboardapp["Dashboard shell<br/>[App.js]"]
  node_liveview["Live alerts"]
  node_mapview["Map display<br/>[MapView.js]"]
  node_detail["Incident detail<br/>[IncidentDetail.jsx]"]
  node_history["Alert history"]
  node_nearby["Nearby units"]
  node_analytics["Statistics"]
  node_settings["Settings<br/>[SettingsScreen.jsx]"]
  node_api_client["Dashboard API<br/>[api.js]"]
  node_socket_client["Dashboard sockets<br/>[socket.js]"]
end

subgraph group_persistence["Incident storage"]
  node_firestore["Firestore adapter"]
  node_database[("Firestore")]
end

node_rider(("Rider"))
node_operator(("Command staff"))

node_rider -.->|"uses"| node_mobileapp
node_mobileapp -.->|"monitors sensors"| node_detection
node_detection -.->|"starts"| node_countdown
node_countdown -.->|"escalates"| node_sms
node_countdown -.->|"sends alert"| node_api
node_mobileapp -.->|"updates location"| node_api
node_api -->|"registers routes"| node_incidents
node_api -->|"handles dispatch event"| node_dispatch
node_api -->|"handles helper event"| node_helpers
node_incidents -->|"delegates"| node_incidentlogic
node_incidents -->|"updates location"| node_firestore
node_incidentlogic -->|"reads and writes"| node_firestore
node_dispatchroutes -->|"delegates"| node_dispatch
node_dispatch -->|"reads incident"| node_incidentlogic
node_dispatch -->|"records dispatch"| node_firestore
node_helperroutes -->|"delegates"| node_helpers
node_helperroutes -->|"emits acceptance"| node_realtime
node_helpers -->|"reads and writes"| node_firestore
node_firestore -->|"accesses"| node_database
node_demo -->|"computes score"| node_severity
node_demo -->|"stores incident"| node_firestore
node_demo -->|"emits demo event"| node_realtime
node_operator -.->|"monitors"| node_dashboardapp
node_dashboardapp -->|"fetches incidents"| node_api_client
node_dashboardapp -->|"subscribes"| node_socket_client
node_dashboardapp -->|"renders"| node_liveview
node_dashboardapp -->|"renders"| node_history
node_dashboardapp -->|"renders"| node_nearby
node_dashboardapp -->|"renders"| node_analytics
node_dashboardapp -->|"renders"| node_settings
node_liveview -->|"renders"| node_mapview
node_liveview -->|"renders"| node_detail
node_api_client -.->|"requests data"| node_api
node_socket_client -.->|"receives events"| node_realtime
node_history -.->|"loads records"| node_api_client
node_analytics -.->|"loads metrics"| node_api_client

click node_mobileapp "https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app"
click node_detection "https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app"
click node_countdown "https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app"
click node_sms "https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app"
click node_api "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/app.py"
click node_incidents "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/incident_routes.py"
click node_severity "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/severity_service.py"
click node_demo "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/demo_routes.py"
click node_incidentlogic "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/incident_service.py"
click node_dispatchroutes "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/dispatch_routes.py"
click node_dispatch "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/dispatch_service.py"
click node_helperroutes "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/helper_routes.py"
click node_helpers "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/helper_service.py"
click node_realtime "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/extensions.py"
click node_firestore "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/firestore_service.py"
click node_dashboardapp "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/App.js"
click node_liveview "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/LiveAlertsScreen.jsx"
click node_mapview "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/MapView.js"
click node_detail "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/IncidentDetail.jsx"
click node_history "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/AlertHistoryScreen.jsx"
click node_nearby "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/NearbyUnitsScreen.jsx"
click node_analytics "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/StatisticsScreen.jsx"
click node_settings "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/SettingsScreen.jsx"
click node_api_client "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/services/api.js"
click node_socket_client "https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/services/socket.js"

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_mobileapp,node_detection,node_countdown,node_sms toneBlue
class node_api,node_incidents,node_severity,node_demo,node_incidentlogic,node_dispatchroutes,node_dispatch,node_helperroutes,node_helpers,node_realtime toneAmber
class node_dashboardapp,node_liveview,node_mapview,node_detail,node_history,node_nearby,node_analytics,node_settings,node_api_client,node_socket_client toneMint
class node_firestore,node_database toneRose
class node_rider,node_operator toneIndigo
```

## Components

### Rider app

- [Mobile client](https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app): `app`
- [Crash detection](https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app): `app`
- [Safety countdown](https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app): `app`
- [SMS alerts](https://github.com/dakshin10/roadsaftey_harrington_iitm/tree/main/app): `app`

### Emergency backend

- [HTTP API](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/app.py): `backend/app.py`
- [Incident routes](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/incident_routes.py): `backend/routes/incident_routes.py`
- [Severity scoring](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/severity_service.py): `backend/services/severity_service.py`
- [Demo incidents](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/demo_routes.py): `backend/routes/demo_routes.py`
- [Incident lifecycle](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/incident_service.py): `backend/services/incident_service.py`
- [Dispatch routes](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/dispatch_routes.py): `backend/routes/dispatch_routes.py`
- [Resource dispatch](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/dispatch_service.py): `backend/services/dispatch_service.py`
- [Helper routes](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/routes/helper_routes.py): `backend/routes/helper_routes.py`
- [Volunteer network](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/helper_service.py): `backend/services/helper_service.py`
- [Socket events](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/extensions.py): `backend/extensions.py`

### Command dashboard

- [Dashboard shell](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/App.js): `frontend_dashboard/src/App.js`
- [Live alerts](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/LiveAlertsScreen.jsx): `frontend_dashboard/src/components/screens/LiveAlertsScreen.jsx`
- [Map display](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/MapView.js): `frontend_dashboard/src/components/MapView.js`
- [Incident detail](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/IncidentDetail.jsx): `frontend_dashboard/src/components/IncidentDetail.jsx`
- [Alert history](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/AlertHistoryScreen.jsx): `frontend_dashboard/src/components/screens/AlertHistoryScreen.jsx`
- [Nearby units](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/NearbyUnitsScreen.jsx): `frontend_dashboard/src/components/screens/NearbyUnitsScreen.jsx`
- [Statistics](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/StatisticsScreen.jsx): `frontend_dashboard/src/components/screens/StatisticsScreen.jsx`
- [Settings](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/components/screens/SettingsScreen.jsx): `frontend_dashboard/src/components/screens/SettingsScreen.jsx`
- [Dashboard API](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/services/api.js): `frontend_dashboard/src/services/api.js`
- [Dashboard sockets](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/frontend_dashboard/src/services/socket.js): `frontend_dashboard/src/services/socket.js`

### Incident storage

- [Firestore adapter](https://github.com/dakshin10/roadsaftey_harrington_iitm/blob/main/backend/services/firestore_service.py): `backend/services/firestore_service.py`
- **Firestore**

### Other components

- **Rider**
- **Command staff**

## Connections

- Rider → Mobile client: uses
- Mobile client → Crash detection: monitors sensors
- Crash detection → Safety countdown: starts
- Safety countdown → SMS alerts: escalates
- Safety countdown → HTTP API: sends alert
- Mobile client → HTTP API: updates location
- HTTP API → Incident routes: registers routes (evidence: `backend/app.py`)
- HTTP API → Resource dispatch: handles dispatch event (evidence: `backend/app.py`)
- HTTP API → Volunteer network: handles helper event (evidence: `backend/app.py`)
- Incident routes → Incident lifecycle: delegates (evidence: `backend/routes/incident_routes.py`)
- Incident routes → Firestore adapter: updates location (evidence: `backend/routes/incident_routes.py`)
- Incident lifecycle → Firestore adapter: reads and writes (evidence: `backend/services/incident_service.py`)
- Dispatch routes → Resource dispatch: delegates (evidence: `backend/routes/dispatch_routes.py`)
- Resource dispatch → Incident lifecycle: reads incident (evidence: `backend/services/dispatch_service.py`)
- Resource dispatch → Firestore adapter: records dispatch (evidence: `backend/services/dispatch_service.py`)
- Helper routes → Volunteer network: delegates (evidence: `backend/routes/helper_routes.py`)
- Helper routes → Socket events: emits acceptance (evidence: `backend/routes/helper_routes.py`)
- Volunteer network → Firestore adapter: reads and writes (evidence: `backend/services/helper_service.py`)
- Firestore adapter → Firestore: accesses (evidence: `backend/services/firestore_service.py`)
- Demo incidents → Severity scoring: computes score (evidence: `backend/routes/demo_routes.py`)
- Demo incidents → Firestore adapter: stores incident (evidence: `backend/routes/demo_routes.py`)
- Demo incidents → Socket events: emits demo event (evidence: `backend/routes/demo_routes.py`)
- Command staff → Dashboard shell: monitors
- Dashboard shell → Dashboard API: fetches incidents (evidence: `frontend_dashboard/src/App.js`)
- Dashboard shell → Dashboard sockets: subscribes (evidence: `frontend_dashboard/src/App.js`)
- Dashboard shell → Live alerts: renders (evidence: `frontend_dashboard/src/App.js`)
- Dashboard shell → Alert history: renders (evidence: `frontend_dashboard/src/App.js`)
- Dashboard shell → Nearby units: renders (evidence: `frontend_dashboard/src/App.js`)
- Dashboard shell → Statistics: renders (evidence: `frontend_dashboard/src/App.js`)
- Dashboard shell → Settings: renders (evidence: `frontend_dashboard/src/App.js`)
- Live alerts → Map display: renders (evidence: `frontend_dashboard/src/components/screens/LiveAlertsScreen.jsx`)
- Live alerts → Incident detail: renders (evidence: `frontend_dashboard/src/components/screens/LiveAlertsScreen.jsx`)
- Dashboard API → HTTP API: requests data
- Dashboard sockets → Socket events: receives events
- Alert history → Dashboard API: loads records
- Statistics → Dashboard API: loads metrics
