# sahria-dev/the-cantine architecture

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

- Interactive diagram: https://gitdiagram.com/sahria-dev/the-cantine
- Repository: https://github.com/sahria-dev/the-cantine

## Overview

The Canteen is a Flask app for campus meal reservations, account management, and balance recharges. Users register or log in, then reserve or cancel meal dates, recharge their balance, update their email, and review past reserved dates counted as meals eaten. The main backend routes are in `app.py`; browser interactions are split across page-specific JavaScript modules. The README describes SQLite/SQLAlchemy persistence, but the database file and templates are not in the supplied tree. Backend excerpts are partial, so only documented or evidenced connections are shown.

Main entry points: [`app.py`](https://github.com/sahria-dev/the-cantine/blob/master/app.py) (Authentication and routes), [`models.py`](https://github.com/sahria-dev/the-cantine/blob/master/models.py) (ORM models), [`static/js/login.js`](https://github.com/sahria-dev/the-cantine/blob/master/static/js/login.js) (Login interaction), [`static/js/registration.js`](https://github.com/sahria-dev/the-cantine/blob/master/static/js/registration.js) (Registration interaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Account access"]
  node_login["Login interaction<br/>[login.js]"]
  node_registration["Registration interaction<br/>[registration.js]"]
end

subgraph group_meals["Meal reservations"]
  node_reservation_ui["Reservation calendar<br/>[reservation.js]"]
  node_reservation_util["Reservation requests"]
  node_history_ui["Meal history<br/>[history.js]"]
end

subgraph group_account["Account services"]
  node_payment_ui["Balance recharge<br/>[payment.js]"]
  node_profile_ui["Personal information<br/>[personal_info.js]"]
end

subgraph group_backend["Backend and persistence"]
  node_auth["Authentication and routes<br/>[app.py]"]
  node_guard["Login guard<br/>[helpers.py]"]
  node_models["ORM models<br/>[models.py]"]
  node_store[("SQLite database")]
end

node_user(("Canteen user"))

node_user -->|"submits credentials"| node_login
node_user -->|"provides details"| node_registration
node_login -->|"sends credentials"| node_auth
node_registration -->|"sends registration"| node_auth
node_auth -->|"uses access guard"| node_guard
node_auth -->|"queries and updates"| node_models
node_models -->|"persists records"| node_store
node_user -->|"chooses meal dates"| node_reservation_ui
node_reservation_ui -->|"requests date data"| node_reservation_util
node_reservation_util -->|"calls reservation routes"| node_auth
node_auth -->|"stores reservations"| node_models
node_user -->|"views meal history"| node_history_ui
node_history_ui -->|"requests history"| node_auth
node_user -->|"enters recharge code"| node_payment_ui
node_payment_ui -->|"submits code"| node_auth
node_user -->|"edits email"| node_profile_ui
node_profile_ui -->|"submits profile change"| node_auth

click node_login "https://github.com/sahria-dev/the-cantine/blob/master/static/js/login.js"
click node_registration "https://github.com/sahria-dev/the-cantine/blob/master/static/js/registration.js"
click node_auth "https://github.com/sahria-dev/the-cantine/blob/master/app.py"
click node_guard "https://github.com/sahria-dev/the-cantine/blob/master/helpers.py"
click node_reservation_ui "https://github.com/sahria-dev/the-cantine/blob/master/static/js/reservation.js"
click node_reservation_util "https://github.com/sahria-dev/the-cantine/blob/master/static/js/reservation_util.js"
click node_history_ui "https://github.com/sahria-dev/the-cantine/blob/master/static/js/history.js"
click node_payment_ui "https://github.com/sahria-dev/the-cantine/blob/master/static/js/payment.js"
click node_profile_ui "https://github.com/sahria-dev/the-cantine/blob/master/static/js/personal_info.js"
click node_models "https://github.com/sahria-dev/the-cantine/blob/master/models.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_login,node_registration,node_user toneBlue
class node_reservation_ui,node_reservation_util,node_history_ui toneAmber
class node_payment_ui,node_profile_ui toneMint
class node_auth,node_guard,node_models,node_store toneRose
```

## Components

### Account access

- [Login interaction](https://github.com/sahria-dev/the-cantine/blob/master/static/js/login.js): `static/js/login.js`
- [Registration interaction](https://github.com/sahria-dev/the-cantine/blob/master/static/js/registration.js): `static/js/registration.js`

### Meal reservations

- [Reservation calendar](https://github.com/sahria-dev/the-cantine/blob/master/static/js/reservation.js): `static/js/reservation.js`
- [Reservation requests](https://github.com/sahria-dev/the-cantine/blob/master/static/js/reservation_util.js): `static/js/reservation_util.js`
- [Meal history](https://github.com/sahria-dev/the-cantine/blob/master/static/js/history.js): `static/js/history.js`

### Account services

- [Balance recharge](https://github.com/sahria-dev/the-cantine/blob/master/static/js/payment.js): `static/js/payment.js`
- [Personal information](https://github.com/sahria-dev/the-cantine/blob/master/static/js/personal_info.js): `static/js/personal_info.js`

### Backend and persistence

- [Authentication and routes](https://github.com/sahria-dev/the-cantine/blob/master/app.py): `app.py`
- [Login guard](https://github.com/sahria-dev/the-cantine/blob/master/helpers.py): `helpers.py`
- [ORM models](https://github.com/sahria-dev/the-cantine/blob/master/models.py): `models.py`
- **SQLite database**

### Other components

- **Canteen user**

## Connections

- Canteen user → Login interaction: submits credentials
- Canteen user → Registration interaction: provides details
- Login interaction → Authentication and routes: sends credentials
- Registration interaction → Authentication and routes: sends registration
- Authentication and routes → Login guard: uses access guard
- Authentication and routes → ORM models: queries and updates
- ORM models → SQLite database: persists records
- Canteen user → Reservation calendar: chooses meal dates
- Reservation calendar → Reservation requests: requests date data
- Reservation requests → Authentication and routes: calls reservation routes
- Authentication and routes → ORM models: stores reservations
- Canteen user → Meal history: views meal history
- Meal history → Authentication and routes: requests history
- Canteen user → Balance recharge: enters recharge code
- Balance recharge → Authentication and routes: submits code
- Canteen user → Personal information: edits email
- Personal information → Authentication and routes: submits profile change
