# niiiizzz/food4all architecture

> Architecture diagram of the GitHub repository niiiizzz/food4all, 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/niiiizzz/food4all
- Repository: https://github.com/niiiizzz/food4all

## Overview

Food4All is a role-based food redistribution frontend connecting restaurants, customers, NGOs and shelters, delivery workers, and administrators. The main flow begins with sign-in or registration, then routes users to role-specific dashboards. Restaurants manage menu items and surplus; customers browse, purchase, or donate food; organizations and delivery users have claim and delivery workspaces; customers can track orders. The shared React context holds users, food, orders, notifications, and reward state in memory. The README documents rewards, eco-scores, and impact analytics. Dashboard excerpts are partial, so uncertain subsystem wiring is omitted.

Main entry points: [`App.tsx`](https://github.com/niiiizzz/food4all/blob/main/App.tsx) (Role Router), [`context/AppContext.tsx`](https://github.com/niiiizzz/food4all/blob/main/context/AppContext.tsx) (Shared App State), [`pages/dashboards/CustomerDashboard.tsx`](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/CustomerDashboard.tsx) (Customer Workspace), [`pages/dashboards/RestaurantDashboard.tsx`](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/RestaurantDashboard.tsx) (Restaurant Workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App Entry"]
  node_app["Role Router<br/>[App.tsx]"]
end

subgraph group_identity["Identity And Navigation"]
  node_login["Sign In And Signup<br/>[Login.tsx]"]
  node_sidebar["Role Navigation<br/>[Sidebar.tsx]"]
  node_context["Shared App State<br/>[AppContext.tsx]"]
  node_mockdata["Seed Accounts<br/>[mockData.ts]"]
end

subgraph group_redistribution["Food Redistribution"]
  node_restaurant["Restaurant Workspace"]
  node_customer["Customer Workspace"]
  node_ngo["NGO Workspace<br/>[NGODashboard.tsx]"]
end

subgraph group_fulfillment["Order Fulfillment"]
  node_delivery["Delivery Workspace"]
  node_payment["Checkout Modal<br/>[PaymentModal.tsx]"]
  node_live_map["Order Tracking Map<br/>[LiveMap.tsx]"]
  node_qr_display["QR Code Display<br/>[QRCodeDisplay.tsx]"]
  node_qr_scanner["QR Scanner<br/>[QRScanner.tsx]"]
end

subgraph group_oversight["Rewards And Oversight"]
  node_admin["Admin Workspace<br/>[AdminDashboard.tsx]"]
  node_profile["User Profile<br/>[ProfileView.tsx]"]
end

node_user(("Platform User"))

node_user -->|"opens app"| node_app
node_app -->|"shows when signed out"| node_login
node_login -->|"requests login"| node_context
node_context -->|"provides current user"| node_app
node_app -->|"renders navigation"| node_sidebar
node_app -->|"routes customer"| node_customer
node_app -->|"routes restaurant"| node_restaurant
node_app -->|"routes NGO"| node_ngo
node_app -->|"routes delivery"| node_delivery
node_app -->|"routes admin"| node_admin
node_context -->|"initializes from"| node_mockdata
node_restaurant -->|"manages food"| node_context
node_customer -->|"reads food and orders"| node_context
node_customer -->|"opens checkout"| node_payment
node_payment -->|"returns quantity"| node_customer
node_customer -->|"places order"| node_context
node_customer -->|"shows order tracking"| node_live_map
node_customer -->|"presents verification code"| node_qr_display
node_delivery -->|"provides delivery workspace"| node_qr_scanner
node_ngo -->|"uses shared state"| node_context
node_delivery -->|"uses shared state"| node_context
node_admin -->|"reads users and activity"| node_context
node_restaurant -->|"shows profile"| node_profile
node_customer -->|"shows profile"| node_profile
node_admin -->|"shows profile"| node_profile

click node_app "https://github.com/niiiizzz/food4all/blob/main/App.tsx"
click node_login "https://github.com/niiiizzz/food4all/blob/main/pages/Login.tsx"
click node_sidebar "https://github.com/niiiizzz/food4all/blob/main/components/Sidebar.tsx"
click node_context "https://github.com/niiiizzz/food4all/blob/main/context/AppContext.tsx"
click node_mockdata "https://github.com/niiiizzz/food4all/blob/main/services/mockData.ts"
click node_restaurant "https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/RestaurantDashboard.tsx"
click node_customer "https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/CustomerDashboard.tsx"
click node_ngo "https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/NGODashboard.tsx"
click node_delivery "https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/DeliveryDashboard.tsx"
click node_payment "https://github.com/niiiizzz/food4all/blob/main/components/PaymentModal.tsx"
click node_live_map "https://github.com/niiiizzz/food4all/blob/main/components/LiveMap.tsx"
click node_qr_display "https://github.com/niiiizzz/food4all/blob/main/components/QRCodeDisplay.tsx"
click node_qr_scanner "https://github.com/niiiizzz/food4all/blob/main/components/QRScanner.tsx"
click node_admin "https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/AdminDashboard.tsx"
click node_profile "https://github.com/niiiizzz/food4all/blob/main/components/ProfileView.tsx"

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_user toneBlue
class node_login,node_sidebar,node_context,node_mockdata toneAmber
class node_restaurant,node_customer,node_ngo toneMint
class node_delivery,node_payment,node_live_map,node_qr_display,node_qr_scanner toneRose
class node_admin,node_profile toneIndigo
```

## Components

### App Entry

- [Role Router](https://github.com/niiiizzz/food4all/blob/main/App.tsx): `App.tsx`

### Identity And Navigation

- [Sign In And Signup](https://github.com/niiiizzz/food4all/blob/main/pages/Login.tsx): `pages/Login.tsx`
- [Role Navigation](https://github.com/niiiizzz/food4all/blob/main/components/Sidebar.tsx): `components/Sidebar.tsx`
- [Shared App State](https://github.com/niiiizzz/food4all/blob/main/context/AppContext.tsx): `context/AppContext.tsx`
- [Seed Accounts](https://github.com/niiiizzz/food4all/blob/main/services/mockData.ts): `services/mockData.ts`

### Food Redistribution

- [Restaurant Workspace](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/RestaurantDashboard.tsx): `pages/dashboards/RestaurantDashboard.tsx`
- [Customer Workspace](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/CustomerDashboard.tsx): `pages/dashboards/CustomerDashboard.tsx`
- [NGO Workspace](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/NGODashboard.tsx): `pages/dashboards/NGODashboard.tsx`

### Order Fulfillment

- [Delivery Workspace](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/DeliveryDashboard.tsx): `pages/dashboards/DeliveryDashboard.tsx`
- [Checkout Modal](https://github.com/niiiizzz/food4all/blob/main/components/PaymentModal.tsx): `components/PaymentModal.tsx`
- [Order Tracking Map](https://github.com/niiiizzz/food4all/blob/main/components/LiveMap.tsx): `components/LiveMap.tsx`
- [QR Code Display](https://github.com/niiiizzz/food4all/blob/main/components/QRCodeDisplay.tsx): `components/QRCodeDisplay.tsx`
- [QR Scanner](https://github.com/niiiizzz/food4all/blob/main/components/QRScanner.tsx): `components/QRScanner.tsx`

### Rewards And Oversight

- [Admin Workspace](https://github.com/niiiizzz/food4all/blob/main/pages/dashboards/AdminDashboard.tsx): `pages/dashboards/AdminDashboard.tsx`
- [User Profile](https://github.com/niiiizzz/food4all/blob/main/components/ProfileView.tsx): `components/ProfileView.tsx`

### Other components

- **Platform User**

## Connections

- Platform User → Role Router: opens app
- Role Router → Sign In And Signup: shows when signed out
- Sign In And Signup → Shared App State: requests login
- Shared App State → Role Router: provides current user
- Role Router → Role Navigation: renders navigation
- Role Router → Customer Workspace: routes customer
- Role Router → Restaurant Workspace: routes restaurant
- Role Router → NGO Workspace: routes NGO
- Role Router → Delivery Workspace: routes delivery
- Role Router → Admin Workspace: routes admin
- Shared App State → Seed Accounts: initializes from
- Restaurant Workspace → Shared App State: manages food
- Customer Workspace → Shared App State: reads food and orders
- Customer Workspace → Checkout Modal: opens checkout
- Checkout Modal → Customer Workspace: returns quantity
- Customer Workspace → Shared App State: places order
- Customer Workspace → Order Tracking Map: shows order tracking
- Customer Workspace → QR Code Display: presents verification code
- Delivery Workspace → QR Scanner: provides delivery workspace
- NGO Workspace → Shared App State: uses shared state
- Delivery Workspace → Shared App State: uses shared state
- Admin Workspace → Shared App State: reads users and activity
- Restaurant Workspace → User Profile: shows profile
- Customer Workspace → User Profile: shows profile
- Admin Workspace → User Profile: shows profile
