# kruddha981/astrothunder-sahakara architecture

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

- Interactive diagram: https://gitdiagram.com/kruddha981/astrothunder-sahakara
- Repository: https://github.com/kruddha981/astrothunder-sahakara

## Overview

Sahakara is a food-rescue platform connecting surplus donors with shelters and, as food ages, animal-rescue and compost recipients. The primary browser workflow posts a donation, applies the safety-and-distance ladder to find an eligible recipient, and tracks pickup and delivery; Supabase is the documented core data/auth/realtime service. The admin portal manages live operations and impact reporting. An optional Express backend provides a separate legacy API and SMTP OTP dispatch. Some frontend wiring and backend service details are unsampled, so the graph omits uncertain links.

Main entry points: [`frontend/script.js`](https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/script.js) (Rescue SPA), [`backend/src/server.js`](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/server.js) (Express API), [`backend/src/donationService.js`](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/donationService.js) (Donation lifecycle), [`frontend/admin/admin.js`](https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/admin/admin.js) (Admin portal)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_public["Rescue experience"]
  node_web["Rescue SPA<br/>[script.js]"]
  node_ladder["Safety ladder<br/>[matching.js]"]
  node_config["Client config<br/>[config.js]"]
end

subgraph group_operations["Admin operations"]
  node_adminui["Admin portal<br/>[admin.js]"]
end

subgraph group_backend["Optional API"]
  node_api["Express API<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_donationroutes["Donation routes<br/>[donations.js]"]
  node_miscroutes["Shelter and stats routes<br/>[misc.js]"]
  node_lifecycle["Donation lifecycle<br/>[donationService.js]"]
  node_backendmatch["Zone matching<br/>[matching.js]"]
  node_email["OTP email<br/>[emailService.js]"]
  node_dbclient["Backend DB client<br/>[db.js]"]
end

subgraph group_data["Platform data"]
  node_schema[("Supabase schema<br/>[schema.sql]")]
  node_supabase["Supabase service"]
end

node_donor(("Donor"))
node_shelter(("Shelter / recipient"))
node_driver(("Volunteer driver"))
node_admin(("Administrator"))
node_smtp["SMTP provider"]
node_maps["Map and routing services"]

node_donor -->|"posts surplus"| node_web
node_web -->|"gets client config"| node_config
node_web -->|"evaluates rescue tier"| node_ladder
node_web -->|"reads and writes donations"| node_supabase
node_supabase -->|"streams live updates"| node_web
node_shelter -->|"uses rescue portal"| node_web
node_driver -->|"updates rescue status"| node_web
node_admin -->|"manages operations"| node_adminui
node_adminui -->|"manages records and logs"| node_supabase
node_adminui -->|"renders maps and routes"| node_maps
node_web -->|"renders recipient map"| node_maps
node_donor -.->|"posts via optional API"| node_api
node_api -->|"dispatches auth"| node_authroutes
node_api -->|"dispatches donations"| node_donationroutes
node_api -->|"dispatches support routes"| node_miscroutes
node_donationroutes -->|"runs lifecycle actions"| node_lifecycle
node_miscroutes -->|"requests shelter and stats"| node_lifecycle
node_authroutes -->|"reads and writes auth data"| node_dbclient
node_authroutes -->|"sends OTP"| node_email
node_email -.->|"sends email"| node_smtp
node_lifecycle -->|"selects shelter and driver"| node_backendmatch
node_lifecycle -->|"reads and updates records"| node_dbclient
node_dbclient -->|"queries database"| node_supabase
node_schema -->|"defines tables and policies"| node_supabase

click node_web "https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/script.js"
click node_ladder "https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/matching.js"
click node_config "https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/config.js"
click node_adminui "https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/admin/admin.js"
click node_api "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/server.js"
click node_authroutes "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/routes/auth.js"
click node_donationroutes "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/routes/donations.js"
click node_miscroutes "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/routes/misc.js"
click node_lifecycle "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/donationService.js"
click node_backendmatch "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/matching.js"
click node_email "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/emailService.js"
click node_dbclient "https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/db.js"
click node_schema "https://github.com/kruddha981/astrothunder-sahakara/blob/main/supabase/schema.sql"

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_web,node_ladder,node_config toneBlue
class node_adminui toneAmber
class node_api,node_authroutes,node_donationroutes,node_miscroutes,node_lifecycle,node_backendmatch,node_email,node_dbclient toneMint
class node_schema,node_supabase toneRose
class node_donor,node_shelter,node_driver,node_admin,node_smtp,node_maps toneIndigo
```

## Components

### Rescue experience

- [Rescue SPA](https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/script.js): `frontend/script.js`
- [Safety ladder](https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/matching.js): `frontend/matching.js`
- [Client config](https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/config.js): `frontend/config.js`

### Admin operations

- [Admin portal](https://github.com/kruddha981/astrothunder-sahakara/blob/main/frontend/admin/admin.js): `frontend/admin/admin.js`

### Optional API

- [Express API](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/server.js): `backend/src/server.js`
- [Auth routes](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Donation routes](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/routes/donations.js): `backend/src/routes/donations.js`
- [Shelter and stats routes](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/routes/misc.js): `backend/src/routes/misc.js`
- [Donation lifecycle](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/donationService.js): `backend/src/donationService.js`
- [Zone matching](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/matching.js): `backend/src/matching.js`
- [OTP email](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/emailService.js): `backend/src/emailService.js`
- [Backend DB client](https://github.com/kruddha981/astrothunder-sahakara/blob/main/backend/src/db.js): `backend/src/db.js`

### Platform data

- [Supabase schema](https://github.com/kruddha981/astrothunder-sahakara/blob/main/supabase/schema.sql): `supabase/schema.sql`
- **Supabase service**

### Other components

- **Donor**
- **Shelter / recipient**
- **Volunteer driver**
- **Administrator**
- **SMTP provider**
- **Map and routing services**

## Connections

- Donor → Rescue SPA: posts surplus
- Rescue SPA → Client config: gets client config
- Rescue SPA → Safety ladder: evaluates rescue tier
- Rescue SPA → Supabase service: reads and writes donations
- Supabase service → Rescue SPA: streams live updates
- Shelter / recipient → Rescue SPA: uses rescue portal
- Volunteer driver → Rescue SPA: updates rescue status
- Administrator → Admin portal: manages operations
- Admin portal → Supabase service: manages records and logs
- Admin portal → Map and routing services: renders maps and routes
- Rescue SPA → Map and routing services: renders recipient map
- Donor → Express API: posts via optional API
- Express API → Auth routes: dispatches auth
- Express API → Donation routes: dispatches donations
- Express API → Shelter and stats routes: dispatches support routes
- Donation routes → Donation lifecycle: runs lifecycle actions
- Shelter and stats routes → Donation lifecycle: requests shelter and stats
- Auth routes → Backend DB client: reads and writes auth data
- Auth routes → OTP email: sends OTP
- OTP email → SMTP provider: sends email
- Donation lifecycle → Zone matching: selects shelter and driver
- Donation lifecycle → Backend DB client: reads and updates records
- Backend DB client → Supabase service: queries database
- Supabase schema → Supabase service: defines tables and policies
