# prowider5565/choy-pos architecture

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

- Interactive diagram: https://gitdiagram.com/prowider5565/choy-pos
- Repository: https://github.com/prowider5565/choy-pos

## Overview

This is a Django business-management API for inventory, sales, customers and suppliers, debts, payments, analytics, media, and messaging. Its clearest evidenced workflow is sale creation: a sale service calculates totals, checks and deducts product batches, records payments, and returns the sale. Other supported branches cover product-batch imports and supplier debt, client records and legacy debt, debt-amount presentation, low-stock analytics, and notifications. The tree indicates additional API capabilities, but no README or excerpts document their internal wiring, so those modules are represented without speculative edges.

Main entry points: [`sales/services/sale_service.py`](https://github.com/prowider5565/choy-pos/blob/main/sales/services/sale_service.py) (Sale service), [`users/models.py`](https://github.com/prowider5565/choy-pos/blob/main/users/models.py) (User and client records), [`users/views/clients.py`](https://github.com/prowider5565/choy-pos/blob/main/users/views/clients.py) (Client API), [`users/serializers/client.py`](https://github.com/prowider5565/choy-pos/blob/main/users/serializers/client.py) (Client serializer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commerce["Sales and inventory"]
  node_sale_api["Sale service<br/>[sale_service.py]"]
  node_sale_math["Sale calculations<br/>[calculations.py]"]
  node_sale_records[("Sales records<br/>[models.py]")]
  node_product_api["Product API"]
  node_product_records[("Product inventory<br/>[models.py]")]
  node_batch_service["Batch service<br/>[services.py]"]
end

subgraph group_finance["Debt and payments"]
  node_debt_records[("Debt records<br/>[models.py]")]
  node_debt_service["Supplier debt service"]
  node_payment_records[("Payment records<br/>[models.py]")]
  node_debt_fields["Debt amount fields<br/>[fields.py]"]
  node_client_debt_serializer["Legacy debt serializer<br/>[old_client_debt.py]"]
  node_bulk_payment_serializer["Bulk payment serializer<br/>[old_client.py]"]
end

subgraph group_identity["People and messaging"]
  node_client_api["Client API<br/>[clients.py]"]
  node_client_serializer["Client serializer<br/>[client.py]"]
  node_people_records[("User and client records<br/>[models.py]")]
  node_notifications["Client notifications"]
  node_message_sender["Message sender<br/>[send_message.py]"]
end

subgraph group_insights["Analytics and media"]
  node_analytics_lists["Analytics lists"]
  node_analytics_dashboard["Dashboard analytics"]
  node_media_api["Media API"]
end

node_seller(("Operator"))

node_sale_api -->|"calculates with"| node_sale_math
node_sale_api -->|"creates and loads"| node_sale_records
node_sale_api -->|"creates payments"| node_payment_records
node_sale_api -->|"checks and deducts"| node_product_records
node_sale_api -->|"loads client"| node_people_records
node_batch_service -->|"uses batches"| node_product_records
node_batch_service -->|"creates supplier debt"| node_debt_service
node_debt_service -->|"creates debt"| node_debt_records
node_client_api -->|"serializes requests"| node_client_serializer
node_client_api -->|"queries clients"| node_people_records
node_client_api -->|"creates old debt"| node_debt_records
node_client_serializer -->|"embeds old debt"| node_client_debt_serializer
node_client_serializer -->|"validates client"| node_people_records
node_client_debt_serializer -->|"serializes debt"| node_debt_records
node_bulk_payment_serializer -->|"uses client serializer"| node_people_records
node_bulk_payment_serializer -->|"serializes bulk payment"| node_payment_records
node_debt_fields -->|"reads payments"| node_payment_records
node_analytics_lists -->|"reads inventory"| node_product_records
node_notifications -->|"sends messages"| node_message_sender
node_notifications -->|"uses calculations"| node_sale_math

click node_sale_api "https://github.com/prowider5565/choy-pos/blob/main/sales/services/sale_service.py"
click node_sale_math "https://github.com/prowider5565/choy-pos/blob/main/sales/calculations.py"
click node_sale_records "https://github.com/prowider5565/choy-pos/blob/main/sales/models.py"
click node_product_api "https://github.com/prowider5565/choy-pos/tree/main/products/views"
click node_product_records "https://github.com/prowider5565/choy-pos/blob/main/products/models.py"
click node_batch_service "https://github.com/prowider5565/choy-pos/blob/main/products/batch/services.py"
click node_debt_records "https://github.com/prowider5565/choy-pos/blob/main/debts/models.py"
click node_debt_service "https://github.com/prowider5565/choy-pos/blob/main/debts/services/new_seller_debt_service.py"
click node_payment_records "https://github.com/prowider5565/choy-pos/blob/main/payments/models.py"
click node_debt_fields "https://github.com/prowider5565/choy-pos/blob/main/common/fields.py"
click node_client_api "https://github.com/prowider5565/choy-pos/blob/main/users/views/clients.py"
click node_client_serializer "https://github.com/prowider5565/choy-pos/blob/main/users/serializers/client.py"
click node_people_records "https://github.com/prowider5565/choy-pos/blob/main/users/models.py"
click node_client_debt_serializer "https://github.com/prowider5565/choy-pos/blob/main/debts/serializers/old_client_debt.py"
click node_bulk_payment_serializer "https://github.com/prowider5565/choy-pos/blob/main/payments/tba/serializers/old_client.py"
click node_analytics_lists "https://github.com/prowider5565/choy-pos/tree/main/analytics/services/lists"
click node_analytics_dashboard "https://github.com/prowider5565/choy-pos/tree/main/analytics/services/dashboard"
click node_notifications "https://github.com/prowider5565/choy-pos/blob/main/bot/services/client_notifications.py"
click node_message_sender "https://github.com/prowider5565/choy-pos/blob/main/bot/services/send_message.py"
click node_media_api "https://github.com/prowider5565/choy-pos/tree/main/media/views"

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_sale_api,node_sale_math,node_sale_records,node_product_api,node_product_records,node_batch_service toneBlue
class node_debt_records,node_debt_service,node_payment_records,node_debt_fields,node_client_debt_serializer,node_bulk_payment_serializer toneAmber
class node_client_api,node_client_serializer,node_people_records,node_notifications,node_message_sender toneMint
class node_analytics_lists,node_analytics_dashboard,node_media_api toneRose
class node_seller toneIndigo
```

## Components

### Sales and inventory

- [Sale service](https://github.com/prowider5565/choy-pos/blob/main/sales/services/sale_service.py): `sales/services/sale_service.py`
- [Sale calculations](https://github.com/prowider5565/choy-pos/blob/main/sales/calculations.py): `sales/calculations.py`
- [Sales records](https://github.com/prowider5565/choy-pos/blob/main/sales/models.py): `sales/models.py`
- [Product API](https://github.com/prowider5565/choy-pos/tree/main/products/views): `products/views`
- [Product inventory](https://github.com/prowider5565/choy-pos/blob/main/products/models.py): `products/models.py`
- [Batch service](https://github.com/prowider5565/choy-pos/blob/main/products/batch/services.py): `products/batch/services.py`

### Debt and payments

- [Debt records](https://github.com/prowider5565/choy-pos/blob/main/debts/models.py): `debts/models.py`
- [Supplier debt service](https://github.com/prowider5565/choy-pos/blob/main/debts/services/new_seller_debt_service.py): `debts/services/new_seller_debt_service.py`
- [Payment records](https://github.com/prowider5565/choy-pos/blob/main/payments/models.py): `payments/models.py`
- [Debt amount fields](https://github.com/prowider5565/choy-pos/blob/main/common/fields.py): `common/fields.py`
- [Legacy debt serializer](https://github.com/prowider5565/choy-pos/blob/main/debts/serializers/old_client_debt.py): `debts/serializers/old_client_debt.py`
- [Bulk payment serializer](https://github.com/prowider5565/choy-pos/blob/main/payments/tba/serializers/old_client.py): `payments/tba/serializers/old_client.py`

### People and messaging

- [Client API](https://github.com/prowider5565/choy-pos/blob/main/users/views/clients.py): `users/views/clients.py`
- [Client serializer](https://github.com/prowider5565/choy-pos/blob/main/users/serializers/client.py): `users/serializers/client.py`
- [User and client records](https://github.com/prowider5565/choy-pos/blob/main/users/models.py): `users/models.py`
- [Client notifications](https://github.com/prowider5565/choy-pos/blob/main/bot/services/client_notifications.py): `bot/services/client_notifications.py`
- [Message sender](https://github.com/prowider5565/choy-pos/blob/main/bot/services/send_message.py): `bot/services/send_message.py`

### Analytics and media

- [Analytics lists](https://github.com/prowider5565/choy-pos/tree/main/analytics/services/lists): `analytics/services/lists`
- [Dashboard analytics](https://github.com/prowider5565/choy-pos/tree/main/analytics/services/dashboard): `analytics/services/dashboard`
- [Media API](https://github.com/prowider5565/choy-pos/tree/main/media/views): `media/views`

### Other components

- **Operator**

## Connections

- Sale service → Sale calculations: calculates with (evidence: `sales/services/sale_service.py`)
- Sale service → Sales records: creates and loads (evidence: `sales/services/sale_service.py`)
- Sale service → Payment records: creates payments (evidence: `sales/services/sale_service.py`)
- Sale service → Product inventory: checks and deducts (evidence: `sales/services/sale_service.py`)
- Sale service → User and client records: loads client (evidence: `sales/services/sale_service.py`)
- Batch service → Product inventory: uses batches (evidence: `products/batch/services.py`)
- Batch service → Supplier debt service: creates supplier debt (evidence: `products/batch/services.py`)
- Supplier debt service → Debt records: creates debt (evidence: `debts/services/new_seller_debt_service.py`)
- Client API → Client serializer: serializes requests (evidence: `users/views/clients.py`)
- Client API → User and client records: queries clients (evidence: `users/views/clients.py`)
- Client API → Debt records: creates old debt (evidence: `users/views/clients.py`)
- Client serializer → Legacy debt serializer: embeds old debt (evidence: `users/serializers/client.py`)
- Client serializer → User and client records: validates client (evidence: `users/serializers/client.py`)
- Legacy debt serializer → Debt records: serializes debt (evidence: `debts/serializers/old_client_debt.py`)
- Bulk payment serializer → User and client records: uses client serializer (evidence: `payments/tba/serializers/old_client.py`)
- Bulk payment serializer → Payment records: serializes bulk payment (evidence: `payments/tba/serializers/old_client.py`)
- Debt amount fields → Payment records: reads payments (evidence: `common/fields.py`)
- Analytics lists → Product inventory: reads inventory (evidence: `analytics/services/lists/low_stock_service.py`)
- Client notifications → Message sender: sends messages (evidence: `bot/services/client_notifications.py`)
- Client notifications → Sale calculations: uses calculations (evidence: `bot/services/client_notifications.py`)
