# mehedi1891/food_bridge architecture

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

- Interactive diagram: https://gitdiagram.com/mehedi1891/food_bridge
- Repository: https://github.com/mehedi1891/food_bridge

## Overview

FoodBridge connects food donors with NGOs and volunteers through a dashboard: donors publish surplus batches, collection teams claim and confirm delivery, and users track quantity, expiry, location, and impact. The browser calls an Express API, which computes urgency and analytics and persists donation records in a local JSON file. The README also describes a relational schema, but the sampled runtime uses JSON; the SQL files are not treated as active runtime components. Relationships reflect the README and sampled source; unsampled details are omitted.

Main entry points: [`backend/data/db.json`](https://github.com/mehedi1891/food_bridge/blob/main/backend/data/db.json) (Donation records), [`backend/server.js`](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js) (Donation upload), [`frontend/index.html`](https://github.com/mehedi1891/food_bridge/blob/main/frontend/index.html) (Dashboard UI), [`frontend/app.js`](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js) (Impact dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_ui["Dashboard UI<br/>[index.html]"]
  node_upload["Surplus upload<br/>[app.js]"]
  node_impact["Impact dashboard<br/>[app.js]"]
  node_charts["Impact charts<br/>[app.js]"]
  node_collection["Collection hub<br/>[app.js]"]
  node_tracking["Live tracking<br/>[app.js]"]
  node_countdown["Expiry countdown<br/>[app.js]"]
  node_claim_action["Claim batch<br/>[app.js]"]
  node_delivery_action["Confirm delivery<br/>[app.js]"]
end

subgraph group_api["Donation API"]
  node_api["Express API<br/>[server.js]"]
  node_stats_route["Impact metrics<br/>[server.js]"]
  node_list_route["Donation listings<br/>[server.js]"]
  node_upload_route["Donation upload<br/>[server.js]"]
  node_claim_route["Claim endpoint<br/>[server.js]"]
  node_deliver_route["Delivery endpoint<br/>[server.js]"]
  node_urgency["Expiry priority<br/>[server.js]"]
end

subgraph group_storage["Persistence"]
  node_json_store[("Donation records<br/>[db.json]")]
end

node_donor(("Food donor"))
node_collector(("NGO / volunteer"))

node_donor -->|"uses"| node_dashboard_ui
node_collector -->|"uses"| node_dashboard_ui
node_dashboard_ui -->|"submits"| node_upload
node_upload -->|"POSTs batch"| node_upload_route
node_impact -->|"fetches metrics"| node_stats_route
node_impact -->|"renders charts"| node_charts
node_collection -->|"loads batches"| node_list_route
node_tracking -->|"loads batches"| node_list_route
node_tracking -->|"ticks expiry"| node_countdown
node_claim_action -->|"PATCHes claim"| node_claim_route
node_delivery_action -->|"PATCHes delivery"| node_deliver_route
node_api -->|"serves static data"| node_json_store
node_stats_route -->|"reads records"| node_json_store
node_list_route -->|"reads records"| node_json_store
node_upload_route -->|"classifies expiry"| node_urgency
node_upload_route -->|"adds record"| node_json_store
node_claim_route -->|"updates record"| node_json_store
node_deliver_route -->|"updates record"| node_json_store

click node_dashboard_ui "https://github.com/mehedi1891/food_bridge/blob/main/frontend/index.html"
click node_upload "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_impact "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_charts "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_collection "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_tracking "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_countdown "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_claim_action "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_delivery_action "https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js"
click node_api "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_stats_route "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_list_route "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_upload_route "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_claim_route "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_deliver_route "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_urgency "https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js"
click node_json_store "https://github.com/mehedi1891/food_bridge/blob/main/backend/data/db.json"

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_dashboard_ui,node_upload,node_impact,node_charts,node_collection,node_tracking,node_countdown,node_claim_action,node_delivery_action toneBlue
class node_api,node_stats_route,node_list_route,node_upload_route,node_claim_route,node_deliver_route,node_urgency toneAmber
class node_json_store toneMint
class node_donor,node_collector toneIndigo
```

## Components

### Dashboard

- [Dashboard UI](https://github.com/mehedi1891/food_bridge/blob/main/frontend/index.html): `frontend/index.html`
- [Surplus upload](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Impact dashboard](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Impact charts](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Collection hub](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Live tracking](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Expiry countdown](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Claim batch](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`
- [Confirm delivery](https://github.com/mehedi1891/food_bridge/blob/main/frontend/app.js): `frontend/app.js`

### Donation API

- [Express API](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`
- [Impact metrics](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`
- [Donation listings](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`
- [Donation upload](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`
- [Claim endpoint](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`
- [Delivery endpoint](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`
- [Expiry priority](https://github.com/mehedi1891/food_bridge/blob/main/backend/server.js): `backend/server.js`

### Persistence

- [Donation records](https://github.com/mehedi1891/food_bridge/blob/main/backend/data/db.json): `backend/data/db.json`

### Other components

- **Food donor**
- **NGO / volunteer**

## Connections

- Food donor → Dashboard UI: uses (evidence: `README.md`)
- NGO / volunteer → Dashboard UI: uses (evidence: `README.md`)
- Dashboard UI → Surplus upload: submits (evidence: `frontend/app.js`)
- Surplus upload → Donation upload: POSTs batch (evidence: `frontend/app.js`)
- Impact dashboard → Impact metrics: fetches metrics (evidence: `frontend/app.js`)
- Impact dashboard → Impact charts: renders charts (evidence: `frontend/app.js`)
- Collection hub → Donation listings: loads batches (evidence: `frontend/app.js`)
- Live tracking → Donation listings: loads batches (evidence: `frontend/app.js`)
- Live tracking → Expiry countdown: ticks expiry (evidence: `frontend/app.js`)
- Claim batch → Claim endpoint: PATCHes claim (evidence: `frontend/app.js`)
- Confirm delivery → Delivery endpoint: PATCHes delivery (evidence: `frontend/app.js`)
- Express API → Donation records: serves static data (evidence: `backend/server.js`)
- Impact metrics → Donation records: reads records (evidence: `backend/server.js`)
- Donation listings → Donation records: reads records (evidence: `backend/server.js`)
- Donation upload → Expiry priority: classifies expiry (evidence: `backend/server.js`)
- Donation upload → Donation records: adds record (evidence: `backend/server.js`)
- Claim endpoint → Donation records: updates record (evidence: `backend/server.js`)
- Delivery endpoint → Donation records: updates record (evidence: `backend/server.js`)
