# tiagosamaha/dlunch architecture

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

- Interactive diagram: https://gitdiagram.com/tiagosamaha/dlunch
- Repository: https://github.com/tiagosamaha/dlunch

## Overview

dlunch is a Django cafeteria-meal entitlement system. A client can look up a student or balance, authenticate a meal deduction, and receive a forbidden response when the student is unknown, has already eaten that day, or has no remaining meals; fingerprint updates are also exposed. Staff can manage students and meal allocations through Django admin and generate date-range meal reports. The model layer stores students, meal records, monthly student balances, and group allocations. Source excerpts show API, reporting, and model calls; some broader Django wiring is not sampled.

Main entry points: [`dlunch/models.py`](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/models.py) (Meal Records And Balances), [`dlunch/admin_views.py`](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/admin_views.py) (Meal Report), [`api/urls.py`](https://github.com/tiagosamaha/dlunch/blob/master/api/urls.py) (API Routes), [`api/handlers.py`](https://github.com/tiagosamaha/dlunch/blob/master/api/handlers.py) (API Handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Client API"]
  node_api_routes["API Routes<br/>[urls.py]"]
  node_api_handlers["API Handlers<br/>[handlers.py]"]
end

subgraph group_domain["Meal Domain"]
  node_meal_domain["Meal Records And Balances<br/>[models.py]"]
  node_binary_field["Fingerprint Field<br/>[fieldtypes.py]"]
end

subgraph group_staff["Staff Operations"]
  node_admin_ui["Admin Management<br/>[admin.py]"]
  node_report_view["Meal Report<br/>[admin_views.py]"]
  node_report_form["Report Form<br/>[forms.py]"]
  node_report_template["Report Template<br/>[relatorio.html]"]
end

subgraph group_runtime["Django Runtime"]
  node_runtime_config["Django Configuration<br/>[settings.py]"]
end

node_client(("API Client"))
node_staff_user(("Staff User"))
node_database[("SQLite Database")]

node_client -->|"requests"| node_api_routes
node_api_routes -->|"dispatches"| node_api_handlers
node_api_handlers -->|"reads and updates"| node_meal_domain
node_admin_ui -->|"registers models"| node_meal_domain
node_report_view -->|"validates report"| node_report_form
node_report_form -->|"counts meals"| node_meal_domain
node_report_view -->|"renders"| node_report_template
node_meal_domain -->|"uses field"| node_binary_field
node_runtime_config -->|"configures"| node_database

click node_api_routes "https://github.com/tiagosamaha/dlunch/blob/master/api/urls.py"
click node_api_handlers "https://github.com/tiagosamaha/dlunch/blob/master/api/handlers.py"
click node_meal_domain "https://github.com/tiagosamaha/dlunch/blob/master/dlunch/models.py"
click node_binary_field "https://github.com/tiagosamaha/dlunch/blob/master/dlunch/fieldtypes.py"
click node_admin_ui "https://github.com/tiagosamaha/dlunch/blob/master/dlunch/admin.py"
click node_report_view "https://github.com/tiagosamaha/dlunch/blob/master/dlunch/admin_views.py"
click node_report_form "https://github.com/tiagosamaha/dlunch/blob/master/dlunch/forms.py"
click node_report_template "https://github.com/tiagosamaha/dlunch/blob/master/dlunch/templates/admin/dlunch/relatorio.html"
click node_runtime_config "https://github.com/tiagosamaha/dlunch/blob/master/settings.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_api_routes,node_api_handlers,node_client,node_staff_user toneBlue
class node_meal_domain,node_binary_field,node_database toneAmber
class node_admin_ui,node_report_view,node_report_form,node_report_template toneMint
class node_runtime_config toneRose
```

## Components

### Client API

- [API Routes](https://github.com/tiagosamaha/dlunch/blob/master/api/urls.py): `api/urls.py`
- [API Handlers](https://github.com/tiagosamaha/dlunch/blob/master/api/handlers.py): `api/handlers.py`

### Meal Domain

- [Meal Records And Balances](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/models.py): `dlunch/models.py`
- [Fingerprint Field](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/fieldtypes.py): `dlunch/fieldtypes.py`

### Staff Operations

- [Admin Management](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/admin.py): `dlunch/admin.py`
- [Meal Report](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/admin_views.py): `dlunch/admin_views.py`
- [Report Form](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/forms.py): `dlunch/forms.py`
- [Report Template](https://github.com/tiagosamaha/dlunch/blob/master/dlunch/templates/admin/dlunch/relatorio.html): `dlunch/templates/admin/dlunch/relatorio.html`

### Django Runtime

- [Django Configuration](https://github.com/tiagosamaha/dlunch/blob/master/settings.py): `settings.py`

### Other components

- **API Client**
- **Staff User**
- **SQLite Database**

## Connections

- API Client → API Routes: requests (evidence: `api/urls.py`)
- API Routes → API Handlers: dispatches (evidence: `api/urls.py`)
- API Handlers → Meal Records And Balances: reads and updates (evidence: `api/handlers.py`)
- Admin Management → Meal Records And Balances: registers models (evidence: `dlunch/admin.py`)
- Meal Report → Report Form: validates report (evidence: `dlunch/admin_views.py`)
- Report Form → Meal Records And Balances: counts meals (evidence: `dlunch/forms.py`)
- Meal Report → Report Template: renders (evidence: `dlunch/admin_views.py`)
- Meal Records And Balances → Fingerprint Field: uses field (evidence: `dlunch/models.py`)
- Django Configuration → SQLite Database: configures (evidence: `settings.py`)
