# vishnu21112006/fooddonation architecture

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

- Interactive diagram: https://gitdiagram.com/vishnu21112006/fooddonation
- Repository: https://github.com/vishnu21112006/fooddonation

## Overview

Paradox of Food Waste is a browser-based food-donation dashboard. A donor records food and expiry details; the interface can request an AI expiry suggestion, then retrieves and displays the available-food list with remaining-time status. Donors can also explore nearby NGOs and share a donation location. The backend keeps food records in memory and uses Gemini for suggestions, with a local rules-based fallback. The excerpts do not show a running NGO backend, so that integration is shown as optional; nearby NGO results are generated in the browser.

Main entry points: [`app.js`](https://github.com/vishnu21112006/fooddonation/blob/main/app.js) (Dashboard interactions), [`backend/server.js`](https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js) (Food API), [`index.html`](https://github.com/vishnu21112006/fooddonation/blob/main/index.html) (Dashboard interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Donor dashboard"]
  node_dashboard["Dashboard interface<br/>[index.html]"]
  node_ui_logic["Dashboard interactions<br/>[app.js]"]
end

subgraph group_food["Food inventory"]
  node_food_entry["Food entry<br/>[app.js]"]
  node_food_api["Food API<br/>[server.js]"]
  node_food_memory[("In-memory foods<br/>[server.js]")]
  node_food_list["Availability list<br/>[app.js]"]
end

subgraph group_expiry["Expiry guidance"]
  node_expiry_request["Expiry suggestion request<br/>[app.js]"]
  node_expiry_api["Expiry endpoint<br/>[server.js]"]
  node_gemini["Gemini models"]
  node_local_rules["Local food rules<br/>[server.js]"]
end

subgraph group_discovery["NGO discovery"]
  node_ngo_map["Nearby NGO map<br/>[app.js]"]
  node_geolocation["Browser geolocation"]
  node_ngo_mock["Mock NGO results<br/>[app.js]"]
  node_map_tiles["OpenStreetMap tiles"]
  node_ngo_service["NGO request service"]
end

node_donor(("Donor"))

node_donor -->|"uses"| node_dashboard
node_dashboard -->|"loads"| node_ui_logic
node_ui_logic -->|"submits"| node_food_entry
node_food_entry -->|"POST /addFood"| node_food_api
node_food_api -->|"stores"| node_food_memory
node_ui_logic -->|"GET /foods"| node_food_api
node_food_api -->|"reads"| node_food_memory
node_ui_logic -->|"renders"| node_food_list
node_ui_logic -->|"requests"| node_expiry_request
node_expiry_request -->|"POST suggestion"| node_expiry_api
node_expiry_api -->|"requests generation"| node_gemini
node_expiry_api -->|"falls back"| node_local_rules
node_expiry_request -->|"returns guidance"| node_ui_logic
node_ui_logic -->|"opens map"| node_ngo_map
node_ngo_map -->|"gets position"| node_geolocation
node_ngo_map -->|"generates nearby results"| node_ngo_mock
node_ngo_map -->|"loads tiles"| node_map_tiles
node_ngo_map -.->|"shares location"| node_ngo_service

click node_dashboard "https://github.com/vishnu21112006/fooddonation/blob/main/index.html"
click node_ui_logic "https://github.com/vishnu21112006/fooddonation/blob/main/app.js"
click node_food_entry "https://github.com/vishnu21112006/fooddonation/blob/main/app.js"
click node_food_api "https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js"
click node_food_memory "https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js"
click node_food_list "https://github.com/vishnu21112006/fooddonation/blob/main/app.js"
click node_expiry_request "https://github.com/vishnu21112006/fooddonation/blob/main/app.js"
click node_expiry_api "https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js"
click node_local_rules "https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js"
click node_ngo_map "https://github.com/vishnu21112006/fooddonation/blob/main/app.js"
click node_ngo_mock "https://github.com/vishnu21112006/fooddonation/blob/main/app.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_dashboard,node_ui_logic toneBlue
class node_food_entry,node_food_api,node_food_memory,node_food_list toneAmber
class node_expiry_request,node_expiry_api,node_gemini,node_local_rules toneMint
class node_ngo_map,node_geolocation,node_ngo_mock,node_map_tiles,node_ngo_service toneRose
class node_donor toneIndigo
```

## Components

### Donor dashboard

- [Dashboard interface](https://github.com/vishnu21112006/fooddonation/blob/main/index.html): `index.html`
- [Dashboard interactions](https://github.com/vishnu21112006/fooddonation/blob/main/app.js): `app.js`

### Food inventory

- [Food entry](https://github.com/vishnu21112006/fooddonation/blob/main/app.js): `app.js`
- [Food API](https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js): `backend/server.js`
- [In-memory foods](https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js): `backend/server.js`
- [Availability list](https://github.com/vishnu21112006/fooddonation/blob/main/app.js): `app.js`

### Expiry guidance

- [Expiry suggestion request](https://github.com/vishnu21112006/fooddonation/blob/main/app.js): `app.js`
- [Expiry endpoint](https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js): `backend/server.js`
- **Gemini models**
- [Local food rules](https://github.com/vishnu21112006/fooddonation/blob/main/backend/server.js): `backend/server.js`

### NGO discovery

- [Nearby NGO map](https://github.com/vishnu21112006/fooddonation/blob/main/app.js): `app.js`
- **Browser geolocation**
- [Mock NGO results](https://github.com/vishnu21112006/fooddonation/blob/main/app.js): `app.js`
- **OpenStreetMap tiles**
- **NGO request service**

### Other components

- **Donor**

## Connections

- Donor → Dashboard interface: uses
- Dashboard interface → Dashboard interactions: loads
- Dashboard interactions → Food entry: submits
- Food entry → Food API: POST /addFood
- Food API → In-memory foods: stores
- Dashboard interactions → Food API: GET /foods
- Food API → In-memory foods: reads
- Dashboard interactions → Availability list: renders
- Dashboard interactions → Expiry suggestion request: requests
- Expiry suggestion request → Expiry endpoint: POST suggestion
- Expiry endpoint → Gemini models: requests generation
- Expiry endpoint → Local food rules: falls back
- Expiry suggestion request → Dashboard interactions: returns guidance
- Dashboard interactions → Nearby NGO map: opens map
- Nearby NGO map → Browser geolocation: gets position
- Nearby NGO map → Mock NGO results: generates nearby results
- Nearby NGO map → OpenStreetMap tiles: loads tiles
- Nearby NGO map → NGO request service: shares location
