# rajpride/himrakshak architecture

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

- Interactive diagram: https://gitdiagram.com/rajpride/himrakshak
- Repository: https://github.com/rajpride/himrakshak

## Overview

Himrakshak is a disaster-safety app for Himalayan road travel. Drivers open a live hazard map, review rain, landslide, traffic and news signals, submit reports or request SOS help, then plan and follow a safer route with hazard and turn alerts. The graph also preserves authentication, satellite viewing, saved places and offline/PWA support. Edges are limited to relationships shown in excerpts, the source index, or README; unsampled feature wiring is not inferred.

Main entry points: [`app/page.tsx`](https://github.com/rajpride/himrakshak/blob/main/app/page.tsx) (Live risk page), [`components/RiskView.tsx`](https://github.com/rajpride/himrakshak/blob/main/components/RiskView.tsx) (Risk dashboard), [`components/RiskMap.tsx`](https://github.com/rajpride/himrakshak/blob/main/components/RiskMap.tsx) (Risk map), [`lib/routes.ts`](https://github.com/rajpride/himrakshak/blob/main/lib/routes.ts) (Route options)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Driver experience"]
  node_home["Live risk page<br/>[page.tsx]"]
  node_riskview["Risk dashboard<br/>[RiskView.tsx]"]
  node_reportform["Report form<br/>[ReportForm.tsx]"]
  node_sos["SOS help<br/>[SosPanel.tsx]"]
  node_tripui["Trip controls<br/>[TripPlanner.tsx]"]
  node_saved["Saved places<br/>[saved-places.ts]"]
  node_voice["Voice commands<br/>[voice.ts]"]
  node_rescue["Rescue dashboard"]
end

subgraph group_hazards["Hazard intelligence"]
  node_riskmap["Risk map<br/>[RiskMap.tsx]"]
  node_rain["Rain forecast<br/>[weather.ts]"]
  node_riskmodel["Risk scoring<br/>[risk.ts]"]
  node_ai["AI landslide risk<br/>[ai-risk.ts]"]
  node_traffic["Traffic status<br/>[traffic.ts]"]
  node_news["Landslide news<br/>[slide-news.ts]"]
  node_satelliteapi["Satellite endpoint<br/>[route.ts]"]
  node_satellite["Satellite data<br/>[satellite.ts]"]
end

subgraph group_journeys["Trip planning"]
  node_trip["Trip state and alerts<br/>[trip.ts]"]
  node_routesapi["Route endpoint<br/>[route.ts]"]
  node_routes["Route options<br/>[routes.ts]"]
  node_valhalla["Road routing<br/>[valhalla.ts]"]
  node_detour["Closure detours<br/>[detour.ts]"]
  node_rerouteapi["Reroute endpoint<br/>[route.ts]"]
end

subgraph group_services["Reports and identity"]
  node_reports["Driver reports<br/>[reports.ts]"]
  node_soslogic["SOS handling<br/>[sos.ts]"]
  node_authui["Sign-in screen<br/>[AuthScreen.tsx]"]
  node_auth["Auth state<br/>[auth.ts]"]
  node_supabase["Supabase client<br/>[supabase.ts]"]
end

subgraph group_platform["App platform"]
  node_serviceworker["Offline caching<br/>[ServiceWorker.tsx]"]
  node_sw["PWA cache<br/>[sw.js]"]
end

node_driver(("Driver"))
node_weatherapi[("Open-Meteo")]
node_newsfeed[("Google News feeds")]
node_valhallaservice[("Valhalla service")]
node_supabaseservice[("Supabase service")]

node_driver -->|"opens"| node_home
node_home -->|"loads forecast"| node_rain
node_home -->|"loads headlines"| node_news
node_home -->|"loads traffic"| node_traffic
node_home -->|"loads risk"| node_ai
node_home -->|"renders"| node_riskview
node_rain -->|"fetches data"| node_weatherapi
node_riskview -->|"renders"| node_riskmap
node_riskview -->|"opens"| node_reportform
node_riskview -->|"uses trip state"| node_trip
node_riskview -->|"parses commands"| node_voice
node_riskview -->|"renders view"| node_satellite
node_riskmap -->|"scores hazards"| node_riskmodel
node_riskmap -->|"reads reports"| node_reports
node_riskmap -->|"uses trip data"| node_trip
node_riskmap -->|"uses headlines"| node_news
node_reportform -->|"submits reports"| node_reports
node_reports -->|"reads and writes"| node_supabase
node_reports -->|"stores reports"| node_supabaseservice
node_sos -->|"invokes"| node_soslogic
node_tripui -.->|"controls trip"| node_trip
node_trip -.->|"requests route options"| node_routesapi
node_routesapi -->|"calls"| node_routes
node_routes -->|"requests roads"| node_valhalla
node_routes -->|"checks route rain"| node_rain
node_routes -->|"scores route risk"| node_riskmodel
node_valhalla -->|"requests routes"| node_valhallaservice
node_rerouteapi -->|"calls"| node_detour
node_detour -->|"requests detour"| node_valhalla
node_news -->|"fetches feeds"| node_newsfeed
node_authui -->|"uses auth"| node_auth
node_authui -->|"authenticates"| node_supabase
node_auth -->|"checks session"| node_supabase
node_satelliteapi -->|"loads data"| node_satellite
node_serviceworker -->|"registers"| node_sw

click node_home "https://github.com/rajpride/himrakshak/blob/main/app/page.tsx"
click node_riskview "https://github.com/rajpride/himrakshak/blob/main/components/RiskView.tsx"
click node_riskmap "https://github.com/rajpride/himrakshak/blob/main/components/RiskMap.tsx"
click node_rain "https://github.com/rajpride/himrakshak/blob/main/lib/weather.ts"
click node_riskmodel "https://github.com/rajpride/himrakshak/blob/main/lib/risk.ts"
click node_ai "https://github.com/rajpride/himrakshak/blob/main/lib/ai-risk.ts"
click node_traffic "https://github.com/rajpride/himrakshak/blob/main/lib/traffic.ts"
click node_news "https://github.com/rajpride/himrakshak/blob/main/lib/slide-news.ts"
click node_reports "https://github.com/rajpride/himrakshak/blob/main/lib/reports.ts"
click node_reportform "https://github.com/rajpride/himrakshak/blob/main/components/ReportForm.tsx"
click node_sos "https://github.com/rajpride/himrakshak/blob/main/components/SosPanel.tsx"
click node_soslogic "https://github.com/rajpride/himrakshak/blob/main/lib/sos.ts"
click node_tripui "https://github.com/rajpride/himrakshak/blob/main/components/TripPlanner.tsx"
click node_trip "https://github.com/rajpride/himrakshak/blob/main/lib/trip.ts"
click node_routesapi "https://github.com/rajpride/himrakshak/blob/main/app/api/routes/route.ts"
click node_routes "https://github.com/rajpride/himrakshak/blob/main/lib/routes.ts"
click node_valhalla "https://github.com/rajpride/himrakshak/blob/main/lib/valhalla.ts"
click node_detour "https://github.com/rajpride/himrakshak/blob/main/lib/detour.ts"
click node_rerouteapi "https://github.com/rajpride/himrakshak/blob/main/app/api/reroute/route.ts"
click node_authui "https://github.com/rajpride/himrakshak/blob/main/components/AuthScreen.tsx"
click node_auth "https://github.com/rajpride/himrakshak/blob/main/lib/auth.ts"
click node_supabase "https://github.com/rajpride/himrakshak/blob/main/lib/supabase.ts"
click node_satelliteapi "https://github.com/rajpride/himrakshak/blob/main/app/api/satellite/route.ts"
click node_satellite "https://github.com/rajpride/himrakshak/blob/main/lib/satellite.ts"
click node_saved "https://github.com/rajpride/himrakshak/blob/main/lib/saved-places.ts"
click node_voice "https://github.com/rajpride/himrakshak/blob/main/lib/voice.ts"
click node_serviceworker "https://github.com/rajpride/himrakshak/blob/main/components/ServiceWorker.tsx"
click node_sw "https://github.com/rajpride/himrakshak/blob/main/public/sw.js"
click node_rescue "https://github.com/rajpride/himrakshak/blob/main/components/RescueDashboard.tsx"

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_home,node_riskview,node_reportform,node_sos,node_tripui,node_saved,node_voice,node_rescue toneBlue
class node_riskmap,node_rain,node_riskmodel,node_ai,node_traffic,node_news,node_satelliteapi,node_satellite,node_weatherapi,node_newsfeed,node_valhallaservice,node_supabaseservice toneAmber
class node_trip,node_routesapi,node_routes,node_valhalla,node_detour,node_rerouteapi toneMint
class node_reports,node_soslogic,node_authui,node_auth,node_supabase toneRose
class node_serviceworker,node_sw,node_driver toneIndigo
```

## Components

### Driver experience

- [Live risk page](https://github.com/rajpride/himrakshak/blob/main/app/page.tsx): `app/page.tsx`
- [Risk dashboard](https://github.com/rajpride/himrakshak/blob/main/components/RiskView.tsx): `components/RiskView.tsx`
- [Report form](https://github.com/rajpride/himrakshak/blob/main/components/ReportForm.tsx): `components/ReportForm.tsx`
- [SOS help](https://github.com/rajpride/himrakshak/blob/main/components/SosPanel.tsx): `components/SosPanel.tsx`
- [Trip controls](https://github.com/rajpride/himrakshak/blob/main/components/TripPlanner.tsx): `components/TripPlanner.tsx`
- [Saved places](https://github.com/rajpride/himrakshak/blob/main/lib/saved-places.ts): `lib/saved-places.ts`
- [Voice commands](https://github.com/rajpride/himrakshak/blob/main/lib/voice.ts): `lib/voice.ts`
- [Rescue dashboard](https://github.com/rajpride/himrakshak/blob/main/components/RescueDashboard.tsx): `components/RescueDashboard.tsx`

### Hazard intelligence

- [Risk map](https://github.com/rajpride/himrakshak/blob/main/components/RiskMap.tsx): `components/RiskMap.tsx`
- [Rain forecast](https://github.com/rajpride/himrakshak/blob/main/lib/weather.ts): `lib/weather.ts`
- [Risk scoring](https://github.com/rajpride/himrakshak/blob/main/lib/risk.ts): `lib/risk.ts`
- [AI landslide risk](https://github.com/rajpride/himrakshak/blob/main/lib/ai-risk.ts): `lib/ai-risk.ts`
- [Traffic status](https://github.com/rajpride/himrakshak/blob/main/lib/traffic.ts): `lib/traffic.ts`
- [Landslide news](https://github.com/rajpride/himrakshak/blob/main/lib/slide-news.ts): `lib/slide-news.ts`
- [Satellite endpoint](https://github.com/rajpride/himrakshak/blob/main/app/api/satellite/route.ts): `app/api/satellite/route.ts`
- [Satellite data](https://github.com/rajpride/himrakshak/blob/main/lib/satellite.ts): `lib/satellite.ts`

### Trip planning

- [Trip state and alerts](https://github.com/rajpride/himrakshak/blob/main/lib/trip.ts): `lib/trip.ts`
- [Route endpoint](https://github.com/rajpride/himrakshak/blob/main/app/api/routes/route.ts): `app/api/routes/route.ts`
- [Route options](https://github.com/rajpride/himrakshak/blob/main/lib/routes.ts): `lib/routes.ts`
- [Road routing](https://github.com/rajpride/himrakshak/blob/main/lib/valhalla.ts): `lib/valhalla.ts`
- [Closure detours](https://github.com/rajpride/himrakshak/blob/main/lib/detour.ts): `lib/detour.ts`
- [Reroute endpoint](https://github.com/rajpride/himrakshak/blob/main/app/api/reroute/route.ts): `app/api/reroute/route.ts`

### Reports and identity

- [Driver reports](https://github.com/rajpride/himrakshak/blob/main/lib/reports.ts): `lib/reports.ts`
- [SOS handling](https://github.com/rajpride/himrakshak/blob/main/lib/sos.ts): `lib/sos.ts`
- [Sign-in screen](https://github.com/rajpride/himrakshak/blob/main/components/AuthScreen.tsx): `components/AuthScreen.tsx`
- [Auth state](https://github.com/rajpride/himrakshak/blob/main/lib/auth.ts): `lib/auth.ts`
- [Supabase client](https://github.com/rajpride/himrakshak/blob/main/lib/supabase.ts): `lib/supabase.ts`

### App platform

- [Offline caching](https://github.com/rajpride/himrakshak/blob/main/components/ServiceWorker.tsx): `components/ServiceWorker.tsx`
- [PWA cache](https://github.com/rajpride/himrakshak/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Driver**
- **Open-Meteo**
- **Google News feeds**
- **Valhalla service**
- **Supabase service**

## Connections

- Driver → Live risk page: opens (evidence: `app/page.tsx`)
- Live risk page → Rain forecast: loads forecast (evidence: `app/page.tsx`)
- Live risk page → Landslide news: loads headlines (evidence: `app/page.tsx`)
- Live risk page → Traffic status: loads traffic (evidence: `app/page.tsx`)
- Live risk page → AI landslide risk: loads risk (evidence: `app/page.tsx`)
- Live risk page → Risk dashboard: renders (evidence: `app/page.tsx`)
- Rain forecast → Open-Meteo: fetches data
- Risk dashboard → Risk map: renders (evidence: `components/RiskView.tsx`)
- Risk dashboard → Report form: opens (evidence: `components/RiskView.tsx`)
- Risk dashboard → Trip state and alerts: uses trip state (evidence: `components/RiskView.tsx`)
- Risk dashboard → Voice commands: parses commands (evidence: `components/RiskView.tsx`)
- Risk dashboard → Satellite data: renders view (evidence: `components/RiskView.tsx`)
- Risk map → Risk scoring: scores hazards (evidence: `components/RiskMap.tsx`)
- Risk map → Driver reports: reads reports (evidence: `components/RiskMap.tsx`)
- Risk map → Trip state and alerts: uses trip data (evidence: `components/RiskMap.tsx`)
- Risk map → Landslide news: uses headlines (evidence: `components/RiskMap.tsx`)
- Report form → Driver reports: submits reports (evidence: `components/ReportForm.tsx`)
- Driver reports → Supabase client: reads and writes (evidence: `lib/reports.ts`)
- Driver reports → Supabase service: stores reports (evidence: `lib/reports.ts`)
- SOS help → SOS handling: invokes (evidence: `components/SosPanel.tsx`)
- Trip controls → Trip state and alerts: controls trip
- Trip state and alerts → Route endpoint: requests route options
- Route endpoint → Route options: calls (evidence: `app/api/routes/route.ts`)
- Route options → Road routing: requests roads (evidence: `lib/routes.ts`)
- Route options → Rain forecast: checks route rain (evidence: `lib/routes.ts`)
- Route options → Risk scoring: scores route risk (evidence: `lib/routes.ts`)
- Road routing → Valhalla service: requests routes (evidence: `lib/valhalla.ts`)
- Reroute endpoint → Closure detours: calls (evidence: `app/api/reroute/route.ts`)
- Closure detours → Road routing: requests detour (evidence: `lib/detour.ts`)
- Landslide news → Google News feeds: fetches feeds (evidence: `lib/slide-news.ts`)
- Sign-in screen → Auth state: uses auth (evidence: `components/AuthScreen.tsx`)
- Sign-in screen → Supabase client: authenticates (evidence: `components/AuthScreen.tsx`)
- Auth state → Supabase client: checks session (evidence: `lib/auth.ts`)
- Satellite endpoint → Satellite data: loads data (evidence: `app/api/satellite/route.ts`)
- Offline caching → PWA cache: registers (evidence: `components/ServiceWorker.tsx`)
