Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.laportenard.com/llms.txt

Use this file to discover all available pages before exploring further.

System diagram

┌─────────────────────────────────────────────────┐
│                  POS Terminal                     │
│  ┌───────────────────────────────────────────┐   │
│  │          Tauri Desktop Shell              │   │
│  │  ┌───────────────────────────────────┐    │   │
│  │  │     Next.js 16 (Static Export)    │    │   │
│  │  │                                   │    │   │
│  │  │  ┌─────────┐  ┌──────────────┐   │    │   │
│  │  │  │ XState  │  │  usePOS       │   │    │   │
│  │  │  │Machines │  │  Reducer      │   │    │   │
│  │  │  └─────────┘  └──────────────┘   │    │   │
│  │  │  ┌─────────┐  ┌──────────────┐   │    │   │
│  │  │  │ Dexie   │  │  Sync        │   │    │   │
│  │  │  │IndexedDB│  │  Transport   │   │    │   │
│  │  │  └─────────┘  └──────┬───────┘   │    │   │
│  │  └───────────────────────┼───────────┘    │   │
│  └──────────────────────────┼────────────────┘   │
└─────────────────────────────┼────────────────────┘

                    WebSocket │ HTTP

              ┌───────────────┼───────────────┐
              │               ▼               │
              │    ┌──────────────────┐       │
              │    │    Sync Hub      │       │
              │    │  (Node.js + WS)  │       │
              │    │  ┌────────────┐  │       │
              │    │  │  SQLite    │  │       │
              │    │  └────────────┘  │       │
              │    └────────┬─────────┘       │
              └─────────────┼─────────────────┘

                   HTTP POST│ (batch-sync)

              ┌─────────────┼─────────────────┐
              │             ▼                  │
              │    ┌──────────────────┐        │
              │    │   Odoo 12        │        │
              │    │  (Python API)    │        │
              │    │  ┌────────────┐  │        │
              │    │  │ PostgreSQL │  │        │
              │    │  └────────────┘  │        │
              │    └──────────────────┘        │
              └────────────────────────────────┘

Data flow

  1. Bootstrap — Terminal authenticates via JWT, fetches full config + catalog + floor plan from Odoo
  2. Local operations — Orders are created and edited locally in the reducer, persisted to IndexedDB via Dexie
  3. Sync — Changes broadcast through the hub to other terminals in real-time
  4. Upstream — Completed orders are forwarded from the hub to Odoo via POST /pos-api/v1/hub/batch-sync
  5. Offline — Terminals continue working with local data; changes queue in the outbox until connectivity returns

Key design decisions

All order data is persisted to IndexedDB (Dexie) immediately. The system remains fully functional without network connectivity. Sync happens opportunistically.
Business logic lives in src/domain/ as pure functions, completely decoupled from React. This makes the core logic testable without component rendering.
Session lifecycle, order state transitions, and sync status are modeled as explicit state machines, preventing impossible states.
The sync hub is a thin WebSocket relay — it doesn’t own business logic. Terminals remain authoritative over their own orders.