# kholif18/ravaa-pos-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/kholif18/ravaa-pos-v2
- Repository: https://github.com/kholif18/ravaa-pos-v2

## Overview

Ravaa POS is a browser-based retail point-of-sale system backed by a central Hono/SQLite API, with an optional USB thermal-printer bridge. The main workflow is cashier login, POS checkout, server-side recording, and optional receipt printing; sales can also be reviewed and reported. Separate areas cover product and stock masters, purchases, returns, debts, audit, and system settings. The README documents these capabilities, but most page implementations and API routes were not sampled, so their internal links are shown only where supported.

Main entry points: [`apps/web/src/api.ts`](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/api.ts) (API client and outbox), [`apps/web/src/ui/auth.ts`](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/ui/auth.ts) (Login and session), [`apps/web/src/pages/pos.ts`](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/pos.ts) (POS checkout), [`apps/api/src/index.ts`](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/api/src/index.ts) (Hono API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_front["Cashier frontend"]
  node_login["Login and session<br/>[auth.ts]"]
  node_app["SPA navigation<br/>[main.ts]"]
  node_api_client["API client and outbox<br/>[api.ts]"]
  node_pwa["Offline app shell<br/>[sw.js]"]
end

subgraph group_sales["Sales operations"]
  node_pos["POS checkout<br/>[pos.ts]"]
  node_history["Transaction history<br/>[history.ts]"]
  node_reports["Reports<br/>[reports.ts]"]
  node_invoices["A4 invoices<br/>[invoice.ts]"]
end

subgraph group_admin["Store operations"]
  node_masters["Product and customer masters<br/>[products.ts]"]
  node_stock["Stock management<br/>[stock.ts]"]
  node_purchases["Purchases and suppliers<br/>[purchases.ts]"]
  node_debts["Debt ledger<br/>[debts.ts]"]
  node_audit["Audit trail<br/>[audit.ts]"]
  node_settings["Settings and backups<br/>[settings.ts]"]
end

subgraph group_backend["Server and persistence"]
  node_api["Hono API<br/>[index.ts]"]
  node_database[("SQLite database<br/>[db.ts]")]
end

subgraph group_printing["Receipt printing"]
  node_escpos["ESC/POS formatter<br/>[escpos.ts]"]
  node_agent["Print agent<br/>[server.js]"]
  node_printer["USB receipt printer"]
end

node_cashier(("Cashier"))

node_cashier -->|"signs in"| node_login
node_login -->|"authenticates"| node_api
node_login -.->|"sets session"| node_app
node_app -->|"opens checkout"| node_pos
node_pos -->|"requests sales"| node_api_client
node_history -->|"loads transactions"| node_api_client
node_reports -->|"loads reports"| node_api_client
node_masters -->|"updates masters"| node_api_client
node_stock -->|"loads stock"| node_api_client
node_purchases -->|"records purchases"| node_api_client
node_debts -.->|"manages ledger"| node_api_client
node_audit -.->|"loads audit"| node_api_client
node_settings -->|"manages backups"| node_api_client
node_api_client -->|"sends requests"| node_api
node_api -->|"reads and writes"| node_database
node_pos -->|"formats receipts"| node_escpos
node_history -->|"prints invoice"| node_invoices
node_escpos -->|"sends print bytes"| node_agent
node_agent -->|"prints receipt"| node_printer
node_pwa -.->|"serves offline shell"| node_cashier

click node_login "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/ui/auth.ts"
click node_app "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/main.ts"
click node_api_client "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/api.ts"
click node_pos "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/pos.ts"
click node_history "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/history.ts"
click node_reports "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/reports.ts"
click node_invoices "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/invoice.ts"
click node_masters "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/products.ts"
click node_stock "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/stock.ts"
click node_purchases "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/purchases.ts"
click node_debts "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/debts.ts"
click node_audit "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/audit.ts"
click node_settings "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/settings.ts"
click node_pwa "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/public/sw.js"
click node_api "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/api/src/index.ts"
click node_database "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/api/src/db.ts"
click node_escpos "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/escpos.ts"
click node_agent "https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/print-agent/server.js"

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_app,node_api_client,node_pwa toneBlue
class node_pos,node_history,node_reports,node_invoices toneAmber
class node_masters,node_stock,node_purchases,node_debts,node_audit,node_settings toneMint
class node_api,node_database toneRose
class node_escpos,node_agent,node_printer,node_cashier toneIndigo
```

## Components

### Cashier frontend

- [Login and session](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/ui/auth.ts): `apps/web/src/ui/auth.ts`
- [SPA navigation](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/main.ts): `apps/web/src/main.ts`
- [API client and outbox](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/api.ts): `apps/web/src/api.ts`
- [Offline app shell](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/public/sw.js): `apps/web/public/sw.js`

### Sales operations

- [POS checkout](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/pos.ts): `apps/web/src/pages/pos.ts`
- [Transaction history](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/history.ts): `apps/web/src/pages/history.ts`
- [Reports](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/reports.ts): `apps/web/src/pages/reports.ts`
- [A4 invoices](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/invoice.ts): `apps/web/src/invoice.ts`

### Store operations

- [Product and customer masters](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/products.ts): `apps/web/src/pages/products.ts`
- [Stock management](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/stock.ts): `apps/web/src/pages/stock.ts`
- [Purchases and suppliers](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/purchases.ts): `apps/web/src/pages/purchases.ts`
- [Debt ledger](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/debts.ts): `apps/web/src/pages/debts.ts`
- [Audit trail](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/audit.ts): `apps/web/src/pages/audit.ts`
- [Settings and backups](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/pages/settings.ts): `apps/web/src/pages/settings.ts`

### Server and persistence

- [Hono API](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/api/src/index.ts): `apps/api/src/index.ts`
- [SQLite database](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/api/src/db.ts): `apps/api/src/db.ts`

### Receipt printing

- [ESC/POS formatter](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/web/src/escpos.ts): `apps/web/src/escpos.ts`
- [Print agent](https://github.com/kholif18/ravaa-pos-v2/blob/main/apps/print-agent/server.js): `apps/print-agent/server.js`
- **USB receipt printer**

### Other components

- **Cashier**

## Connections

- Cashier → Login and session: signs in (evidence: `apps/web/src/ui/auth.ts`)
- Login and session → Hono API: authenticates (evidence: `apps/web/src/ui/auth.ts`)
- Login and session → SPA navigation: sets session (evidence: `apps/web/src/main.ts`)
- SPA navigation → POS checkout: opens checkout (evidence: `apps/web/src/main.ts`)
- POS checkout → API client and outbox: requests sales (evidence: `apps/web/src/pages/pos.ts`)
- Transaction history → API client and outbox: loads transactions (evidence: `apps/web/src/pages/history.ts`)
- Reports → API client and outbox: loads reports (evidence: `apps/web/src/pages/reports.ts`)
- Product and customer masters → API client and outbox: updates masters (evidence: `apps/web/src/pages/products.ts`)
- Stock management → API client and outbox: loads stock (evidence: `apps/web/src/pages/stock.ts`)
- Purchases and suppliers → API client and outbox: records purchases (evidence: `apps/web/src/pages/purchases.ts`)
- Debt ledger → API client and outbox: manages ledger
- Audit trail → API client and outbox: loads audit
- Settings and backups → API client and outbox: manages backups (evidence: `apps/web/src/pages/settings.ts`)
- API client and outbox → Hono API: sends requests (evidence: `apps/web/src/api.ts`)
- Hono API → SQLite database: reads and writes (evidence: `apps/api/src/index.ts`)
- POS checkout → ESC/POS formatter: formats receipts (evidence: `apps/web/src/pages/pos.ts`)
- Transaction history → A4 invoices: prints invoice (evidence: `apps/web/src/pages/history.ts`)
- ESC/POS formatter → Print agent: sends print bytes (evidence: `README.md`)
- Print agent → USB receipt printer: prints receipt (evidence: `apps/print-agent/server.js`)
- Offline app shell → Cashier: serves offline shell (evidence: `README.md`)
