# pisethprom-dk/fll_pos_api architecture

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

- Interactive diagram: https://gitdiagram.com/pisethprom-dk/fll_pos_api
- Repository: https://github.com/pisethprom-dk/fll_pos_api

## Overview

This is a Django/DRF backend for a retail point-of-sale shop. The main workflow is staff authentication, product/customer lookup, quotation or invoice creation, payment and sale completion; posting a sale updates stock and preserves its cost and exchange rate. Other major areas include company configuration, partner records, stock documents and reports. The README documents the API capabilities; some view-to-service wiring and unsampled subsystems are not shown, so those links are omitted rather than inferred.

Main entry points: [`sales/services.py`](https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/services.py) (Sales workflows), [`reports/services.py`](https://github.com/pisethprom-dk/fll_pos_api/blob/main/reports/services.py) (Report calculations), [`inventory/services.py`](https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/services.py) (Stock posting and ledger), [`company/services.py`](https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/services.py) (Rates and numbering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and API"]
  node_user_api["User and auth API<br/>[views.py]"]
  node_tokens["Token lifecycle<br/>[tokens.py]"]
  node_scopes["Role scopes<br/>[scopes.py]"]
end

subgraph group_setup["Shop Setup"]
  node_company_api["Company API<br/>[views.py]"]
  node_company_rules["Rates and numbering<br/>[services.py]"]
  node_currency["Currency rules<br/>[currency.py]"]
  node_company_data[("Company settings<br/>[models.py]")]
end

subgraph group_records["Retail Records"]
  node_catalogue_api["Catalogue API<br/>[views.py]"]
  node_products[("Products and categories<br/>[models.py]")]
  node_catalogue_seed["Demo catalogue data<br/>[demo_data.py]"]
  node_partners_api["Partner API<br/>[views.py]"]
  node_partners[("Customers and suppliers<br/>[models.py]")]
end

subgraph group_operations["Sales and Stock"]
  node_sales_api["Sales API<br/>[views.py]"]
  node_sales_rules["Sales workflows<br/>[services.py]"]
  node_sale_money["Sale calculations<br/>[money.py]"]
  node_sales_docs[("Sales documents<br/>[models.py]")]
  node_inventory_api["Inventory API<br/>[views.py]"]
  node_stock_rules["Stock posting and ledger<br/>[services.py]"]
  node_stock_docs[("Stock documents<br/>[models.py]")]
  node_domain_errors["Domain errors<br/>[exceptions.py]"]
end

subgraph group_insight["Reporting"]
  node_reports_api["Reports API<br/>[views.py]"]
  node_report_queries["Report calculations<br/>[services.py]"]
  node_warranty[("Warranty records<br/>[models.py]")]
end

node_staff(("Shop staff"))

node_staff -->|"authenticates"| node_user_api
node_user_api -->|"uses tokens"| node_tokens
node_staff -->|"configures shop"| node_company_api
node_staff -->|"looks up products"| node_catalogue_api
node_catalogue_seed -->|"creates demo rows"| node_products
node_staff -->|"manages partners"| node_partners_api
node_staff -->|"handles sales"| node_sales_api
node_staff -->|"manages stock"| node_inventory_api
node_staff -.->|"requests reports"| node_reports_api
node_company_rules -->|"reads counters"| node_company_data
node_company_rules -->|"converts currency"| node_currency
node_sales_rules -->|"posts movements"| node_stock_rules
node_sales_rules -->|"takes numbers"| node_company_rules
node_sales_rules -->|"settles tenders"| node_sale_money
node_sales_rules -->|"updates documents"| node_sales_docs
node_stock_rules -->|"writes ledger"| node_stock_docs
node_report_queries -->|"reads sales"| node_sales_docs
node_report_queries -->|"reads stock"| node_stock_docs
node_report_queries -->|"reads warranty"| node_warranty
node_sales_rules -->|"raises rule errors"| node_domain_errors
node_stock_rules -->|"raises rule errors"| node_domain_errors

click node_user_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/users/views.py"
click node_tokens "https://github.com/pisethprom-dk/fll_pos_api/blob/main/users/tokens.py"
click node_scopes "https://github.com/pisethprom-dk/fll_pos_api/blob/main/users/scopes.py"
click node_company_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/views.py"
click node_company_rules "https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/services.py"
click node_currency "https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/currency.py"
click node_company_data "https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/models.py"
click node_catalogue_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/catalogue/views.py"
click node_products "https://github.com/pisethprom-dk/fll_pos_api/blob/main/catalogue/models.py"
click node_catalogue_seed "https://github.com/pisethprom-dk/fll_pos_api/blob/main/catalogue/demo_data.py"
click node_partners_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/partners/views.py"
click node_partners "https://github.com/pisethprom-dk/fll_pos_api/blob/main/partners/models.py"
click node_sales_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/views.py"
click node_sales_rules "https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/services.py"
click node_sale_money "https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/money.py"
click node_sales_docs "https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/models.py"
click node_inventory_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/views.py"
click node_stock_rules "https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/services.py"
click node_stock_docs "https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/models.py"
click node_reports_api "https://github.com/pisethprom-dk/fll_pos_api/blob/main/reports/views.py"
click node_report_queries "https://github.com/pisethprom-dk/fll_pos_api/blob/main/reports/services.py"
click node_warranty "https://github.com/pisethprom-dk/fll_pos_api/blob/main/warranty/models.py"
click node_domain_errors "https://github.com/pisethprom-dk/fll_pos_api/blob/main/core/exceptions.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_user_api,node_tokens,node_scopes toneBlue
class node_company_api,node_company_rules,node_currency,node_company_data toneAmber
class node_catalogue_api,node_products,node_catalogue_seed,node_partners_api,node_partners toneMint
class node_sales_api,node_sales_rules,node_sale_money,node_sales_docs,node_inventory_api,node_stock_rules,node_stock_docs,node_domain_errors toneRose
class node_reports_api,node_report_queries,node_warranty,node_staff toneIndigo
```

## Components

### Access and API

- [User and auth API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/users/views.py): `users/views.py`
- [Token lifecycle](https://github.com/pisethprom-dk/fll_pos_api/blob/main/users/tokens.py): `users/tokens.py`
- [Role scopes](https://github.com/pisethprom-dk/fll_pos_api/blob/main/users/scopes.py): `users/scopes.py`

### Shop Setup

- [Company API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/views.py): `company/views.py`
- [Rates and numbering](https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/services.py): `company/services.py`
- [Currency rules](https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/currency.py): `company/currency.py`
- [Company settings](https://github.com/pisethprom-dk/fll_pos_api/blob/main/company/models.py): `company/models.py`

### Retail Records

- [Catalogue API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/catalogue/views.py): `catalogue/views.py`
- [Products and categories](https://github.com/pisethprom-dk/fll_pos_api/blob/main/catalogue/models.py): `catalogue/models.py`
- [Demo catalogue data](https://github.com/pisethprom-dk/fll_pos_api/blob/main/catalogue/demo_data.py): `catalogue/demo_data.py`
- [Partner API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/partners/views.py): `partners/views.py`
- [Customers and suppliers](https://github.com/pisethprom-dk/fll_pos_api/blob/main/partners/models.py): `partners/models.py`

### Sales and Stock

- [Sales API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/views.py): `sales/views.py`
- [Sales workflows](https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/services.py): `sales/services.py`
- [Sale calculations](https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/money.py): `sales/money.py`
- [Sales documents](https://github.com/pisethprom-dk/fll_pos_api/blob/main/sales/models.py): `sales/models.py`
- [Inventory API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/views.py): `inventory/views.py`
- [Stock posting and ledger](https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/services.py): `inventory/services.py`
- [Stock documents](https://github.com/pisethprom-dk/fll_pos_api/blob/main/inventory/models.py): `inventory/models.py`
- [Domain errors](https://github.com/pisethprom-dk/fll_pos_api/blob/main/core/exceptions.py): `core/exceptions.py`

### Reporting

- [Reports API](https://github.com/pisethprom-dk/fll_pos_api/blob/main/reports/views.py): `reports/views.py`
- [Report calculations](https://github.com/pisethprom-dk/fll_pos_api/blob/main/reports/services.py): `reports/services.py`
- [Warranty records](https://github.com/pisethprom-dk/fll_pos_api/blob/main/warranty/models.py): `warranty/models.py`

### Other components

- **Shop staff**

## Connections

- Shop staff → User and auth API: authenticates (evidence: `README.md`)
- User and auth API → Token lifecycle: uses tokens
- Shop staff → Company API: configures shop (evidence: `README.md`)
- Shop staff → Catalogue API: looks up products (evidence: `README.md`)
- Demo catalogue data → Products and categories: creates demo rows (evidence: `catalogue/management/commands/seed_demo.py`)
- Shop staff → Partner API: manages partners (evidence: `README.md`)
- Shop staff → Sales API: handles sales (evidence: `README.md`)
- Shop staff → Inventory API: manages stock (evidence: `README.md`)
- Shop staff → Reports API: requests reports
- Rates and numbering → Company settings: reads counters (evidence: `company/services.py`)
- Rates and numbering → Currency rules: converts currency (evidence: `company/services.py`)
- Sales workflows → Stock posting and ledger: posts movements (evidence: `sales/services.py`)
- Sales workflows → Rates and numbering: takes numbers (evidence: `sales/services.py`)
- Sales workflows → Sale calculations: settles tenders (evidence: `sales/services.py`)
- Sales workflows → Sales documents: updates documents (evidence: `sales/services.py`)
- Stock posting and ledger → Stock documents: writes ledger (evidence: `inventory/services.py`)
- Report calculations → Sales documents: reads sales (evidence: `reports/services.py`)
- Report calculations → Stock documents: reads stock (evidence: `reports/services.py`)
- Report calculations → Warranty records: reads warranty (evidence: `reports/services.py`)
- Sales workflows → Domain errors: raises rule errors (evidence: `core/exceptions.py`)
- Stock posting and ledger → Domain errors: raises rule errors (evidence: `core/exceptions.py`)
