# 4007ayesha/grub-canteen architecture

> Architecture diagram of the GitHub repository 4007ayesha/grub-canteen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/4007ayesha/grub-canteen
- Repository: https://github.com/4007ayesha/grub-canteen

## Overview

Grub Canteen is a smart canteen system with a React client and FastAPI API. Students browse and search food, manage a cart, check out, and track orders; administrators manage menus, orders, inventory, and analytics. The backend also exposes authentication, payments, feedback, notifications, and demand-prediction capabilities. The graph reflects documented routes and sampled imports; the README gives little workflow detail, and the frontend API excerpt does not establish its backend endpoint connections.

Main entry points: [`backend/main.py`](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/main.py) (API application), [`backend/database.py`](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/database.py) (Database session), [`backend/models.py`](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/models.py) (Domain records), [`frontend/src/App.jsx`](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/App.jsx) (Route application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["Route application<br/>[App.jsx]"]
  node_authui["Auth state<br/>[AuthContext.jsx]"]
  node_cart["Cart state<br/>[CartContext.jsx]"]
  node_search["Search overlay<br/>[SearchOverlay.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_student_pages["Student pages"]
  node_admin_menu["Menu administration<br/>[AdminMenu.jsx]"]
  node_admin_orders["Order administration<br/>[AdminOrders.jsx]"]
  node_admin_inventory["Inventory administration<br/>[AdminInventory.jsx]"]
  node_admin_analytics["Analytics dashboard<br/>[AdminAnalytics.jsx]"]
end

subgraph group_api["FastAPI services"]
  node_server["API application<br/>[main.py]"]
  node_auth_routes["Authentication routes<br/>[auth.py]"]
  node_menu_routes["Menu routes<br/>[menu.py]"]
  node_payment_routes["Payment routes<br/>[payment.py]"]
  node_order_routes["Order and tracking routes<br/>[orders.py]"]
  node_feedback_routes["Feedback routes<br/>[feedback.py]"]
  node_notification_routes["Notification routes<br/>[notifications.py]"]
  node_inventory_routes["Inventory and waste routes<br/>[inventory.py]"]
  node_analytics_routes["Analytics routes<br/>[analytics.py]"]
  node_prediction_routes["Demand prediction routes<br/>[predictions.py]"]
  node_auth_logic["Token and password logic<br/>[auth.py]"]
  node_admin_guard["Admin authorization<br/>[dependencies.py]"]
end

subgraph group_domain["Canteen operations"]
  node_websocket["Order update manager"]
  node_ml_model["Prediction model<br/>[ml_model.py]"]
end

subgraph group_persistence["Data and prediction"]
  node_database["Database session<br/>[database.py]"]
  node_models["Domain records<br/>[models.py]"]
  node_schemas["Request and response schemas<br/>[schemas.py]"]
end

node_student(("Student"))
node_admin(("Administrator"))

node_student -->|"uses"| node_app
node_admin -->|"uses"| node_app
node_app -->|"routes to"| node_student_pages
node_app -->|"routes to"| node_admin_menu
node_app -->|"routes to"| node_admin_orders
node_app -->|"routes to"| node_admin_inventory
node_app -->|"routes to"| node_admin_analytics
node_authui -->|"calls"| node_api_client
node_search -->|"queries"| node_api_client
node_server -->|"registers"| node_auth_routes
node_server -->|"registers"| node_menu_routes
node_server -->|"registers"| node_payment_routes
node_server -->|"registers"| node_order_routes
node_server -->|"registers"| node_feedback_routes
node_server -->|"registers"| node_notification_routes
node_server -->|"registers"| node_inventory_routes
node_server -->|"registers"| node_analytics_routes
node_server -->|"registers"| node_prediction_routes
node_auth_routes -->|"uses"| node_auth_logic
node_admin_guard -->|"validates"| node_auth_logic
node_auth_routes -->|"queries"| node_database
node_auth_routes -->|"uses"| node_models
node_auth_routes -->|"validates"| node_schemas
node_menu_routes -->|"queries"| node_database
node_menu_routes -->|"uses"| node_models
node_menu_routes -->|"validates"| node_schemas
node_payment_routes -->|"queries"| node_database
node_payment_routes -->|"uses"| node_models
node_payment_routes -->|"validates"| node_schemas
node_order_routes -->|"queries"| node_database
node_order_routes -->|"uses"| node_models
node_order_routes -->|"validates"| node_schemas
node_order_routes -->|"broadcasts"| node_websocket
node_order_routes -->|"uses"| node_notification_routes
node_feedback_routes -->|"queries"| node_database
node_feedback_routes -->|"uses"| node_models
node_feedback_routes -->|"validates"| node_schemas
node_notification_routes -->|"queries"| node_database
node_notification_routes -->|"uses"| node_models
node_notification_routes -->|"validates"| node_schemas
node_inventory_routes -->|"queries"| node_database
node_inventory_routes -->|"uses"| node_models
node_inventory_routes -->|"validates"| node_schemas
node_analytics_routes -->|"queries"| node_database
node_analytics_routes -->|"uses"| node_models
node_prediction_routes -->|"queries"| node_database
node_prediction_routes -->|"uses"| node_models
node_prediction_routes -->|"validates"| node_schemas

click node_app "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/App.jsx"
click node_authui "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/context/AuthContext.jsx"
click node_cart "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/context/CartContext.jsx"
click node_search "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/components/layout/SearchOverlay.jsx"
click node_api_client "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/api.js"
click node_student_pages "https://github.com/4007ayesha/grub-canteen/tree/dev/frontend/src/pages"
click node_admin_menu "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminMenu.jsx"
click node_admin_orders "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminOrders.jsx"
click node_admin_inventory "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminInventory.jsx"
click node_admin_analytics "https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminAnalytics.jsx"
click node_server "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/main.py"
click node_auth_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/auth.py"
click node_menu_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/menu.py"
click node_payment_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/payment.py"
click node_order_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/orders.py"
click node_feedback_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/feedback.py"
click node_notification_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/notifications.py"
click node_inventory_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/inventory.py"
click node_analytics_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/analytics.py"
click node_prediction_routes "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/predictions.py"
click node_auth_logic "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/auth.py"
click node_admin_guard "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/dependencies.py"
click node_websocket "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/websocket_manager.py"
click node_ml_model "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/ml_model.py"
click node_database "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/database.py"
click node_models "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/models.py"
click node_schemas "https://github.com/4007ayesha/grub-canteen/blob/dev/backend/schemas.py"

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_authui,node_cart,node_search,node_api_client,node_student_pages,node_admin_menu,node_admin_orders,node_admin_inventory,node_admin_analytics toneBlue
class node_server,node_auth_routes,node_menu_routes,node_payment_routes,node_order_routes,node_feedback_routes,node_notification_routes,node_inventory_routes,node_analytics_routes,node_prediction_routes,node_auth_logic,node_admin_guard toneAmber
class node_websocket,node_ml_model toneMint
class node_database,node_models,node_schemas toneRose
class node_student,node_admin toneIndigo
```

## Components

### React client

- [Route application](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth state](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Cart state](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/context/CartContext.jsx): `frontend/src/context/CartContext.jsx`
- [Search overlay](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/components/layout/SearchOverlay.jsx): `frontend/src/components/layout/SearchOverlay.jsx`
- [API client](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/api.js): `frontend/src/api.js`
- [Student pages](https://github.com/4007ayesha/grub-canteen/tree/dev/frontend/src/pages): `frontend/src/pages`
- [Menu administration](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminMenu.jsx): `frontend/src/pages/AdminMenu.jsx`
- [Order administration](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminOrders.jsx): `frontend/src/pages/AdminOrders.jsx`
- [Inventory administration](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminInventory.jsx): `frontend/src/pages/AdminInventory.jsx`
- [Analytics dashboard](https://github.com/4007ayesha/grub-canteen/blob/dev/frontend/src/pages/AdminAnalytics.jsx): `frontend/src/pages/AdminAnalytics.jsx`

### FastAPI services

- [API application](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/main.py): `backend/main.py`
- [Authentication routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/auth.py): `backend/routes/auth.py`
- [Menu routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/menu.py): `backend/routes/menu.py`
- [Payment routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/payment.py): `backend/routes/payment.py`
- [Order and tracking routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/orders.py): `backend/routes/orders.py`
- [Feedback routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/feedback.py): `backend/routes/feedback.py`
- [Notification routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/notifications.py): `backend/routes/notifications.py`
- [Inventory and waste routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/inventory.py): `backend/routes/inventory.py`
- [Analytics routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/analytics.py): `backend/routes/analytics.py`
- [Demand prediction routes](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/routes/predictions.py): `backend/routes/predictions.py`
- [Token and password logic](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/auth.py): `backend/auth.py`
- [Admin authorization](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/dependencies.py): `backend/dependencies.py`

### Canteen operations

- [Order update manager](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/websocket_manager.py): `backend/websocket_manager.py`
- [Prediction model](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/ml_model.py): `backend/ml_model.py`

### Data and prediction

- [Database session](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/database.py): `backend/database.py`
- [Domain records](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/models.py): `backend/models.py`
- [Request and response schemas](https://github.com/4007ayesha/grub-canteen/blob/dev/backend/schemas.py): `backend/schemas.py`

### Other components

- **Student**
- **Administrator**

## Connections

- Student → Route application: uses (evidence: `frontend/src/App.jsx`)
- Administrator → Route application: uses (evidence: `frontend/src/App.jsx`)
- Route application → Student pages: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Menu administration: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Order administration: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Inventory administration: routes to (evidence: `frontend/src/App.jsx`)
- Route application → Analytics dashboard: routes to (evidence: `frontend/src/App.jsx`)
- Auth state → API client: calls (evidence: `frontend/src/context/AuthContext.jsx`)
- Search overlay → API client: queries (evidence: `frontend/src/components/layout/SearchOverlay.jsx`)
- API application → Authentication routes: registers (evidence: `backend/main.py`)
- API application → Menu routes: registers (evidence: `backend/main.py`)
- API application → Payment routes: registers (evidence: `backend/main.py`)
- API application → Order and tracking routes: registers (evidence: `backend/main.py`)
- API application → Feedback routes: registers (evidence: `backend/main.py`)
- API application → Notification routes: registers (evidence: `backend/main.py`)
- API application → Inventory and waste routes: registers (evidence: `backend/main.py`)
- API application → Analytics routes: registers (evidence: `backend/main.py`)
- API application → Demand prediction routes: registers (evidence: `backend/main.py`)
- Authentication routes → Token and password logic: uses (evidence: `backend/routes/auth.py`)
- Admin authorization → Token and password logic: validates (evidence: `backend/dependencies.py`)
- Authentication routes → Database session: queries (evidence: `backend/routes/auth.py`)
- Authentication routes → Domain records: uses (evidence: `backend/routes/auth.py`)
- Authentication routes → Request and response schemas: validates (evidence: `backend/routes/auth.py`)
- Menu routes → Database session: queries (evidence: `backend/routes/menu.py`)
- Menu routes → Domain records: uses (evidence: `backend/routes/menu.py`)
- Menu routes → Request and response schemas: validates (evidence: `backend/routes/menu.py`)
- Payment routes → Database session: queries (evidence: `backend/routes/payment.py`)
- Payment routes → Domain records: uses (evidence: `backend/routes/payment.py`)
- Payment routes → Request and response schemas: validates (evidence: `backend/routes/payment.py`)
- Order and tracking routes → Database session: queries (evidence: `backend/routes/orders.py`)
- Order and tracking routes → Domain records: uses (evidence: `backend/routes/orders.py`)
- Order and tracking routes → Request and response schemas: validates (evidence: `backend/routes/orders.py`)
- Order and tracking routes → Order update manager: broadcasts (evidence: `backend/routes/orders.py`)
- Order and tracking routes → Notification routes: uses (evidence: `backend/routes/orders.py`)
- Feedback routes → Database session: queries (evidence: `backend/routes/feedback.py`)
- Feedback routes → Domain records: uses (evidence: `backend/routes/feedback.py`)
- Feedback routes → Request and response schemas: validates (evidence: `backend/routes/feedback.py`)
- Notification routes → Database session: queries (evidence: `backend/routes/notifications.py`)
- Notification routes → Domain records: uses (evidence: `backend/routes/notifications.py`)
- Notification routes → Request and response schemas: validates (evidence: `backend/routes/notifications.py`)
- Inventory and waste routes → Database session: queries (evidence: `backend/routes/inventory.py`)
- Inventory and waste routes → Domain records: uses (evidence: `backend/routes/inventory.py`)
- Inventory and waste routes → Request and response schemas: validates (evidence: `backend/routes/inventory.py`)
- Analytics routes → Database session: queries (evidence: `backend/routes/analytics.py`)
- Analytics routes → Domain records: uses (evidence: `backend/routes/analytics.py`)
- Demand prediction routes → Database session: queries (evidence: `backend/routes/predictions.py`)
- Demand prediction routes → Domain records: uses (evidence: `backend/routes/predictions.py`)
- Demand prediction routes → Request and response schemas: validates (evidence: `backend/routes/predictions.py`)
