# saipavan-28/foodbanksystem architecture

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

- Interactive diagram: https://gitdiagram.com/saipavan-28/foodbanksystem
- Repository: https://github.com/saipavan-28/foodbanksystem

## Overview

FoodBridge coordinates food donors, NGOs/shelters, volunteers and administrators through donation and relief requests, volunteer assignment, pickup/delivery tracking and completion. The UI routes role-based portals through shared application state; that state uses REST services against an Express/MongoDB backend, with Socket.IO for live tracking and chat/notifications. Geolocation and Golden Hour urgency are supporting capabilities. The graph reflects only visible calls or imports and explicit excerpts; unshown routes and integrations are not assumed to connect.

Main entry points: [`src/context/FoodBridgeContext.tsx`](https://github.com/saipavan-28/foodbanksystem/blob/main/src/context/FoodBridgeContext.tsx) (Shared workflow state), [`src/App.tsx`](https://github.com/saipavan-28/foodbanksystem/blob/main/src/App.tsx) (Role router), [`server/server.js`](https://github.com/saipavan-28/foodbanksystem/blob/main/server/server.js) (HTTP and socket server), [`src/pages/VolunteerApp.tsx`](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/VolunteerApp.tsx) (Volunteer app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Role-based application"]
  node_app["Role router<br/>[App.tsx]"]
  node_donor["Donor portal<br/>[DonorPortal.tsx]"]
  node_ngo["NGO portal<br/>[NGOPortal.tsx]"]
  node_volunteer["Volunteer app<br/>[VolunteerApp.tsx]"]
  node_admincenter["Admin center"]
  node_landing["Public landing<br/>[PublicLanding.tsx]"]
  node_login["Login and registration<br/>[LoginPage.tsx]"]
end

subgraph group_workflow["Food rescue workflow"]
  node_state["Shared workflow state"]
  node_matching["Volunteer matching card"]
  node_quiz["Volunteer safety quiz"]
end

subgraph group_backend["API and persistence"]
  node_api["REST client<br/>[api.ts]"]
  node_server["HTTP and socket server<br/>[server.js]"]
  node_authroutes["Authentication routes<br/>[authRoutes.js]"]
  node_requestroutes["Request routes<br/>[requestRoutes.js]"]
  node_volroutes["Volunteer routes<br/>[volunteerRoutes.js]"]
  node_chatroutes["Chat routes<br/>[chatRoutes.js]"]
  node_notificationroutes["Notification routes"]
  node_trackingroutes["Tracking endpoint<br/>[trackingRoutes.js]"]
  node_users[("User records<br/>[User.js]")]
  node_requests[("Donation requests<br/>[DonationRequest.js]")]
  node_volunteers[("Volunteer records<br/>[Volunteer.js]")]
end

subgraph group_realtime["Live coordination"]
  node_chat[("Chat records<br/>[Chat.js]")]
  node_notifications[("Notification records<br/>[Notification.js]")]
  node_socketclient["Socket client<br/>[socket.ts]"]
  node_trackingui["Live delivery tracking"]
  node_chatui["Live chat<br/>[LiveChatModal.tsx]"]
end

subgraph group_shared["Shared capabilities"]
  node_geo["Geolocation and distance<br/>[geoUtils.ts]"]
  node_locationpicker["Location picker"]
  node_golden["Golden Hour timer"]
  node_profile["Profile editor<br/>[ProfileEditor.tsx]"]
  node_types["Domain types<br/>[foodbridge.ts]"]
end

node_user(("Donor / NGO / volunteer"))
node_admin(("Administrator"))
node_nominatim["OpenStreetMap Nominatim"]

node_user -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"provides state"| node_state
node_app -->|"routes role"| node_donor
node_app -->|"routes role"| node_ngo
node_app -->|"routes role"| node_volunteer
node_app -->|"routes role"| node_admincenter
node_app -->|"routes default"| node_landing
node_app -->|"routes login"| node_login
node_donor -.->|"updates requests"| node_state
node_ngo -.->|"submits needs"| node_state
node_volunteer -.->|"updates missions"| node_state
node_admincenter -.->|"manages requests"| node_state
node_login -.->|"authenticates"| node_state
node_state -->|"calls REST"| node_api
node_api -.->|"sends API requests"| node_server
node_server -->|"mounts routes"| node_authroutes
node_server -->|"mounts routes"| node_requestroutes
node_server -->|"mounts routes"| node_volroutes
node_server -->|"mounts routes"| node_chatroutes
node_server -->|"mounts routes"| node_notificationroutes
node_server -->|"mounts routes"| node_trackingroutes
node_authroutes -->|"reads and writes"| node_users
node_requestroutes -->|"reads and writes"| node_requests
node_requestroutes -->|"releases assignment"| node_volunteers
node_volroutes -->|"manages"| node_volunteers
node_chatroutes -->|"stores messages"| node_chat
node_notificationroutes -->|"stores alerts"| node_notifications
node_server -.->|"exchanges events"| node_socketclient
node_trackingui -->|"subscribes"| node_socketclient
node_trackingui -->|"calculates distance"| node_geo
node_chatui -->|"uses shared state"| node_state
node_locationpicker -->|"geocodes locations"| node_geo
node_geo -->|"searches and resolves"| node_nominatim
node_state -->|"uses distance"| node_geo
node_donor -->|"renders urgency"| node_golden
node_ngo -->|"renders urgency"| node_golden
node_volunteer -->|"renders urgency"| node_golden
node_admincenter -->|"renders matching"| node_matching
node_login -->|"renders quiz"| node_quiz
node_volunteer -->|"renders quiz"| node_quiz
node_ngo -->|"renders editor"| node_profile
node_donor -->|"renders editor"| node_profile
node_state -->|"uses domain types"| node_types
node_volunteer -->|"uses domain types"| node_types

click node_app "https://github.com/saipavan-28/foodbanksystem/blob/main/src/App.tsx"
click node_donor "https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/DonorPortal.tsx"
click node_ngo "https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/NGOPortal.tsx"
click node_volunteer "https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/VolunteerApp.tsx"
click node_admincenter "https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/AdminCommandCenter.tsx"
click node_landing "https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/PublicLanding.tsx"
click node_login "https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/LoginPage.tsx"
click node_state "https://github.com/saipavan-28/foodbanksystem/blob/main/src/context/FoodBridgeContext.tsx"
click node_api "https://github.com/saipavan-28/foodbanksystem/blob/main/src/services/api.ts"
click node_server "https://github.com/saipavan-28/foodbanksystem/blob/main/server/server.js"
click node_authroutes "https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/authRoutes.js"
click node_requestroutes "https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/requestRoutes.js"
click node_volroutes "https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/volunteerRoutes.js"
click node_chatroutes "https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/chatRoutes.js"
click node_notificationroutes "https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/notificationRoutes.js"
click node_trackingroutes "https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/trackingRoutes.js"
click node_users "https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/User.js"
click node_requests "https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/DonationRequest.js"
click node_volunteers "https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/Volunteer.js"
click node_chat "https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/Chat.js"
click node_notifications "https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/Notification.js"
click node_socketclient "https://github.com/saipavan-28/foodbanksystem/blob/main/src/services/socket.ts"
click node_trackingui "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/LiveTrackingModal.tsx"
click node_chatui "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/LiveChatModal.tsx"
click node_geo "https://github.com/saipavan-28/foodbanksystem/blob/main/src/utils/geoUtils.ts"
click node_locationpicker "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/LocationPickerMap.tsx"
click node_golden "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/GoldenHourBadge.tsx"
click node_matching "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/MatchingDeliveryBoyCard.tsx"
click node_quiz "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/VolunteerQuizModal.tsx"
click node_profile "https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/ProfileEditor.tsx"
click node_types "https://github.com/saipavan-28/foodbanksystem/blob/main/src/types/foodbridge.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_donor,node_ngo,node_volunteer,node_admincenter,node_landing,node_login toneBlue
class node_state,node_matching,node_quiz toneAmber
class node_api,node_server,node_authroutes,node_requestroutes,node_volroutes,node_chatroutes,node_notificationroutes,node_trackingroutes,node_users,node_requests,node_volunteers toneMint
class node_chat,node_notifications,node_socketclient,node_trackingui,node_chatui toneRose
class node_geo,node_locationpicker,node_golden,node_profile,node_types,node_user,node_admin,node_nominatim toneIndigo
```

## Components

### Role-based application

- [Role router](https://github.com/saipavan-28/foodbanksystem/blob/main/src/App.tsx): `src/App.tsx`
- [Donor portal](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/DonorPortal.tsx): `src/pages/DonorPortal.tsx`
- [NGO portal](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/NGOPortal.tsx): `src/pages/NGOPortal.tsx`
- [Volunteer app](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/VolunteerApp.tsx): `src/pages/VolunteerApp.tsx`
- [Admin center](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/AdminCommandCenter.tsx): `src/pages/AdminCommandCenter.tsx`
- [Public landing](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/PublicLanding.tsx): `src/pages/PublicLanding.tsx`
- [Login and registration](https://github.com/saipavan-28/foodbanksystem/blob/main/src/pages/LoginPage.tsx): `src/pages/LoginPage.tsx`

### Food rescue workflow

- [Shared workflow state](https://github.com/saipavan-28/foodbanksystem/blob/main/src/context/FoodBridgeContext.tsx): `src/context/FoodBridgeContext.tsx`
- [Volunteer matching card](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/MatchingDeliveryBoyCard.tsx): `src/components/MatchingDeliveryBoyCard.tsx`
- [Volunteer safety quiz](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/VolunteerQuizModal.tsx): `src/components/VolunteerQuizModal.tsx`

### API and persistence

- [REST client](https://github.com/saipavan-28/foodbanksystem/blob/main/src/services/api.ts): `src/services/api.ts`
- [HTTP and socket server](https://github.com/saipavan-28/foodbanksystem/blob/main/server/server.js): `server/server.js`
- [Authentication routes](https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/authRoutes.js): `server/routes/authRoutes.js`
- [Request routes](https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/requestRoutes.js): `server/routes/requestRoutes.js`
- [Volunteer routes](https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/volunteerRoutes.js): `server/routes/volunteerRoutes.js`
- [Chat routes](https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/chatRoutes.js): `server/routes/chatRoutes.js`
- [Notification routes](https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/notificationRoutes.js): `server/routes/notificationRoutes.js`
- [Tracking endpoint](https://github.com/saipavan-28/foodbanksystem/blob/main/server/routes/trackingRoutes.js): `server/routes/trackingRoutes.js`
- [User records](https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/User.js): `server/models/User.js`
- [Donation requests](https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/DonationRequest.js): `server/models/DonationRequest.js`
- [Volunteer records](https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/Volunteer.js): `server/models/Volunteer.js`

### Live coordination

- [Chat records](https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/Chat.js): `server/models/Chat.js`
- [Notification records](https://github.com/saipavan-28/foodbanksystem/blob/main/server/models/Notification.js): `server/models/Notification.js`
- [Socket client](https://github.com/saipavan-28/foodbanksystem/blob/main/src/services/socket.ts): `src/services/socket.ts`
- [Live delivery tracking](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/LiveTrackingModal.tsx): `src/components/LiveTrackingModal.tsx`
- [Live chat](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/LiveChatModal.tsx): `src/components/LiveChatModal.tsx`

### Shared capabilities

- [Geolocation and distance](https://github.com/saipavan-28/foodbanksystem/blob/main/src/utils/geoUtils.ts): `src/utils/geoUtils.ts`
- [Location picker](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/LocationPickerMap.tsx): `src/components/LocationPickerMap.tsx`
- [Golden Hour timer](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/GoldenHourBadge.tsx): `src/components/GoldenHourBadge.tsx`
- [Profile editor](https://github.com/saipavan-28/foodbanksystem/blob/main/src/components/ProfileEditor.tsx): `src/components/ProfileEditor.tsx`
- [Domain types](https://github.com/saipavan-28/foodbanksystem/blob/main/src/types/foodbridge.ts): `src/types/foodbridge.ts`

### Other components

- **Donor / NGO / volunteer**
- **Administrator**
- **OpenStreetMap Nominatim**

## Connections

- Donor / NGO / volunteer → Role router: uses (evidence: `src/App.tsx`)
- Administrator → Role router: uses (evidence: `src/App.tsx`)
- Role router → Shared workflow state: provides state (evidence: `src/App.tsx`)
- Role router → Donor portal: routes role (evidence: `src/App.tsx`)
- Role router → NGO portal: routes role (evidence: `src/App.tsx`)
- Role router → Volunteer app: routes role (evidence: `src/App.tsx`)
- Role router → Admin center: routes role (evidence: `src/App.tsx`)
- Role router → Public landing: routes default (evidence: `src/App.tsx`)
- Role router → Login and registration: routes login (evidence: `src/App.tsx`)
- Donor portal → Shared workflow state: updates requests (evidence: `src/pages/DonorPortal.tsx`)
- NGO portal → Shared workflow state: submits needs (evidence: `src/pages/NGOPortal.tsx`)
- Volunteer app → Shared workflow state: updates missions (evidence: `src/pages/VolunteerApp.tsx`)
- Admin center → Shared workflow state: manages requests (evidence: `src/pages/AdminCommandCenter.tsx`)
- Login and registration → Shared workflow state: authenticates (evidence: `src/pages/LoginPage.tsx`)
- Shared workflow state → REST client: calls REST (evidence: `src/context/FoodBridgeContext.tsx`)
- REST client → HTTP and socket server: sends API requests
- HTTP and socket server → Authentication routes: mounts routes (evidence: `server/server.js`)
- HTTP and socket server → Request routes: mounts routes (evidence: `server/server.js`)
- HTTP and socket server → Volunteer routes: mounts routes (evidence: `server/server.js`)
- HTTP and socket server → Chat routes: mounts routes (evidence: `server/server.js`)
- HTTP and socket server → Notification routes: mounts routes (evidence: `server/server.js`)
- HTTP and socket server → Tracking endpoint: mounts routes (evidence: `server/server.js`)
- Authentication routes → User records: reads and writes (evidence: `server/routes/authRoutes.js`)
- Request routes → Donation requests: reads and writes (evidence: `server/routes/requestRoutes.js`)
- Request routes → Volunteer records: releases assignment (evidence: `server/routes/requestRoutes.js`)
- Volunteer routes → Volunteer records: manages (evidence: `server/routes/volunteerRoutes.js`)
- Chat routes → Chat records: stores messages (evidence: `server/routes/chatRoutes.js`)
- Notification routes → Notification records: stores alerts (evidence: `server/routes/notificationRoutes.js`)
- HTTP and socket server → Socket client: exchanges events
- Live delivery tracking → Socket client: subscribes (evidence: `src/components/LiveTrackingModal.tsx`)
- Live delivery tracking → Geolocation and distance: calculates distance (evidence: `src/components/LiveTrackingModal.tsx`)
- Live chat → Shared workflow state: uses shared state (evidence: `src/components/LiveChatModal.tsx`)
- Location picker → Geolocation and distance: geocodes locations (evidence: `src/components/LocationPickerMap.tsx`)
- Geolocation and distance → OpenStreetMap Nominatim: searches and resolves (evidence: `src/utils/geoUtils.ts`)
- Shared workflow state → Geolocation and distance: uses distance (evidence: `src/context/FoodBridgeContext.tsx`)
- Donor portal → Golden Hour timer: renders urgency (evidence: `src/pages/DonorPortal.tsx`)
- NGO portal → Golden Hour timer: renders urgency (evidence: `src/pages/NGOPortal.tsx`)
- Volunteer app → Golden Hour timer: renders urgency (evidence: `src/pages/VolunteerApp.tsx`)
- Admin center → Volunteer matching card: renders matching (evidence: `src/pages/AdminCommandCenter.tsx`)
- Login and registration → Volunteer safety quiz: renders quiz (evidence: `src/pages/LoginPage.tsx`)
- Volunteer app → Volunteer safety quiz: renders quiz (evidence: `src/pages/VolunteerApp.tsx`)
- NGO portal → Profile editor: renders editor (evidence: `src/pages/NGOPortal.tsx`)
- Donor portal → Profile editor: renders editor (evidence: `src/pages/DonorPortal.tsx`)
- Shared workflow state → Domain types: uses domain types (evidence: `src/context/FoodBridgeContext.tsx`)
- Volunteer app → Domain types: uses domain types (evidence: `src/pages/VolunteerApp.tsx`)
