# mani-s23/sahya architecture

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

- Interactive diagram: https://gitdiagram.com/mani-s23/sahya
- Repository: https://github.com/mani-s23/sahya

## Overview

Sahya is a community-assistance platform for discovering verified local resources and coordinating emergency, volunteer, complaint, weather, and administrative workflows. Users can locate resources through the directory, map, or assistant; request emergency help; and access community services. The React application is routed and wrapped by shared authentication, location, and notification contexts, while an Express API exposes corresponding service areas backed by MongoDB. The README documents broader capabilities than the sampled implementation shows, so uncertain wiring is omitted rather than inferred.

Main entry points: [`src/App.tsx`](https://github.com/mani-s23/sahya/blob/main/src/App.tsx) (App routing), [`server/src/server.ts`](https://github.com/mani-s23/sahya/blob/main/server/src/server.ts) (Express API server), [`src/services/resourceService.ts`](https://github.com/mani-s23/sahya/blob/main/src/services/resourceService.ts) (Resource services), [`src/pages/ResourceDetailPage.tsx`](https://github.com/mani-s23/sahya/blob/main/src/pages/ResourceDetailPage.tsx) (Resource details)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["App routing<br/>[App.tsx]"]
  node_auth_context["Authentication state<br/>[AuthContext.tsx]"]
  node_location_context["Location state"]
  node_notification_context["Notification state"]
end

subgraph group_discovery["Resource discovery"]
  node_directory["Resource directory<br/>[ResourcesPage.tsx]"]
  node_resource_detail["Resource details"]
  node_map["Interactive map<br/>[InteractiveMap.tsx]"]
  node_resource_service["Resource services<br/>[resourceService.ts]"]
  node_mock_data["Fallback resource data<br/>[mockData.ts]"]
end

subgraph group_assistance["Community assistance"]
  node_assistant_page["Assistant experience<br/>[AssistantPage.tsx]"]
  node_assistant_service["Assistant tools"]
  node_emergency["Emergency requests<br/>[EmergencyPage.tsx]"]
  node_emergency_modal["Emergency modal<br/>[EmergencyModal.tsx]"]
  node_emergency_service["Emergency service"]
  node_complaints["Complaint reporting<br/>[ComplaintsPage.tsx]"]
  node_volunteers["Volunteer network<br/>[VolunteerPage.tsx]"]
  node_weather["Weather advisory<br/>[WeatherPage.tsx]"]
end

subgraph group_operations["Platform operations"]
  node_admin["Admin suite"]
  node_auth_service["Authentication service<br/>[authService.ts]"]
end

subgraph group_backend["API and persistence"]
  node_api_server["Express API server<br/>[server.ts]"]
  node_resource_routes["Resource endpoints<br/>[resourceRoutes.ts]"]
  node_resource_controller["Resource operations"]
  node_emergency_routes["Emergency endpoints<br/>[emergencyRoutes.ts]"]
  node_emergency_controller["Emergency operations"]
  node_complaint_routes["Complaint endpoints<br/>[complaintRoutes.ts]"]
  node_complaint_controller["Complaint operations"]
  node_mongo[("MongoDB<br/>[db.ts]")]
  node_socket_handler["Realtime sockets<br/>[socketHandler.ts]"]
end

node_user(("Community user"))
node_weather_provider["Open-Meteo"]

node_user -->|"uses"| node_app
node_app -->|"provides"| node_auth_context
node_app -->|"provides"| node_location_context
node_app -->|"provides"| node_notification_context
node_app -->|"routes to"| node_directory
node_app -->|"routes to"| node_resource_detail
node_app -->|"routes to"| node_volunteers
node_app -->|"routes to"| node_weather
node_app -->|"opens"| node_emergency_modal
node_user -.->|"requests listings"| node_resource_service
node_resource_detail -->|"loads resource"| node_resource_service
node_resource_detail -->|"shows feedback"| node_notification_context
node_resource_service -.->|"uses fallback"| node_mock_data
node_assistant_service -->|"searches resources"| node_resource_service
node_assistant_service -->|"reads weather fallback"| node_mock_data
node_assistant_page -.->|"submits queries"| node_assistant_service
node_map -.->|"shows locations"| node_resource_detail
node_emergency -.->|"submits request"| node_emergency_service
node_emergency_modal -.->|"submits request"| node_emergency_service
node_emergency_service -->|"matches nearby help"| node_resource_service
node_auth_service -.->|"calls API"| node_api_server
node_api_server -->|"connects"| node_mongo
node_api_server -->|"mounts"| node_resource_routes
node_api_server -->|"mounts"| node_emergency_routes
node_api_server -->|"mounts"| node_complaint_routes
node_api_server -->|"sets up"| node_socket_handler
node_resource_routes -->|"dispatches"| node_resource_controller
node_emergency_routes -->|"dispatches"| node_emergency_controller
node_complaint_routes -->|"dispatches"| node_complaint_controller
node_user -.->|"receives advisories"| node_weather_provider

click node_app "https://github.com/mani-s23/sahya/blob/main/src/App.tsx"
click node_auth_context "https://github.com/mani-s23/sahya/blob/main/src/context/AuthContext.tsx"
click node_location_context "https://github.com/mani-s23/sahya/blob/main/src/context/LocationContext.tsx"
click node_notification_context "https://github.com/mani-s23/sahya/blob/main/src/context/NotificationContext.tsx"
click node_directory "https://github.com/mani-s23/sahya/blob/main/src/pages/ResourcesPage.tsx"
click node_resource_detail "https://github.com/mani-s23/sahya/blob/main/src/pages/ResourceDetailPage.tsx"
click node_map "https://github.com/mani-s23/sahya/blob/main/src/components/map/InteractiveMap.tsx"
click node_resource_service "https://github.com/mani-s23/sahya/blob/main/src/services/resourceService.ts"
click node_mock_data "https://github.com/mani-s23/sahya/blob/main/src/services/mockData.ts"
click node_assistant_page "https://github.com/mani-s23/sahya/blob/main/src/pages/AssistantPage.tsx"
click node_assistant_service "https://github.com/mani-s23/sahya/blob/main/src/services/assistantService.ts"
click node_emergency "https://github.com/mani-s23/sahya/blob/main/src/pages/EmergencyPage.tsx"
click node_emergency_modal "https://github.com/mani-s23/sahya/blob/main/src/components/emergency/EmergencyModal.tsx"
click node_emergency_service "https://github.com/mani-s23/sahya/blob/main/src/services/emergencyService.ts"
click node_complaints "https://github.com/mani-s23/sahya/blob/main/src/pages/ComplaintsPage.tsx"
click node_volunteers "https://github.com/mani-s23/sahya/blob/main/src/pages/VolunteerPage.tsx"
click node_weather "https://github.com/mani-s23/sahya/blob/main/src/pages/WeatherPage.tsx"
click node_admin "https://github.com/mani-s23/sahya/blob/main/src/pages/admin/AdminResourcesPage.tsx"
click node_auth_service "https://github.com/mani-s23/sahya/blob/main/src/services/authService.ts"
click node_api_server "https://github.com/mani-s23/sahya/blob/main/server/src/server.ts"
click node_resource_routes "https://github.com/mani-s23/sahya/blob/main/server/src/routes/resourceRoutes.ts"
click node_resource_controller "https://github.com/mani-s23/sahya/blob/main/server/src/controllers/resourceController.ts"
click node_emergency_routes "https://github.com/mani-s23/sahya/blob/main/server/src/routes/emergencyRoutes.ts"
click node_emergency_controller "https://github.com/mani-s23/sahya/blob/main/server/src/controllers/emergencyController.ts"
click node_complaint_routes "https://github.com/mani-s23/sahya/blob/main/server/src/routes/complaintRoutes.ts"
click node_complaint_controller "https://github.com/mani-s23/sahya/blob/main/server/src/controllers/complaintController.ts"
click node_mongo "https://github.com/mani-s23/sahya/blob/main/server/src/config/db.ts"
click node_socket_handler "https://github.com/mani-s23/sahya/blob/main/server/src/sockets/socketHandler.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_app,node_auth_context,node_location_context,node_notification_context,node_user toneBlue
class node_directory,node_resource_detail,node_map,node_resource_service,node_mock_data toneAmber
class node_assistant_page,node_assistant_service,node_emergency,node_emergency_modal,node_emergency_service,node_complaints,node_volunteers,node_weather toneMint
class node_admin,node_auth_service toneRose
class node_api_server,node_resource_routes,node_resource_controller,node_emergency_routes,node_emergency_controller,node_complaint_routes,node_complaint_controller,node_mongo,node_socket_handler,node_weather_provider toneIndigo
```

## Components

### Web application

- [App routing](https://github.com/mani-s23/sahya/blob/main/src/App.tsx): `src/App.tsx`
- [Authentication state](https://github.com/mani-s23/sahya/blob/main/src/context/AuthContext.tsx): `src/context/AuthContext.tsx`
- [Location state](https://github.com/mani-s23/sahya/blob/main/src/context/LocationContext.tsx): `src/context/LocationContext.tsx`
- [Notification state](https://github.com/mani-s23/sahya/blob/main/src/context/NotificationContext.tsx): `src/context/NotificationContext.tsx`

### Resource discovery

- [Resource directory](https://github.com/mani-s23/sahya/blob/main/src/pages/ResourcesPage.tsx): `src/pages/ResourcesPage.tsx`
- [Resource details](https://github.com/mani-s23/sahya/blob/main/src/pages/ResourceDetailPage.tsx): `src/pages/ResourceDetailPage.tsx`
- [Interactive map](https://github.com/mani-s23/sahya/blob/main/src/components/map/InteractiveMap.tsx): `src/components/map/InteractiveMap.tsx`
- [Resource services](https://github.com/mani-s23/sahya/blob/main/src/services/resourceService.ts): `src/services/resourceService.ts`
- [Fallback resource data](https://github.com/mani-s23/sahya/blob/main/src/services/mockData.ts): `src/services/mockData.ts`

### Community assistance

- [Assistant experience](https://github.com/mani-s23/sahya/blob/main/src/pages/AssistantPage.tsx): `src/pages/AssistantPage.tsx`
- [Assistant tools](https://github.com/mani-s23/sahya/blob/main/src/services/assistantService.ts): `src/services/assistantService.ts`
- [Emergency requests](https://github.com/mani-s23/sahya/blob/main/src/pages/EmergencyPage.tsx): `src/pages/EmergencyPage.tsx`
- [Emergency modal](https://github.com/mani-s23/sahya/blob/main/src/components/emergency/EmergencyModal.tsx): `src/components/emergency/EmergencyModal.tsx`
- [Emergency service](https://github.com/mani-s23/sahya/blob/main/src/services/emergencyService.ts): `src/services/emergencyService.ts`
- [Complaint reporting](https://github.com/mani-s23/sahya/blob/main/src/pages/ComplaintsPage.tsx): `src/pages/ComplaintsPage.tsx`
- [Volunteer network](https://github.com/mani-s23/sahya/blob/main/src/pages/VolunteerPage.tsx): `src/pages/VolunteerPage.tsx`
- [Weather advisory](https://github.com/mani-s23/sahya/blob/main/src/pages/WeatherPage.tsx): `src/pages/WeatherPage.tsx`

### Platform operations

- [Admin suite](https://github.com/mani-s23/sahya/blob/main/src/pages/admin/AdminResourcesPage.tsx): `src/pages/admin/AdminResourcesPage.tsx`
- [Authentication service](https://github.com/mani-s23/sahya/blob/main/src/services/authService.ts): `src/services/authService.ts`

### API and persistence

- [Express API server](https://github.com/mani-s23/sahya/blob/main/server/src/server.ts): `server/src/server.ts`
- [Resource endpoints](https://github.com/mani-s23/sahya/blob/main/server/src/routes/resourceRoutes.ts): `server/src/routes/resourceRoutes.ts`
- [Resource operations](https://github.com/mani-s23/sahya/blob/main/server/src/controllers/resourceController.ts): `server/src/controllers/resourceController.ts`
- [Emergency endpoints](https://github.com/mani-s23/sahya/blob/main/server/src/routes/emergencyRoutes.ts): `server/src/routes/emergencyRoutes.ts`
- [Emergency operations](https://github.com/mani-s23/sahya/blob/main/server/src/controllers/emergencyController.ts): `server/src/controllers/emergencyController.ts`
- [Complaint endpoints](https://github.com/mani-s23/sahya/blob/main/server/src/routes/complaintRoutes.ts): `server/src/routes/complaintRoutes.ts`
- [Complaint operations](https://github.com/mani-s23/sahya/blob/main/server/src/controllers/complaintController.ts): `server/src/controllers/complaintController.ts`
- [MongoDB](https://github.com/mani-s23/sahya/blob/main/server/src/config/db.ts): `server/src/config/db.ts`
- [Realtime sockets](https://github.com/mani-s23/sahya/blob/main/server/src/sockets/socketHandler.ts): `server/src/sockets/socketHandler.ts`

### Other components

- **Community user**
- **Open-Meteo**

## Connections

- Community user → App routing: uses (evidence: `src/App.tsx`)
- App routing → Authentication state: provides (evidence: `src/App.tsx`)
- App routing → Location state: provides (evidence: `src/App.tsx`)
- App routing → Notification state: provides (evidence: `src/App.tsx`)
- App routing → Resource directory: routes to (evidence: `src/App.tsx`)
- App routing → Resource details: routes to (evidence: `src/App.tsx`)
- App routing → Volunteer network: routes to (evidence: `src/App.tsx`)
- App routing → Weather advisory: routes to (evidence: `src/App.tsx`)
- App routing → Emergency modal: opens (evidence: `src/App.tsx`)
- Community user → Resource services: requests listings
- Resource details → Resource services: loads resource (evidence: `src/pages/ResourceDetailPage.tsx`)
- Resource details → Notification state: shows feedback (evidence: `src/pages/ResourceDetailPage.tsx`)
- Resource services → Fallback resource data: uses fallback
- Assistant tools → Resource services: searches resources (evidence: `src/services/assistantService.ts`)
- Assistant tools → Fallback resource data: reads weather fallback (evidence: `src/services/assistantService.ts`)
- Assistant experience → Assistant tools: submits queries
- Interactive map → Resource details: shows locations (evidence: `src/pages/ResourceDetailPage.tsx`)
- Emergency requests → Emergency service: submits request
- Emergency modal → Emergency service: submits request
- Emergency service → Resource services: matches nearby help (evidence: `src/services/emergencyService.ts`)
- Authentication service → Express API server: calls API
- Express API server → MongoDB: connects (evidence: `server/src/server.ts`)
- Express API server → Resource endpoints: mounts (evidence: `server/src/server.ts`)
- Express API server → Emergency endpoints: mounts (evidence: `server/src/server.ts`)
- Express API server → Complaint endpoints: mounts (evidence: `server/src/server.ts`)
- Express API server → Realtime sockets: sets up (evidence: `server/src/server.ts`)
- Resource endpoints → Resource operations: dispatches (evidence: `server/src/routes/resourceRoutes.ts`)
- Emergency endpoints → Emergency operations: dispatches (evidence: `server/src/routes/emergencyRoutes.ts`)
- Complaint endpoints → Complaint operations: dispatches (evidence: `server/src/routes/complaintRoutes.ts`)
- Community user → Open-Meteo: receives advisories
