# phakin-smt/tiramisu-pos architecture

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

- Interactive diagram: https://gitdiagram.com/phakin-smt/tiramisu-pos
- Repository: https://github.com/phakin-smt/tiramisu-pos

## Overview

Promttak-POS is a multi-store point-of-sale system: staff authenticate, select a store, browse a catalog, build a discounted cart, take cash or PromptPay payment, and record sales that affect stock and reporting. The primary interface is a React PWA; a legacy Vanilla JS interface shares the Flask API. The React app also supports offline sales and later synchronization. The graph preserves the documented inventory, order, reporting, analytics, and product-management branches. Some subsystem links rely on README descriptions because their implementation files were not sampled.

Main entry points: [`frontend/src/api/client.ts`](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/api/client.ts) (HTTP client), [`frontend/src/features/sell/SellPage.tsx`](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/SellPage.tsx) (Sell screen), [`backend/server.py`](https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/server.py) (Flask API), [`frontend/src/offline/offlineOrders.ts`](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/offlineOrders.ts) (Offline orders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React POS"]
  node_app["App entry<br/>[App.tsx]"]
  node_auth["PIN and session<br/>[AuthContext.tsx]"]
  node_stores["Store selection<br/>[StoreContext.tsx]"]
end

subgraph group_sales["Sales operations"]
  node_sell["Sell screen<br/>[SellPage.tsx]"]
  node_catalog["Catalog loading<br/>[useProducts.ts]"]
  node_checkout["Checkout<br/>[useCheckout.ts]"]
  node_orders["Order history<br/>[OrdersPage.tsx]"]
  node_stock["Stock control<br/>[StockPage.tsx]"]
  node_reports["Sales reports<br/>[ReportsPage.tsx]"]
  node_analytics["Sales analytics<br/>[AnalyticsPage.tsx]"]
  node_products["Product admin"]
end

subgraph group_offline["Offline capability"]
  node_offlineq[("Offline orders<br/>[offlineOrders.ts]")]
  node_localdb[("IndexedDB<br/>[database.ts]")]
  node_sync["Order sync"]
end

subgraph group_server["Flask services"]
  node_api["HTTP client<br/>[client.ts]"]
  node_legacy["Legacy interface<br/>[app.js]"]
  node_flask["Flask API<br/>[server.py]"]
  node_qr["PromptPay QR<br/>[promptpay_qr.py]"]
end

subgraph group_state["Persistent state"]
  node_db[("SQL database<br/>[database.py]")]
end

node_cashier(("Cashier"))

node_cashier -->|"uses"| node_app
node_app -->|"provides context"| node_auth
node_auth -->|"gates access"| node_stores
node_stores -->|"routes to"| node_sell
node_sell -->|"loads products"| node_catalog
node_sell -.->|"submits sale"| node_checkout
node_checkout -->|"sends checkout"| node_api
node_api -->|"requests API"| node_flask
node_flask -->|"reads and writes"| node_db
node_flask -->|"generates QR"| node_qr
node_sell -->|"queues offline"| node_offlineq
node_offlineq -->|"stores orders"| node_localdb
node_sync -->|"reads queue"| node_offlineq
node_sync -.->|"uploads orders"| node_api
node_orders -->|"loads orders"| node_api
node_stock -->|"loads stock"| node_api
node_reports -->|"loads reports"| node_api
node_analytics -.->|"loads analytics"| node_api
node_products -.->|"manages products"| node_api
node_legacy -->|"calls shared API"| node_flask

click node_app "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/app/App.tsx"
click node_auth "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/auth/AuthContext.tsx"
click node_stores "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/stores/StoreContext.tsx"
click node_sell "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/SellPage.tsx"
click node_catalog "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/useProducts.ts"
click node_checkout "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/useCheckout.ts"
click node_orders "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/orders/OrdersPage.tsx"
click node_stock "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/stock/StockPage.tsx"
click node_reports "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/reports/ReportsPage.tsx"
click node_analytics "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/analytics/AnalyticsPage.tsx"
click node_products "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/products-admin/ProductsAdminPage.tsx"
click node_offlineq "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/offlineOrders.ts"
click node_localdb "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/database.ts"
click node_sync "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/syncOfflineOrders.ts"
click node_api "https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/api/client.ts"
click node_legacy "https://github.com/phakin-smt/tiramisu-pos/blob/main/vanilla/app.js"
click node_flask "https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/server.py"
click node_qr "https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/promptpay_qr.py"
click node_db "https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/database.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_auth,node_stores toneBlue
class node_sell,node_catalog,node_checkout,node_orders,node_stock,node_reports,node_analytics,node_products toneAmber
class node_offlineq,node_localdb,node_sync toneMint
class node_api,node_legacy,node_flask,node_qr toneRose
class node_db,node_cashier toneIndigo
```

## Components

### React POS

- [App entry](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/app/App.tsx): `frontend/src/app/App.tsx`
- [PIN and session](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/auth/AuthContext.tsx): `frontend/src/features/auth/AuthContext.tsx`
- [Store selection](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/stores/StoreContext.tsx): `frontend/src/features/stores/StoreContext.tsx`

### Sales operations

- [Sell screen](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/SellPage.tsx): `frontend/src/features/sell/SellPage.tsx`
- [Catalog loading](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/useProducts.ts): `frontend/src/features/sell/useProducts.ts`
- [Checkout](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/sell/useCheckout.ts): `frontend/src/features/sell/useCheckout.ts`
- [Order history](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/orders/OrdersPage.tsx): `frontend/src/features/orders/OrdersPage.tsx`
- [Stock control](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/stock/StockPage.tsx): `frontend/src/features/stock/StockPage.tsx`
- [Sales reports](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/reports/ReportsPage.tsx): `frontend/src/features/reports/ReportsPage.tsx`
- [Sales analytics](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/analytics/AnalyticsPage.tsx): `frontend/src/features/analytics/AnalyticsPage.tsx`
- [Product admin](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/features/products-admin/ProductsAdminPage.tsx): `frontend/src/features/products-admin/ProductsAdminPage.tsx`

### Offline capability

- [Offline orders](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/offlineOrders.ts): `frontend/src/offline/offlineOrders.ts`
- [IndexedDB](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/database.ts): `frontend/src/offline/database.ts`
- [Order sync](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/offline/syncOfflineOrders.ts): `frontend/src/offline/syncOfflineOrders.ts`

### Flask services

- [HTTP client](https://github.com/phakin-smt/tiramisu-pos/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Legacy interface](https://github.com/phakin-smt/tiramisu-pos/blob/main/vanilla/app.js): `vanilla/app.js`
- [Flask API](https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/server.py): `backend/server.py`
- [PromptPay QR](https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/promptpay_qr.py): `backend/promptpay_qr.py`

### Persistent state

- [SQL database](https://github.com/phakin-smt/tiramisu-pos/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Cashier**

## Connections

- Cashier → App entry: uses
- App entry → PIN and session: provides context (evidence: `frontend/src/app/App.tsx`)
- PIN and session → Store selection: gates access (evidence: `frontend/src/app/router.tsx`)
- Store selection → Sell screen: routes to (evidence: `frontend/src/app/router.tsx`)
- Sell screen → Catalog loading: loads products (evidence: `frontend/src/features/sell/useProducts.ts`)
- Sell screen → Checkout: submits sale
- Checkout → HTTP client: sends checkout (evidence: `frontend/src/features/sell/useCheckout.ts`)
- HTTP client → Flask API: requests API
- Flask API → SQL database: reads and writes (evidence: `backend/server.py`)
- Flask API → PromptPay QR: generates QR (evidence: `backend/server.py`)
- Sell screen → Offline orders: queues offline
- Offline orders → IndexedDB: stores orders (evidence: `frontend/src/offline/offlineOrders.ts`)
- Order sync → Offline orders: reads queue (evidence: `frontend/src/offline/offlineOrders.ts`)
- Order sync → HTTP client: uploads orders
- Order history → HTTP client: loads orders
- Stock control → HTTP client: loads stock
- Sales reports → HTTP client: loads reports
- Sales analytics → HTTP client: loads analytics
- Product admin → HTTP client: manages products
- Legacy interface → Flask API: calls shared API
