# team3c4gt/smart_mess_kiet architecture

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

- Interactive diagram: https://gitdiagram.com/team3c4gt/smart_mess_kiet
- Repository: https://github.com/team3c4gt/smart_mess_kiet

## Overview

Smart Mess & KFC Express is a campus dining operations platform: students submit meal choices or KFC orders, which staff dashboards use for roster verification, attendance aggregation, kitchen planning, and order fulfillment; leadership gets campus analytics. The frontend routes role dashboards and centralizes shared state/API access. Backend REST controllers provide dining, identity, aggregation, forecasting, and canteen operations, backed by MongoDB with seeded in-memory fallback. README documents cross-tab synchronization and an optional Python forecasting service. Some subsystem details are documented but their implementation was not sampled, so those branches have only documented links.

Main entry points: [`frontend/src/App.jsx`](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/App.jsx) (Route and access guard), [`frontend/src/context/AppContext.jsx`](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/context/AppContext.jsx) (Shared app state), [`frontend/src/pages/StudentDashboard.jsx`](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/StudentDashboard.jsx) (Student portal), [`backend/src/controllers/apiControllers.js`](https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/controllers/apiControllers.js) (API operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Campus portals"]
  node_student["Student portal"]
  node_roomlead["Room lead"]
  node_floor["Floor incharge"]
  node_block["Block coordinator"]
  node_mess["Mess incharge"]
  node_kfcstaff["KFC staff"]
  node_principal["Principal"]
  node_switchboard["Admin switchboard<br/>[MainDashboards.jsx]"]
  node_login["Login<br/>[LoginPage.jsx]"]
  node_app["Route and access guard<br/>[App.jsx]"]
  node_state["Shared app state<br/>[AppContext.jsx]"]
  node_sync["Cross-tab sync<br/>[AppContext.jsx]"]
end

subgraph group_operations["Dining operations"]
  node_headcount["Headcount and batch planning"]
  node_kitchen["Meal production"]
  node_orders["KFC order fulfillment"]
  node_analytics["Campus analytics"]
end

subgraph group_service["API and data"]
  node_api["REST routes<br/>[apiRoutes.js]"]
  node_controllers["API operations<br/>[apiControllers.js]"]
  node_models["Dining data models<br/>[Schemas.js]"]
  node_mongo[("MongoDB")]
  node_seed["Seed records<br/>[Seeder.js]"]
end

subgraph group_intelligence["Forecasting"]
  node_pythonai["Python AI service<br/>[main.py]"]
end

node_resident(("Student"))
node_staff(("Dining staff"))
node_leadership(("Campus leadership"))

node_resident -->|"opens portal"| node_app
node_app -->|"routes to"| node_login
node_app -->|"guards and routes"| node_student
node_app -->|"guards and routes"| node_roomlead
node_app -->|"guards and routes"| node_floor
node_app -->|"guards and routes"| node_block
node_app -->|"guards and routes"| node_mess
node_app -->|"guards and routes"| node_kfcstaff
node_app -->|"guards and routes"| node_principal
node_app -->|"routes to"| node_switchboard
node_student -->|"uses shared state"| node_state
node_roomlead -->|"uses shared state"| node_state
node_floor -.->|"uses shared state"| node_state
node_block -.->|"uses shared state"| node_state
node_mess -.->|"uses shared state"| node_state
node_kfcstaff -.->|"uses shared state"| node_state
node_principal -.->|"uses shared state"| node_state
node_state -->|"fetches API"| node_api
node_state -->|"broadcasts changes"| node_sync
node_staff -.->|"verifies meal roster"| node_roomlead
node_staff -.->|"tracks attendance"| node_floor
node_staff -.->|"transmits meal counts"| node_block
node_staff -.->|"plans production"| node_mess
node_staff -.->|"fulfills orders"| node_kfcstaff
node_leadership -.->|"reviews analytics"| node_principal
node_student -.->|"submits meal choices"| node_headcount
node_headcount -.->|"sizes ingredient batches"| node_kitchen
node_student -.->|"places KFC order"| node_orders
node_api -->|"dispatches"| node_controllers
node_controllers -->|"queries and updates"| node_models
node_controllers -->|"runs seeder"| node_seed
node_seed -->|"uses schemas"| node_models
node_models -.->|"persists records"| node_mongo
node_controllers -.->|"serves forecasts"| node_headcount
node_pythonai -.->|"optional forecast service"| node_headcount

click node_student "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/StudentDashboard.jsx"
click node_roomlead "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/RoomLeadDashboard.jsx"
click node_floor "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/FloorInchargeDashboard.jsx"
click node_block "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/BlockCoordinatorDashboard.jsx"
click node_mess "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MessInchargeDashboard.jsx"
click node_kfcstaff "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/KfcStaffDashboard.jsx"
click node_principal "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/PrincipalDashboard.jsx"
click node_switchboard "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MainDashboards.jsx"
click node_login "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/LoginPage.jsx"
click node_app "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/App.jsx"
click node_state "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/context/AppContext.jsx"
click node_sync "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/context/AppContext.jsx"
click node_api "https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/routes/apiRoutes.js"
click node_controllers "https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/controllers/apiControllers.js"
click node_models "https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/models/Schemas.js"
click node_seed "https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/Seeder.js"
click node_headcount "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MessInchargeDashboard.jsx"
click node_kitchen "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MessInchargeDashboard.jsx"
click node_orders "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/KfcStaffDashboard.jsx"
click node_analytics "https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/PrincipalDashboard.jsx"
click node_pythonai "https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/ai-service/main.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_student,node_roomlead,node_floor,node_block,node_mess,node_kfcstaff,node_principal,node_switchboard,node_login,node_app,node_state,node_sync toneBlue
class node_headcount,node_kitchen,node_orders,node_analytics toneAmber
class node_api,node_controllers,node_models,node_mongo,node_seed toneMint
class node_pythonai toneRose
class node_resident,node_staff,node_leadership toneIndigo
```

## Components

### Campus portals

- [Student portal](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/StudentDashboard.jsx): `frontend/src/pages/StudentDashboard.jsx`
- [Room lead](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/RoomLeadDashboard.jsx): `frontend/src/pages/RoomLeadDashboard.jsx`
- [Floor incharge](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/FloorInchargeDashboard.jsx): `frontend/src/pages/FloorInchargeDashboard.jsx`
- [Block coordinator](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/BlockCoordinatorDashboard.jsx): `frontend/src/pages/BlockCoordinatorDashboard.jsx`
- [Mess incharge](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MessInchargeDashboard.jsx): `frontend/src/pages/MessInchargeDashboard.jsx`
- [KFC staff](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/KfcStaffDashboard.jsx): `frontend/src/pages/KfcStaffDashboard.jsx`
- [Principal](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/PrincipalDashboard.jsx): `frontend/src/pages/PrincipalDashboard.jsx`
- [Admin switchboard](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MainDashboards.jsx): `frontend/src/pages/MainDashboards.jsx`
- [Login](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Route and access guard](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Shared app state](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/context/AppContext.jsx): `frontend/src/context/AppContext.jsx`
- [Cross-tab sync](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/context/AppContext.jsx): `frontend/src/context/AppContext.jsx`

### Dining operations

- [Headcount and batch planning](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MessInchargeDashboard.jsx): `frontend/src/pages/MessInchargeDashboard.jsx`
- [Meal production](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/MessInchargeDashboard.jsx): `frontend/src/pages/MessInchargeDashboard.jsx`
- [KFC order fulfillment](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/KfcStaffDashboard.jsx): `frontend/src/pages/KfcStaffDashboard.jsx`
- [Campus analytics](https://github.com/team3c4gt/smart_mess_kiet/blob/main/frontend/src/pages/PrincipalDashboard.jsx): `frontend/src/pages/PrincipalDashboard.jsx`

### API and data

- [REST routes](https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/routes/apiRoutes.js): `backend/src/routes/apiRoutes.js`
- [API operations](https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/controllers/apiControllers.js): `backend/src/controllers/apiControllers.js`
- [Dining data models](https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/models/Schemas.js): `backend/src/models/Schemas.js`
- **MongoDB**
- [Seed records](https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/src/Seeder.js): `backend/src/Seeder.js`

### Forecasting

- [Python AI service](https://github.com/team3c4gt/smart_mess_kiet/blob/main/backend/ai-service/main.py): `backend/ai-service/main.py`

### Other components

- **Student**
- **Dining staff**
- **Campus leadership**

## Connections

- Student → Route and access guard: opens portal (evidence: `frontend/src/App.jsx`)
- Route and access guard → Login: routes to (evidence: `frontend/src/App.jsx`)
- Route and access guard → Student portal: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → Room lead: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → Floor incharge: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → Block coordinator: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → Mess incharge: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → KFC staff: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → Principal: guards and routes (evidence: `frontend/src/App.jsx`)
- Route and access guard → Admin switchboard: routes to (evidence: `frontend/src/App.jsx`)
- Student portal → Shared app state: uses shared state (evidence: `frontend/src/context/AppContext.jsx`)
- Room lead → Shared app state: uses shared state (evidence: `frontend/src/pages/RoomLeadDashboard.jsx`)
- Floor incharge → Shared app state: uses shared state (evidence: `frontend/src/pages/FloorInchargeDashboard.jsx`)
- Block coordinator → Shared app state: uses shared state (evidence: `frontend/src/pages/BlockCoordinatorDashboard.jsx`)
- Mess incharge → Shared app state: uses shared state (evidence: `frontend/src/pages/MessInchargeDashboard.jsx`)
- KFC staff → Shared app state: uses shared state (evidence: `frontend/src/pages/KfcStaffDashboard.jsx`)
- Principal → Shared app state: uses shared state (evidence: `frontend/src/pages/PrincipalDashboard.jsx`)
- Shared app state → REST routes: fetches API (evidence: `frontend/src/context/AppContext.jsx`)
- Shared app state → Cross-tab sync: broadcasts changes (evidence: `README.md`)
- Dining staff → Room lead: verifies meal roster (evidence: `README.md`)
- Dining staff → Floor incharge: tracks attendance (evidence: `README.md`)
- Dining staff → Block coordinator: transmits meal counts (evidence: `README.md`)
- Dining staff → Mess incharge: plans production (evidence: `README.md`)
- Dining staff → KFC staff: fulfills orders (evidence: `README.md`)
- Campus leadership → Principal: reviews analytics (evidence: `README.md`)
- Student portal → Headcount and batch planning: submits meal choices (evidence: `README.md`)
- Headcount and batch planning → Meal production: sizes ingredient batches (evidence: `README.md`)
- Student portal → KFC order fulfillment: places KFC order (evidence: `README.md`)
- REST routes → API operations: dispatches (evidence: `backend/src/routes/apiRoutes.js`)
- API operations → Dining data models: queries and updates (evidence: `backend/src/controllers/apiControllers.js`)
- API operations → Seed records: runs seeder (evidence: `backend/src/controllers/apiControllers.js`)
- Seed records → Dining data models: uses schemas (evidence: `backend/src/Seeder.js`)
- Dining data models → MongoDB: persists records
- API operations → Headcount and batch planning: serves forecasts (evidence: `README.md`)
- Python AI service → Headcount and batch planning: optional forecast service (evidence: `README.md`)
