# vatanium-lite/minimartpos architecture

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

- Interactive diagram: https://gitdiagram.com/vatanium-lite/minimartpos
- Repository: https://github.com/vatanium-lite/minimartpos

## Overview

Moon Mart POS is a Windows desktop checkout and inventory application. A cashier scans or enters a barcode, manages cart quantities and a whole-sale discount, selects a payment label, and completes checkout; the application records the sale, deducts stock, and attempts receipt printing. Separate workflows manage products and stock and display a Bangkok-time business-day sales summary. The graph distinguishes UI orchestration, database operations, reporting, and receipt rendering/printing. Some subsystem links are documented in the README; unsampled implementation details are not inferred.

Main entry points: [`main.py`](https://github.com/vatanium-lite/minimartpos/blob/master/main.py) (POS window), [`db.py`](https://github.com/vatanium-lite/minimartpos/blob/master/db.py) (Sale recording), [`printer.py`](https://github.com/vatanium-lite/minimartpos/blob/master/printer.py) (Receipt formatting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["POS interface"]
  node_pos["POS window<br/>[main.py]"]
end

subgraph group_sales["Sales workflow"]
  node_cart["Cart and totals<br/>[main.py]"]
  node_checkout["Checkout<br/>[main.py]"]
  node_payment["Cash or KHQR<br/>[main.py]"]
end

subgraph group_inventory["Products and stock"]
  node_product_edit["Product editing<br/>[main.py]"]
  node_stock_forms["Stock forms<br/>[main.py]"]
end

subgraph group_data["Database and reporting"]
  node_sale_record["Sale recording<br/>[db.py]"]
  node_batch_deduction["Batch deduction<br/>[db.py]"]
  node_product_store["Product operations<br/>[db.py]"]
  node_stock_store["Stock operations<br/>[db.py]"]
  node_sales_report["Business-day summary<br/>[db.py]"]
end

subgraph group_receipts["Receipt output"]
  node_receipt_render["Receipt formatting<br/>[printer.py]"]
end

node_cashier(("Cashier"))
node_scanner(("Barcode scanner"))
node_sqlite[("SQLite database")]
node_printer_driver["Windows ESC/POS printer"]

node_cashier -->|"operates"| node_pos
node_scanner -.->|"enters barcode"| node_pos
node_pos -->|"manages"| node_cart
node_cart -->|"submits"| node_checkout
node_cashier -->|"confirms payment"| node_payment
node_payment -->|"selects method"| node_checkout
node_checkout -->|"records sale"| node_sale_record
node_checkout -->|"deducts stock"| node_batch_deduction
node_sale_record -->|"writes transactions"| node_sqlite
node_batch_deduction -->|"reads and updates batches"| node_sqlite
node_pos -->|"opens forms"| node_product_edit
node_product_edit -->|"adds or edits products"| node_product_store
node_pos -->|"opens forms"| node_stock_forms
node_stock_forms -->|"changes stock"| node_stock_store
node_product_store -->|"reads and writes products"| node_sqlite
node_stock_store -->|"reads and writes batches"| node_sqlite
node_pos -->|"requests summary"| node_sales_report
node_sales_report -->|"queries sales"| node_sqlite
node_checkout -->|"prints after commit"| node_receipt_render
node_receipt_render -->|"sends receipt"| node_printer_driver

click node_pos "https://github.com/vatanium-lite/minimartpos/blob/master/main.py"
click node_cart "https://github.com/vatanium-lite/minimartpos/blob/master/main.py"
click node_checkout "https://github.com/vatanium-lite/minimartpos/blob/master/main.py"
click node_payment "https://github.com/vatanium-lite/minimartpos/blob/master/main.py"
click node_product_edit "https://github.com/vatanium-lite/minimartpos/blob/master/main.py"
click node_stock_forms "https://github.com/vatanium-lite/minimartpos/blob/master/main.py"
click node_sale_record "https://github.com/vatanium-lite/minimartpos/blob/master/db.py"
click node_batch_deduction "https://github.com/vatanium-lite/minimartpos/blob/master/db.py"
click node_product_store "https://github.com/vatanium-lite/minimartpos/blob/master/db.py"
click node_stock_store "https://github.com/vatanium-lite/minimartpos/blob/master/db.py"
click node_sales_report "https://github.com/vatanium-lite/minimartpos/blob/master/db.py"
click node_receipt_render "https://github.com/vatanium-lite/minimartpos/blob/master/printer.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_pos toneBlue
class node_cart,node_checkout,node_payment,node_sqlite toneAmber
class node_product_edit,node_stock_forms toneMint
class node_sale_record,node_batch_deduction,node_product_store,node_stock_store,node_sales_report toneRose
class node_receipt_render,node_cashier,node_scanner,node_printer_driver toneIndigo
```

## Components

### POS interface

- [POS window](https://github.com/vatanium-lite/minimartpos/blob/master/main.py): `main.py`

### Sales workflow

- [Cart and totals](https://github.com/vatanium-lite/minimartpos/blob/master/main.py): `main.py`
- [Checkout](https://github.com/vatanium-lite/minimartpos/blob/master/main.py): `main.py`
- [Cash or KHQR](https://github.com/vatanium-lite/minimartpos/blob/master/main.py): `main.py`

### Products and stock

- [Product editing](https://github.com/vatanium-lite/minimartpos/blob/master/main.py): `main.py`
- [Stock forms](https://github.com/vatanium-lite/minimartpos/blob/master/main.py): `main.py`

### Database and reporting

- [Sale recording](https://github.com/vatanium-lite/minimartpos/blob/master/db.py): `db.py`
- [Batch deduction](https://github.com/vatanium-lite/minimartpos/blob/master/db.py): `db.py`
- [Product operations](https://github.com/vatanium-lite/minimartpos/blob/master/db.py): `db.py`
- [Stock operations](https://github.com/vatanium-lite/minimartpos/blob/master/db.py): `db.py`
- [Business-day summary](https://github.com/vatanium-lite/minimartpos/blob/master/db.py): `db.py`

### Receipt output

- [Receipt formatting](https://github.com/vatanium-lite/minimartpos/blob/master/printer.py): `printer.py`

### Other components

- **Cashier**
- **Barcode scanner**
- **SQLite database**
- **Windows ESC/POS printer**

## Connections

- Cashier → POS window: operates (evidence: `README.md`)
- Barcode scanner → POS window: enters barcode (evidence: `README.md`)
- POS window → Cart and totals: manages (evidence: `main.py`)
- Cart and totals → Checkout: submits (evidence: `README.md`)
- Cashier → Cash or KHQR: confirms payment (evidence: `README.md`)
- Cash or KHQR → Checkout: selects method (evidence: `README.md`)
- Checkout → Sale recording: records sale (evidence: `README.md`)
- Checkout → Batch deduction: deducts stock (evidence: `README.md`)
- Sale recording → SQLite database: writes transactions (evidence: `db.py`)
- Batch deduction → SQLite database: reads and updates batches (evidence: `db.py`)
- POS window → Product editing: opens forms (evidence: `main.py`)
- Product editing → Product operations: adds or edits products (evidence: `README.md`)
- POS window → Stock forms: opens forms (evidence: `main.py`)
- Stock forms → Stock operations: changes stock (evidence: `README.md`)
- Product operations → SQLite database: reads and writes products (evidence: `db.py`)
- Stock operations → SQLite database: reads and writes batches (evidence: `db.py`)
- POS window → Business-day summary: requests summary (evidence: `README.md`)
- Business-day summary → SQLite database: queries sales (evidence: `db.py`)
- Checkout → Receipt formatting: prints after commit (evidence: `README.md`)
- Receipt formatting → Windows ESC/POS printer: sends receipt (evidence: `printer.py`)
