# dia-312/pos-1 architecture

> Architecture diagram of the GitHub repository dia-312/pos-1, 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/dia-312/pos-1
- Repository: https://github.com/dia-312/pos-1

## Overview

This is a local-first POS application for cafés and small businesses. The user workflow enters through routed login or sales screens; in the cashier flow, staff select products, build a cart, confirm checkout, record a sale and reduce stock, with receipt printing available afterward. Separate screens cover product, order, expense, user, dashboard and report management, while settings and theme state support the application. The database and backup paths are evident, but unsampled page and helper implementations limit claims about their internal wiring.

Main entry points: [`src/routes/AppRoutes.tsx`](https://github.com/dia-312/pos-1/blob/master/src/routes/AppRoutes.tsx) (Route dispatch), [`src/pages/Cashier.tsx`](https://github.com/dia-312/pos-1/blob/master/src/pages/Cashier.tsx) (Cashier checkout), [`src/lib/database.ts`](https://github.com/dia-312/pos-1/blob/master/src/lib/database.ts) (SQLite data layer), [`src/App.tsx`](https://github.com/dia-312/pos-1/blob/master/src/App.tsx) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application shell"]
  node_app["App shell<br/>[App.tsx]"]
  node_routes["Route dispatch<br/>[AppRoutes.tsx]"]
  node_protected["Protected routes<br/>[ProtectedRoute.tsx]"]
  node_admin["Admin routes<br/>[AdminRoute.tsx]"]
  node_login["Login<br/>[Login.tsx]"]
  node_auth["Auth state<br/>[useAuthStore.ts]"]
  node_settings["Settings<br/>[Settings.tsx]"]
  node_theme["Theme state<br/>[useThemeStore.ts]"]
  node_about["About page<br/>[About.tsx]"]
end

subgraph group_sales["Sales workflow"]
  node_cashier["Cashier checkout<br/>[Cashier.tsx]"]
  node_cart["Cart state<br/>[useCartStore.ts]"]
  node_checkout["Checkout dialog<br/>[CheckoutModal.tsx]"]
  node_receipt["Receipt formatting<br/>[html.ts]"]
end

subgraph group_operations["Business operations"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_dashstate["Dashboard state"]
  node_products["Product management<br/>[Products.tsx]"]
  node_orders["Order management<br/>[Orders.tsx]"]
  node_expenses["Expense tracking<br/>[Expenses.tsx]"]
  node_reports["Reports and exports<br/>[Reports.tsx]"]
  node_users["User management<br/>[Users.tsx]"]
end

subgraph group_platform["Local data platform"]
  node_backup["Automatic backup<br/>[backup.ts]"]
  node_database[("SQLite data layer<br/>[database.ts]")]
  node_crypto["Secret hashing<br/>[crypto.ts]"]
  node_tauri["Tauri desktop host<br/>[main.rs]"]
end

node_staff(("Staff or admin"))

node_staff -->|"navigates"| node_routes
node_routes -->|"dispatches"| node_login
node_routes -->|"guards"| node_protected
node_routes -->|"guards"| node_admin
node_routes -->|"dispatches"| node_cashier
node_routes -->|"dispatches"| node_products
node_routes -->|"dispatches"| node_orders
node_routes -->|"dispatches"| node_expenses
node_routes -->|"dispatches"| node_dashboard
node_routes -->|"dispatches"| node_reports
node_routes -->|"dispatches"| node_users
node_routes -->|"dispatches"| node_settings
node_routes -->|"dispatches"| node_about
node_app -->|"renders"| node_routes
node_app -->|"initializes"| node_database
node_app -->|"starts"| node_backup
node_app -->|"initializes"| node_theme
node_cashier -->|"reads products"| node_database
node_cashier -->|"updates"| node_cart
node_cashier -->|"opens"| node_checkout
node_checkout -->|"confirms"| node_cashier
node_cashier -->|"records sale"| node_database
node_cashier -->|"reduces stock"| node_database
node_cashier -->|"formats receipt"| node_receipt
node_dashboard -->|"displays"| node_dashstate
node_dashstate -->|"loads statistics"| node_database
node_database -->|"hashes credentials"| node_crypto
node_tauri -->|"hosts SQLite access"| node_database

click node_app "https://github.com/dia-312/pos-1/blob/master/src/App.tsx"
click node_routes "https://github.com/dia-312/pos-1/blob/master/src/routes/AppRoutes.tsx"
click node_protected "https://github.com/dia-312/pos-1/blob/master/src/routes/ProtectedRoute.tsx"
click node_admin "https://github.com/dia-312/pos-1/blob/master/src/routes/AdminRoute.tsx"
click node_login "https://github.com/dia-312/pos-1/blob/master/src/pages/Login.tsx"
click node_auth "https://github.com/dia-312/pos-1/blob/master/src/store/useAuthStore.ts"
click node_settings "https://github.com/dia-312/pos-1/blob/master/src/pages/Settings.tsx"
click node_theme "https://github.com/dia-312/pos-1/blob/master/src/store/useThemeStore.ts"
click node_backup "https://github.com/dia-312/pos-1/blob/master/src/lib/backup.ts"
click node_cashier "https://github.com/dia-312/pos-1/blob/master/src/pages/Cashier.tsx"
click node_cart "https://github.com/dia-312/pos-1/blob/master/src/store/useCartStore.ts"
click node_checkout "https://github.com/dia-312/pos-1/blob/master/src/components/ui/CheckoutModal.tsx"
click node_receipt "https://github.com/dia-312/pos-1/blob/master/src/lib/html.ts"
click node_dashboard "https://github.com/dia-312/pos-1/blob/master/src/pages/Dashboard.tsx"
click node_dashstate "https://github.com/dia-312/pos-1/blob/master/src/store/useDashboardStore.ts"
click node_products "https://github.com/dia-312/pos-1/blob/master/src/pages/Products.tsx"
click node_orders "https://github.com/dia-312/pos-1/blob/master/src/pages/Orders.tsx"
click node_expenses "https://github.com/dia-312/pos-1/blob/master/src/pages/Expenses.tsx"
click node_reports "https://github.com/dia-312/pos-1/blob/master/src/pages/Reports.tsx"
click node_users "https://github.com/dia-312/pos-1/blob/master/src/pages/Users.tsx"
click node_about "https://github.com/dia-312/pos-1/blob/master/src/pages/About.tsx"
click node_database "https://github.com/dia-312/pos-1/blob/master/src/lib/database.ts"
click node_crypto "https://github.com/dia-312/pos-1/blob/master/src/lib/crypto.ts"
click node_tauri "https://github.com/dia-312/pos-1/blob/master/src-tauri/src/main.rs"

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_routes,node_protected,node_admin,node_login,node_auth,node_settings,node_theme,node_about toneBlue
class node_cashier,node_cart,node_checkout,node_receipt toneAmber
class node_dashboard,node_dashstate,node_products,node_orders,node_expenses,node_reports,node_users toneMint
class node_backup,node_database,node_crypto,node_tauri toneRose
class node_staff toneIndigo
```

## Components

### Application shell

- [App shell](https://github.com/dia-312/pos-1/blob/master/src/App.tsx): `src/App.tsx`
- [Route dispatch](https://github.com/dia-312/pos-1/blob/master/src/routes/AppRoutes.tsx): `src/routes/AppRoutes.tsx`
- [Protected routes](https://github.com/dia-312/pos-1/blob/master/src/routes/ProtectedRoute.tsx): `src/routes/ProtectedRoute.tsx`
- [Admin routes](https://github.com/dia-312/pos-1/blob/master/src/routes/AdminRoute.tsx): `src/routes/AdminRoute.tsx`
- [Login](https://github.com/dia-312/pos-1/blob/master/src/pages/Login.tsx): `src/pages/Login.tsx`
- [Auth state](https://github.com/dia-312/pos-1/blob/master/src/store/useAuthStore.ts): `src/store/useAuthStore.ts`
- [Settings](https://github.com/dia-312/pos-1/blob/master/src/pages/Settings.tsx): `src/pages/Settings.tsx`
- [Theme state](https://github.com/dia-312/pos-1/blob/master/src/store/useThemeStore.ts): `src/store/useThemeStore.ts`
- [About page](https://github.com/dia-312/pos-1/blob/master/src/pages/About.tsx): `src/pages/About.tsx`

### Sales workflow

- [Cashier checkout](https://github.com/dia-312/pos-1/blob/master/src/pages/Cashier.tsx): `src/pages/Cashier.tsx`
- [Cart state](https://github.com/dia-312/pos-1/blob/master/src/store/useCartStore.ts): `src/store/useCartStore.ts`
- [Checkout dialog](https://github.com/dia-312/pos-1/blob/master/src/components/ui/CheckoutModal.tsx): `src/components/ui/CheckoutModal.tsx`
- [Receipt formatting](https://github.com/dia-312/pos-1/blob/master/src/lib/html.ts): `src/lib/html.ts`

### Business operations

- [Dashboard](https://github.com/dia-312/pos-1/blob/master/src/pages/Dashboard.tsx): `src/pages/Dashboard.tsx`
- [Dashboard state](https://github.com/dia-312/pos-1/blob/master/src/store/useDashboardStore.ts): `src/store/useDashboardStore.ts`
- [Product management](https://github.com/dia-312/pos-1/blob/master/src/pages/Products.tsx): `src/pages/Products.tsx`
- [Order management](https://github.com/dia-312/pos-1/blob/master/src/pages/Orders.tsx): `src/pages/Orders.tsx`
- [Expense tracking](https://github.com/dia-312/pos-1/blob/master/src/pages/Expenses.tsx): `src/pages/Expenses.tsx`
- [Reports and exports](https://github.com/dia-312/pos-1/blob/master/src/pages/Reports.tsx): `src/pages/Reports.tsx`
- [User management](https://github.com/dia-312/pos-1/blob/master/src/pages/Users.tsx): `src/pages/Users.tsx`

### Local data platform

- [Automatic backup](https://github.com/dia-312/pos-1/blob/master/src/lib/backup.ts): `src/lib/backup.ts`
- [SQLite data layer](https://github.com/dia-312/pos-1/blob/master/src/lib/database.ts): `src/lib/database.ts`
- [Secret hashing](https://github.com/dia-312/pos-1/blob/master/src/lib/crypto.ts): `src/lib/crypto.ts`
- [Tauri desktop host](https://github.com/dia-312/pos-1/blob/master/src-tauri/src/main.rs): `src-tauri/src/main.rs`

### Other components

- **Staff or admin**

## Connections

- Staff or admin → Route dispatch: navigates
- Route dispatch → Login: dispatches
- Route dispatch → Protected routes: guards
- Route dispatch → Admin routes: guards
- Route dispatch → Cashier checkout: dispatches
- Route dispatch → Product management: dispatches
- Route dispatch → Order management: dispatches
- Route dispatch → Expense tracking: dispatches
- Route dispatch → Dashboard: dispatches
- Route dispatch → Reports and exports: dispatches
- Route dispatch → User management: dispatches
- Route dispatch → Settings: dispatches
- Route dispatch → About page: dispatches
- App shell → Route dispatch: renders
- App shell → SQLite data layer: initializes
- App shell → Automatic backup: starts
- App shell → Theme state: initializes
- Cashier checkout → SQLite data layer: reads products
- Cashier checkout → Cart state: updates
- Cashier checkout → Checkout dialog: opens
- Checkout dialog → Cashier checkout: confirms
- Cashier checkout → SQLite data layer: records sale
- Cashier checkout → SQLite data layer: reduces stock
- Cashier checkout → Receipt formatting: formats receipt
- Dashboard → Dashboard state: displays
- Dashboard state → SQLite data layer: loads statistics
- SQLite data layer → Secret hashing: hashes credentials
- Tauri desktop host → SQLite data layer: hosts SQLite access
