# dhruvplaz-web/surakshitpath architecture

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

- Interactive diagram: https://gitdiagram.com/dhruvplaz-web/surakshitpath
- Repository: https://github.com/dhruvplaz-web/surakshitpath

## Overview

SurakshitPath is a Pune-focused nocturnal mobility and civic-safety app. A commuter signs in or enters as a guest, selects origin, destination and travel profile, compares safe/balanced/fast routes, then navigates with safety guidance and can share a route or request emergency help. Separate role-based experiences support municipal hazard management and volunteer response, alongside shelters, ride monitoring, weather risk and hazard reporting. Edges are limited to relationships shown in excerpts or README; unsampled integrations are included as capability nodes only where their subsystem is documented.

Main entry points: [`src/App.tsx`](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/App.tsx) (Application shell), [`src/engine/graphRouter.ts`](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/graphRouter.ts) (Route alternatives), [`src/components/Admin/CivicAdminDashboard.tsx`](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Admin/CivicAdminDashboard.tsx) (Civic admin), [`src/context/AuthContext.tsx`](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/context/AuthContext.tsx) (Session context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_app["Application shell<br/>[App.tsx]"]
  node_location["Location search"]
  node_map["Map cockpit<br/>[MapCockpit.tsx]"]
  node_geocoding["Geocoding"]
end

subgraph group_routing["Safe navigation"]
  node_routes["Route alternatives<br/>[graphRouter.ts]"]
  node_road["Road geometry"]
  node_safety_score["Safety scoring<br/>[safetyScorer.ts]"]
  node_ml_nav["Navigation models"]
  node_corridors["Pune corridor graph"]
  node_curved["Curved route data"]
  node_routes_ui["Route comparison"]
  node_explain["Safety explanation"]
  node_navigation["Navigation guidance"]
end

subgraph group_safety["Safety network"]
  node_shelters["Safe havens<br/>[safeHavens.ts]"]
  node_shelter_engine["Shelter matching"]
  node_ride["Ride shield"]
  node_weather["Weather risk"]
  node_emergency["SOS response"]
  node_transit["Transit integration"]
  node_closure["Live closures"]
  node_shelter_live["Live shelters"]
end

subgraph group_civic["Civic response"]
  node_admin["Civic admin"]
  node_volunteer["Volunteer cockpit"]
  node_hazards["Hazard reporting"]
  node_ai["AI risk analysis<br/>[aiRiskService.ts]"]
  node_civic_data["Civic records<br/>[civicAdminData.ts]"]
  node_api["Python API<br/>[main.py]"]
end

subgraph group_identity["Identity and support"]
  node_guardian["Trusted guardians"]
  node_auth_context["Session context<br/>[AuthContext.tsx]"]
  node_auth["Authentication"]
  node_firebase[("Firebase<br/>[firebase.ts]")]
end

node_commuter(("Commuter"))

node_commuter -->|"uses"| node_app
node_app -->|"reads session"| node_auth_context
node_auth_context -->|"authenticates"| node_auth
node_auth -->|"uses auth"| node_firebase
node_app -->|"renders"| node_location
node_location -->|"searches"| node_geocoding
node_app -->|"fetches route geometry"| node_road
node_road -->|"predicts ETA"| node_ml_nav
node_app -.->|"calculates alternatives"| node_routes
node_routes -->|"scores edges"| node_safety_score
node_routes -->|"predicts ETA"| node_ml_nav
node_routes -->|"reads graph"| node_corridors
node_routes -->|"reads corridors"| node_curved
node_app -->|"presents routes"| node_routes_ui
node_routes_ui -.->|"explains safety"| node_explain
node_app -.->|"renders map"| node_map
node_map -->|"loads shelters"| node_shelter_live
node_commuter -.->|"follows guidance"| node_navigation
node_app -->|"renders admin"| node_admin
node_app -->|"supports responder role"| node_volunteer
node_app -->|"opens reporting"| node_hazards
node_hazards -->|"analyzes risk"| node_ai
node_admin -->|"reads records"| node_civic_data
node_commuter -->|"finds havens"| node_shelters
node_shelter_engine -.->|"matches nearby"| node_shelters
node_commuter -->|"uses ride shield"| node_ride
node_commuter -->|"checks conditions"| node_weather
node_commuter -->|"requests SOS"| node_emergency
node_guardian -.->|"configures contacts"| node_auth_context
node_admin -.->|"may use API"| node_api
node_routes -.->|"uses closures"| node_closure
node_routes -.->|"uses transit"| node_transit

click node_app "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/App.tsx"
click node_location "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Sidebar/LocationSearchBox.tsx"
click node_map "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Map/MapCockpit.tsx"
click node_admin "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Admin/CivicAdminDashboard.tsx"
click node_volunteer "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Volunteer/VolunteerCockpit.tsx"
click node_hazards "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Community/ReportHazardModal.tsx"
click node_routes "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/graphRouter.ts"
click node_road "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/roadCurvatureService.ts"
click node_safety_score "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/safetyScorer.ts"
click node_ml_nav "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/mlNavigationEngine.ts"
click node_corridors "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/puneCorridorGraph.ts"
click node_curved "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/puneCurvedRoutesData.ts"
click node_routes_ui "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Sidebar/RouteComparisonCard.tsx"
click node_explain "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Sidebar/TreeShapWaterfall.tsx"
click node_navigation "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Navigation/NavigationCockpitHud.tsx"
click node_shelters "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/safeHavens.ts"
click node_shelter_engine "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/corridorShelterEngine.ts"
click node_ride "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/rideShieldService.ts"
click node_weather "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Commuter/NocturnalWeatherCard.tsx"
click node_emergency "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Emergency/EmergencySosModal.tsx"
click node_guardian "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Guardian/TrustedGuardianModal.tsx"
click node_auth_context "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/context/AuthContext.tsx"
click node_auth "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/firebaseAuthService.ts"
click node_firebase "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/config/firebase.ts"
click node_geocoding "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/geocodingService.ts"
click node_ai "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/aiRiskService.ts"
click node_civic_data "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/civicAdminData.ts"
click node_transit "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/liveTransitService.ts"
click node_closure "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/liveClosureService.ts"
click node_shelter_live "https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/liveShelterService.ts"
click node_api "https://github.com/dhruvplaz-web/surakshitpath/blob/main/api/main.py"

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_location,node_map,node_geocoding toneBlue
class node_routes,node_road,node_safety_score,node_ml_nav,node_corridors,node_curved,node_routes_ui,node_explain,node_navigation toneAmber
class node_shelters,node_shelter_engine,node_ride,node_weather,node_emergency,node_transit,node_closure,node_shelter_live toneMint
class node_admin,node_volunteer,node_hazards,node_ai,node_civic_data,node_api toneRose
class node_guardian,node_auth_context,node_auth,node_firebase,node_commuter toneIndigo
```

## Components

### App experience

- [Application shell](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/App.tsx): `src/App.tsx`
- [Location search](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Sidebar/LocationSearchBox.tsx): `src/components/Sidebar/LocationSearchBox.tsx`
- [Map cockpit](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Map/MapCockpit.tsx): `src/components/Map/MapCockpit.tsx`
- [Geocoding](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/geocodingService.ts): `src/services/geocodingService.ts`

### Safe navigation

- [Route alternatives](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/graphRouter.ts): `src/engine/graphRouter.ts`
- [Road geometry](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/roadCurvatureService.ts): `src/services/roadCurvatureService.ts`
- [Safety scoring](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/safetyScorer.ts): `src/engine/safetyScorer.ts`
- [Navigation models](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/engine/mlNavigationEngine.ts): `src/engine/mlNavigationEngine.ts`
- [Pune corridor graph](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/puneCorridorGraph.ts): `src/data/puneCorridorGraph.ts`
- [Curved route data](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/puneCurvedRoutesData.ts): `src/data/puneCurvedRoutesData.ts`
- [Route comparison](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Sidebar/RouteComparisonCard.tsx): `src/components/Sidebar/RouteComparisonCard.tsx`
- [Safety explanation](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Sidebar/TreeShapWaterfall.tsx): `src/components/Sidebar/TreeShapWaterfall.tsx`
- [Navigation guidance](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Navigation/NavigationCockpitHud.tsx): `src/components/Navigation/NavigationCockpitHud.tsx`

### Safety network

- [Safe havens](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/safeHavens.ts): `src/data/safeHavens.ts`
- [Shelter matching](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/corridorShelterEngine.ts): `src/services/corridorShelterEngine.ts`
- [Ride shield](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/rideShieldService.ts): `src/services/rideShieldService.ts`
- [Weather risk](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Commuter/NocturnalWeatherCard.tsx): `src/components/Commuter/NocturnalWeatherCard.tsx`
- [SOS response](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Emergency/EmergencySosModal.tsx): `src/components/Emergency/EmergencySosModal.tsx`
- [Transit integration](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/liveTransitService.ts): `src/services/liveTransitService.ts`
- [Live closures](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/liveClosureService.ts): `src/services/liveClosureService.ts`
- [Live shelters](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/liveShelterService.ts): `src/services/liveShelterService.ts`

### Civic response

- [Civic admin](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Admin/CivicAdminDashboard.tsx): `src/components/Admin/CivicAdminDashboard.tsx`
- [Volunteer cockpit](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Volunteer/VolunteerCockpit.tsx): `src/components/Volunteer/VolunteerCockpit.tsx`
- [Hazard reporting](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Community/ReportHazardModal.tsx): `src/components/Community/ReportHazardModal.tsx`
- [AI risk analysis](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/aiRiskService.ts): `src/services/aiRiskService.ts`
- [Civic records](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/data/civicAdminData.ts): `src/data/civicAdminData.ts`
- [Python API](https://github.com/dhruvplaz-web/surakshitpath/blob/main/api/main.py): `api/main.py`

### Identity and support

- [Trusted guardians](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/components/Guardian/TrustedGuardianModal.tsx): `src/components/Guardian/TrustedGuardianModal.tsx`
- [Session context](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Authentication](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/services/firebaseAuthService.ts): `src/services/firebaseAuthService.ts`
- [Firebase](https://github.com/dhruvplaz-web/surakshitpath/blob/main/src/config/firebase.ts): `src/config/firebase.ts`

### Other components

- **Commuter**

## Connections

- Commuter → Application shell: uses
- Application shell → Session context: reads session (evidence: `src/App.tsx`)
- Session context → Authentication: authenticates (evidence: `src/context/AuthContext.tsx`)
- Authentication → Firebase: uses auth (evidence: `src/services/firebaseAuthService.ts`)
- Application shell → Location search: renders (evidence: `src/App.tsx`)
- Location search → Geocoding: searches (evidence: `src/components/Sidebar/LocationSearchBox.tsx`)
- Application shell → Road geometry: fetches route geometry (evidence: `src/App.tsx`)
- Road geometry → Navigation models: predicts ETA (evidence: `src/services/roadCurvatureService.ts`)
- Application shell → Route alternatives: calculates alternatives (evidence: `src/App.tsx`)
- Route alternatives → Safety scoring: scores edges (evidence: `src/engine/graphRouter.ts`)
- Route alternatives → Navigation models: predicts ETA (evidence: `src/engine/graphRouter.ts`)
- Route alternatives → Pune corridor graph: reads graph (evidence: `src/engine/graphRouter.ts`)
- Route alternatives → Curved route data: reads corridors (evidence: `src/engine/graphRouter.ts`)
- Application shell → Route comparison: presents routes (evidence: `src/App.tsx`)
- Route comparison → Safety explanation: explains safety
- Application shell → Map cockpit: renders map (evidence: `src/App.tsx`)
- Map cockpit → Live shelters: loads shelters (evidence: `src/components/Map/MapCockpit.tsx`)
- Commuter → Navigation guidance: follows guidance
- Application shell → Civic admin: renders admin (evidence: `src/App.tsx`)
- Application shell → Volunteer cockpit: supports responder role (evidence: `src/App.tsx`)
- Application shell → Hazard reporting: opens reporting (evidence: `src/App.tsx`)
- Hazard reporting → AI risk analysis: analyzes risk (evidence: `src/components/Community/ReportHazardModal.tsx`)
- Civic admin → Civic records: reads records (evidence: `src/components/Admin/CivicAdminDashboard.tsx`)
- Commuter → Safe havens: finds havens
- Shelter matching → Safe havens: matches nearby
- Commuter → Ride shield: uses ride shield
- Commuter → Weather risk: checks conditions
- Commuter → SOS response: requests SOS
- Trusted guardians → Session context: configures contacts
- Civic admin → Python API: may use API
- Route alternatives → Live closures: uses closures
- Route alternatives → Transit integration: uses transit
