# qthai-06/smartcaffe architecture

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

- Interactive diagram: https://gitdiagram.com/qthai-06/smartcaffe
- Repository: https://github.com/qthai-06/smartcaffe

## Overview

SmartCafe AI is a Streamlit café-inventory application: staff sign in, inspect stock or submit a photo, review and adjust AI-detected counts, then save an inventory snapshot. The dashboard also exposes inventory history, audit records, and an advisor that estimates replenishment needs from recent snapshots. The main control and persistence relationships are visible in the excerpts and README; the advisor’s forecast calculation is implemented in its page, while the separate forecast module is only a stub. Some dashboard details are omitted from the sampled app excerpt.

Main entry points: [`smartcafe_ai/app.py`](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/app.py) (Streamlit dashboard), [`smartcafe_ai/src/database.py`](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/database.py) (Inventory persistence), [`smartcafe_ai/ui/page_inventory.py`](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/page_inventory.py) (Inventory page), [`smartcafe_ai/ui/page_advisor.py`](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/page_advisor.py) (Replenishment advisor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_app["Streamlit dashboard<br/>[app.py]"]
  node_auth["Login authentication<br/>[auth.py]"]
end

subgraph group_inventory["Inventory workflow"]
  node_inventory_page["Inventory page<br/>[page_inventory.py]"]
  node_vision["YOLO recognition<br/>[vision.py]"]
end

subgraph group_insights["History and advice"]
  node_advisor["Replenishment advisor<br/>[page_advisor.py]"]
  node_ui_components["Reusable UI components<br/>[components.py]"]
end

subgraph group_persistence["Persistence"]
  node_database["Inventory persistence<br/>[database.py]"]
  node_sqlite[("SQLite inventory store")]
  node_csv["CSV inventory file<br/>[inventory.csv]"]
end

node_staff(("Cafe staff"))

node_staff -->|"uses"| node_app
node_app -->|"authenticates"| node_auth
node_app -->|"loads and saves"| node_database
node_app -->|"routes to"| node_inventory_page
node_app -->|"routes to"| node_advisor
node_inventory_page -->|"processes image"| node_vision
node_inventory_page -->|"reads and saves"| node_database
node_advisor -->|"reads history"| node_database
node_advisor -->|"renders metrics"| node_ui_components
node_database -->|"reads and writes"| node_sqlite
node_database -->|"migrates and exports"| node_csv

click node_app "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/app.py"
click node_auth "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/auth.py"
click node_inventory_page "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/page_inventory.py"
click node_vision "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/vision.py"
click node_advisor "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/page_advisor.py"
click node_ui_components "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/components.py"
click node_database "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/database.py"
click node_sqlite "https://github.com/qthai-06/smartcaffe/tree/main/smartcafe_ai/data/db"
click node_csv "https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/data/inventory.csv"

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_auth toneBlue
class node_inventory_page,node_vision toneAmber
class node_advisor,node_ui_components toneMint
class node_database,node_sqlite,node_csv toneRose
class node_staff toneIndigo
```

## Components

### Application

- [Streamlit dashboard](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/app.py): `smartcafe_ai/app.py`
- [Login authentication](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/auth.py): `smartcafe_ai/src/auth.py`

### Inventory workflow

- [Inventory page](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/page_inventory.py): `smartcafe_ai/ui/page_inventory.py`
- [YOLO recognition](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/vision.py): `smartcafe_ai/src/vision.py`

### History and advice

- [Replenishment advisor](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/page_advisor.py): `smartcafe_ai/ui/page_advisor.py`
- [Reusable UI components](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/ui/components.py): `smartcafe_ai/ui/components.py`

### Persistence

- [Inventory persistence](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/src/database.py): `smartcafe_ai/src/database.py`
- [SQLite inventory store](https://github.com/qthai-06/smartcaffe/tree/main/smartcafe_ai/data/db): `smartcafe_ai/data/db`
- [CSV inventory file](https://github.com/qthai-06/smartcaffe/blob/main/smartcafe_ai/data/inventory.csv): `smartcafe_ai/data/inventory.csv`

### Other components

- **Cafe staff**

## Connections

- Cafe staff → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → Login authentication: authenticates (evidence: `smartcafe_ai/app.py`)
- Streamlit dashboard → Inventory persistence: loads and saves (evidence: `smartcafe_ai/app.py`)
- Streamlit dashboard → Inventory page: routes to (evidence: `smartcafe_ai/app.py`)
- Streamlit dashboard → Replenishment advisor: routes to (evidence: `smartcafe_ai/app.py`)
- Inventory page → YOLO recognition: processes image (evidence: `smartcafe_ai/ui/page_inventory.py`)
- Inventory page → Inventory persistence: reads and saves (evidence: `smartcafe_ai/ui/page_inventory.py`)
- Replenishment advisor → Inventory persistence: reads history (evidence: `smartcafe_ai/ui/page_advisor.py`)
- Replenishment advisor → Reusable UI components: renders metrics (evidence: `smartcafe_ai/ui/page_advisor.py`)
- Inventory persistence → SQLite inventory store: reads and writes (evidence: `smartcafe_ai/src/database.py`)
- Inventory persistence → CSV inventory file: migrates and exports (evidence: `smartcafe_ai/src/database.py`)
