# ankitkumar810/shaastra architecture

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

- Interactive diagram: https://gitdiagram.com/ankitkumar810/shaastra
- Repository: https://github.com/ankitkumar810/shaastra

## Overview

SHAASTRA is a disaster-management platform prototype centered on shelter discovery, safety registration and family reconnection, with district coordination. The README describes the current UI as a low-bandwidth demo with local interactions and explicitly says several integrations are not yet part of the product; sampled API code nevertheless shows corresponding staged server capabilities. The graph keeps the demo journeys distinct from those API branches. UI-to-API wiring is not established by the sampled excerpts, so those links are omitted.

Main entry points: [`lib/prisma.ts`](https://github.com/ankitkumar810/shaastra/blob/main/lib/prisma.ts) (Operational data), [`lib/supabase/server.ts`](https://github.com/ankitkumar810/shaastra/blob/main/lib/supabase/server.ts) (Supabase auth), [`lib/services/auth.ts`](https://github.com/ankitkumar810/shaastra/blob/main/lib/services/auth.ts) (Profile and roles), [`app/api/v1/shelters/route.ts`](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/shelters/route.ts) (Shelter API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_citizen_home["Citizen dashboard<br/>[page.tsx]"]
  node_shelter_discovery["Shelter discovery<br/>[page.tsx]"]
  node_safety_checkin["Safety check-in<br/>[page.tsx]"]
  node_missing_person_ui["Family registry<br/>[page.tsx]"]
  node_hazard_ui["Hazard reporting<br/>[page.tsx]"]
  node_authority_dashboard["District dashboard<br/>[page.tsx]"]
end

subgraph group_response["Disaster response"]
  node_shelter_api["Shelter API<br/>[route.ts]"]
  node_shelter_detail_api["Shelter operations<br/>[route.ts]"]
  node_reports_api["Incident reports<br/>[route.ts]"]
  node_missing_api["Missing persons<br/>[route.ts]"]
  node_consent_api["Location consent<br/>[route.ts]"]
  node_predictions_api["Resource predictions<br/>[route.ts]"]
  node_prisma[("Operational data<br/>[prisma.ts]")]
end

subgraph group_identity["Identity and access"]
  node_auth_callback["Login callback<br/>[route.ts]"]
  node_auth_service["Profile and roles<br/>[auth.ts]"]
  node_supabase["Supabase auth<br/>[server.ts]"]
end

subgraph group_integrations["Staged integrations"]
  node_assistant_api["AI assistant API<br/>[route.ts]"]
  node_ai_service["Grounded responses<br/>[ai.ts]"]
  node_translation_api["Translation API<br/>[route.ts]"]
  node_translation_service["Bhashini service<br/>[bhashini.ts]"]
  node_sms_webhook["SMS commands<br/>[route.ts]"]
  node_offline_sync["Offline sync<br/>[route.ts]"]
end

node_citizen(("Citizen"))
node_authority(("Authority"))

node_citizen -->|"opens"| node_citizen_home
node_citizen -->|"finds shelters"| node_shelter_discovery
node_citizen -->|"checks in"| node_safety_checkin
node_citizen -->|"seeks family"| node_missing_person_ui
node_citizen -->|"reports hazard"| node_hazard_ui
node_authority -->|"coordinates"| node_authority_dashboard
node_shelter_api -->|"queries and writes"| node_prisma
node_shelter_detail_api -->|"reads and updates"| node_prisma
node_shelter_detail_api -->|"checks profile"| node_auth_service
node_shelter_api -->|"checks profile"| node_auth_service
node_shelter_api -->|"authenticates"| node_supabase
node_shelter_detail_api -->|"authenticates"| node_supabase
node_reports_api -->|"reads and creates"| node_prisma
node_reports_api -->|"checks profile"| node_auth_service
node_reports_api -->|"authenticates"| node_supabase
node_missing_api -->|"reads and creates"| node_prisma
node_missing_api -->|"checks profile"| node_auth_service
node_missing_api -->|"authenticates"| node_supabase
node_consent_api -->|"stores consent"| node_prisma
node_consent_api -->|"ensures profile"| node_auth_service
node_consent_api -->|"authenticates"| node_supabase
node_predictions_api -->|"checks profile"| node_auth_service
node_predictions_api -->|"authenticates"| node_supabase
node_predictions_api -->|"evaluates shelters"| node_prisma
node_auth_callback -->|"exchanges session"| node_supabase
node_auth_callback -->|"syncs profile"| node_auth_service
node_assistant_api -->|"generates response"| node_ai_service
node_translation_api -->|"translates text"| node_translation_service
node_sms_webhook -->|"reads shelter status"| node_prisma
node_offline_sync -->|"syncs records"| node_prisma
node_offline_sync -->|"authenticates"| node_supabase

click node_citizen_home "https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/page.tsx"
click node_shelter_discovery "https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/shelters/page.tsx"
click node_safety_checkin "https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/safety-checkin/page.tsx"
click node_missing_person_ui "https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/missing-persons/page.tsx"
click node_hazard_ui "https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/report-hazard/page.tsx"
click node_authority_dashboard "https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/authority/page.tsx"
click node_shelter_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/shelters/route.ts"
click node_shelter_detail_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/shelters/%5Bid%5D/route.ts"
click node_reports_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/reports/route.ts"
click node_missing_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/missing-persons/route.ts"
click node_consent_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/location/consent/route.ts"
click node_predictions_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/predictions/route.ts"
click node_prisma "https://github.com/ankitkumar810/shaastra/blob/main/lib/prisma.ts"
click node_auth_callback "https://github.com/ankitkumar810/shaastra/blob/main/app/auth/callback/route.ts"
click node_auth_service "https://github.com/ankitkumar810/shaastra/blob/main/lib/services/auth.ts"
click node_supabase "https://github.com/ankitkumar810/shaastra/blob/main/lib/supabase/server.ts"
click node_assistant_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/assistant/route.ts"
click node_ai_service "https://github.com/ankitkumar810/shaastra/blob/main/lib/services/ai.ts"
click node_translation_api "https://github.com/ankitkumar810/shaastra/blob/main/app/api/bhashini/translate/route.ts"
click node_translation_service "https://github.com/ankitkumar810/shaastra/blob/main/lib/services/bhashini.ts"
click node_sms_webhook "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/sms/webhook/route.ts"
click node_offline_sync "https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/sync/route.ts"

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_citizen_home,node_shelter_discovery,node_safety_checkin,node_missing_person_ui,node_hazard_ui,node_authority_dashboard toneBlue
class node_shelter_api,node_shelter_detail_api,node_reports_api,node_missing_api,node_consent_api,node_predictions_api,node_prisma toneAmber
class node_auth_callback,node_auth_service,node_supabase toneMint
class node_assistant_api,node_ai_service,node_translation_api,node_translation_service,node_sms_webhook,node_offline_sync toneRose
class node_citizen,node_authority toneIndigo
```

## Components

### User experience

- [Citizen dashboard](https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/page.tsx): `app/dashboard/citizen/page.tsx`
- [Shelter discovery](https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/shelters/page.tsx): `app/dashboard/citizen/shelters/page.tsx`
- [Safety check-in](https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/safety-checkin/page.tsx): `app/dashboard/citizen/safety-checkin/page.tsx`
- [Family registry](https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/missing-persons/page.tsx): `app/dashboard/citizen/missing-persons/page.tsx`
- [Hazard reporting](https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/citizen/report-hazard/page.tsx): `app/dashboard/citizen/report-hazard/page.tsx`
- [District dashboard](https://github.com/ankitkumar810/shaastra/blob/main/app/dashboard/authority/page.tsx): `app/dashboard/authority/page.tsx`

### Disaster response

- [Shelter API](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/shelters/route.ts): `app/api/v1/shelters/route.ts`
- [Shelter operations](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/shelters/%5Bid%5D/route.ts): `app/api/v1/shelters/[id]/route.ts`
- [Incident reports](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/reports/route.ts): `app/api/v1/reports/route.ts`
- [Missing persons](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/missing-persons/route.ts): `app/api/v1/missing-persons/route.ts`
- [Location consent](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/location/consent/route.ts): `app/api/v1/location/consent/route.ts`
- [Resource predictions](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/predictions/route.ts): `app/api/v1/predictions/route.ts`
- [Operational data](https://github.com/ankitkumar810/shaastra/blob/main/lib/prisma.ts): `lib/prisma.ts`

### Identity and access

- [Login callback](https://github.com/ankitkumar810/shaastra/blob/main/app/auth/callback/route.ts): `app/auth/callback/route.ts`
- [Profile and roles](https://github.com/ankitkumar810/shaastra/blob/main/lib/services/auth.ts): `lib/services/auth.ts`
- [Supabase auth](https://github.com/ankitkumar810/shaastra/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`

### Staged integrations

- [AI assistant API](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/assistant/route.ts): `app/api/v1/assistant/route.ts`
- [Grounded responses](https://github.com/ankitkumar810/shaastra/blob/main/lib/services/ai.ts): `lib/services/ai.ts`
- [Translation API](https://github.com/ankitkumar810/shaastra/blob/main/app/api/bhashini/translate/route.ts): `app/api/bhashini/translate/route.ts`
- [Bhashini service](https://github.com/ankitkumar810/shaastra/blob/main/lib/services/bhashini.ts): `lib/services/bhashini.ts`
- [SMS commands](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/sms/webhook/route.ts): `app/api/v1/sms/webhook/route.ts`
- [Offline sync](https://github.com/ankitkumar810/shaastra/blob/main/app/api/v1/sync/route.ts): `app/api/v1/sync/route.ts`

### Other components

- **Citizen**
- **Authority**

## Connections

- Citizen → Citizen dashboard: opens
- Citizen → Shelter discovery: finds shelters
- Citizen → Safety check-in: checks in
- Citizen → Family registry: seeks family
- Citizen → Hazard reporting: reports hazard
- Authority → District dashboard: coordinates
- Shelter API → Operational data: queries and writes
- Shelter operations → Operational data: reads and updates
- Shelter operations → Profile and roles: checks profile
- Shelter API → Profile and roles: checks profile
- Shelter API → Supabase auth: authenticates
- Shelter operations → Supabase auth: authenticates
- Incident reports → Operational data: reads and creates
- Incident reports → Profile and roles: checks profile
- Incident reports → Supabase auth: authenticates
- Missing persons → Operational data: reads and creates
- Missing persons → Profile and roles: checks profile
- Missing persons → Supabase auth: authenticates
- Location consent → Operational data: stores consent
- Location consent → Profile and roles: ensures profile
- Location consent → Supabase auth: authenticates
- Resource predictions → Profile and roles: checks profile
- Resource predictions → Supabase auth: authenticates
- Resource predictions → Operational data: evaluates shelters
- Login callback → Supabase auth: exchanges session
- Login callback → Profile and roles: syncs profile
- AI assistant API → Grounded responses: generates response
- Translation API → Bhashini service: translates text
- SMS commands → Operational data: reads shelter status
- Offline sync → Operational data: syncs records
- Offline sync → Supabase auth: authenticates
