# sujalafx23-ux/sahakara architecture

> Architecture diagram of the GitHub repository sujalafx23-ux/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/sujalafx23-ux/sahakara
- Repository: https://github.com/sujalafx23-ux/sahakara

## Overview

Sahakara is a food-rescue platform: donors post surplus food, the app applies food-safety and distance rules to route it to an eligible shelter, animal recipient, or compost facility, and participants progress the rescue through pickup and delivery. The primary SPA uses Supabase directly for core data and realtime features; the separate Express/SQLite backend is documented as optional. Admin tools manage live operations and impact. The README documents several admin capabilities whose implementation details were not sampled, so their connections are limited to the admin controller and Supabase.

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

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Rescue application"]
  node_spa["Rescue SPA<br/>[script.js]"]
  node_ladder["Safety ladder<br/>[matching.js]"]
  node_config["Supabase config<br/>[config.js]"]
end

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

subgraph group_data["Data services"]
  node_supabase[("Supabase services")]
  node_schema["Platform schema<br/>[schema.sql]"]
  node_map["Map / routing services"]
end

subgraph group_optional["Optional backend"]
  node_server["Express server<br/>[server.js]"]
  node_donationroutes["Donation routes<br/>[donations.js]"]
  node_miscroutes["Shelter / stats routes<br/>[misc.js]"]
  node_authroutes["Auth routes<br/>[auth.js]"]
  node_service["Donation lifecycle<br/>[donationService.js]"]
  node_backendmatch["Zone matching<br/>[matching.js]"]
  node_sqlite[("Local SQLite<br/>[db.js]")]
  node_email["OTP email<br/>[emailService.js]"]
  node_seed["Demo seed<br/>[seed.js]"]
end

node_donor(("Donor"))
node_recipient(("Shelter / recipient"))
node_driver(("Volunteer driver"))
node_admin(("Administrator"))
node_smtp["SMTP service"]

node_donor -->|"posts food"| node_spa
node_spa -->|"requests match"| node_ladder
node_ladder -->|"returns recipient"| node_spa
node_spa -->|"reads / writes"| node_supabase
node_supabase -->|"realtime updates"| node_spa
node_recipient -->|"claims donation"| node_spa
node_driver -->|"updates progress"| node_spa
node_admin -->|"manages operations"| node_adminapp
node_adminapp -->|"manages records"| node_supabase
node_supabase -->|"streams updates"| node_adminapp
node_config -->|"creates client"| node_supabase
node_schema -->|"defines tables"| node_supabase
node_adminapp -->|"uses map"| node_map
node_spa -.->|"uses maps"| node_map
node_spa -.->|"auth API"| node_server
node_server -->|"mounts routes"| node_donationroutes
node_server -->|"mounts routes"| node_miscroutes
node_server -->|"mounts routes"| node_authroutes
node_server -->|"initializes data"| node_seed
node_donationroutes -->|"handles lifecycle"| node_service
node_miscroutes -->|"reads / toggles"| node_service
node_authroutes -->|"reads / writes"| node_sqlite
node_authroutes -->|"sends OTP"| node_email
node_service -->|"finds shelter / driver"| node_backendmatch
node_service -->|"reads / writes"| node_sqlite
node_email -.->|"sends mail"| node_smtp

click node_spa "https://github.com/sujalafx23-ux/sahakara/blob/main/frontend/script.js"
click node_ladder "https://github.com/sujalafx23-ux/sahakara/blob/main/frontend/matching.js"
click node_config "https://github.com/sujalafx23-ux/sahakara/blob/main/frontend/config.js"
click node_adminapp "https://github.com/sujalafx23-ux/sahakara/blob/main/frontend/admin/admin.js"
click node_schema "https://github.com/sujalafx23-ux/sahakara/blob/main/supabase/schema.sql"
click node_server "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/server.js"
click node_donationroutes "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/routes/donations.js"
click node_miscroutes "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/routes/misc.js"
click node_authroutes "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/routes/auth.js"
click node_service "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/donationService.js"
click node_backendmatch "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/matching.js"
click node_sqlite "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/db.js"
click node_email "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/emailService.js"
click node_seed "https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/seed.js"

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_spa,node_ladder,node_config toneBlue
class node_adminapp toneAmber
class node_supabase,node_schema,node_map toneMint
class node_server,node_donationroutes,node_miscroutes,node_authroutes,node_service,node_backendmatch,node_sqlite,node_email,node_seed toneRose
class node_donor,node_recipient,node_driver,node_admin,node_smtp toneIndigo
```

## Components

### Rescue application

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

### Admin operations

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

### Data services

- **Supabase services**
- [Platform schema](https://github.com/sujalafx23-ux/sahakara/blob/main/supabase/schema.sql): `supabase/schema.sql`
- **Map / routing services**

### Optional backend

- [Express server](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/server.js): `backend/src/server.js`
- [Donation routes](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/routes/donations.js): `backend/src/routes/donations.js`
- [Shelter / stats routes](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/routes/misc.js): `backend/src/routes/misc.js`
- [Auth routes](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/routes/auth.js): `backend/src/routes/auth.js`
- [Donation lifecycle](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/donationService.js): `backend/src/donationService.js`
- [Zone matching](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/matching.js): `backend/src/matching.js`
- [Local SQLite](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/db.js): `backend/src/db.js`
- [OTP email](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/emailService.js): `backend/src/emailService.js`
- [Demo seed](https://github.com/sujalafx23-ux/sahakara/blob/main/backend/src/seed.js): `backend/src/seed.js`

### Other components

- **Donor**
- **Shelter / recipient**
- **Volunteer driver**
- **Administrator**
- **SMTP service**

## Connections

- Donor → Rescue SPA: posts food
- Rescue SPA → Safety ladder: requests match
- Safety ladder → Rescue SPA: returns recipient
- Rescue SPA → Supabase services: reads / writes
- Supabase services → Rescue SPA: realtime updates
- Shelter / recipient → Rescue SPA: claims donation
- Volunteer driver → Rescue SPA: updates progress
- Administrator → Admin portal: manages operations
- Admin portal → Supabase services: manages records
- Supabase services → Admin portal: streams updates
- Supabase config → Supabase services: creates client
- Platform schema → Supabase services: defines tables
- Admin portal → Map / routing services: uses map
- Rescue SPA → Map / routing services: uses maps
- Rescue SPA → Express server: auth API
- Express server → Donation routes: mounts routes
- Express server → Shelter / stats routes: mounts routes
- Express server → Auth routes: mounts routes
- Express server → Demo seed: initializes data
- Donation routes → Donation lifecycle: handles lifecycle
- Shelter / stats routes → Donation lifecycle: reads / toggles
- Auth routes → Local SQLite: reads / writes
- Auth routes → OTP email: sends OTP
- Donation lifecycle → Zone matching: finds shelter / driver
- Donation lifecycle → Local SQLite: reads / writes
- OTP email → SMTP service: sends mail
