# cheekydavy/pos architecture

> Architecture diagram of the GitHub repository cheekydavy/pos, 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/cheekydavy/pos
- Repository: https://github.com/cheekydavy/pos

## Overview

This is a cloud POS and customer-management platform, with a Next.js web app and an Express API. The main workflow is staff using the POS to create and check out sales; other documented workflows cover inventory, purchasing, customer and supplier records, reporting, roles, receivables, and M-Pesa payments. The graph shows the route/controller/service structure where source references support it. Some service internals and frontend API wiring were not sampled, so those connections are documented or marked unverified rather than inferred.

Main entry points: [`apps/api/src/app.ts`](https://github.com/cheekydavy/pos/blob/main/apps/api/src/app.ts) (API application), [`apps/api/src/modules/mpesa/mpesa.controller.ts`](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/mpesa/mpesa.controller.ts) (M-Pesa controller), [`apps/web/src/app/pos/page.tsx`](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/pos/page.tsx) (POS checkout), [`apps/api/src/modules/sales/sales.routes.ts`](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.routes.ts) (Sales routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_pos["POS checkout<br/>[page.tsx]"]
  node_web_records["Web records<br/>[page.tsx]"]
  node_web_reports["Web reports<br/>[page.tsx]"]
  node_web_inventory["Web inventory<br/>[page.tsx]"]
  node_web_purchasing["Web purchasing<br/>[page.tsx]"]
  node_web_mpesa["Web M-Pesa<br/>[page.tsx]"]
end

subgraph group_api["API workflows"]
  node_api_app["API application<br/>[app.ts]"]
  node_sales_routes["Sales routes<br/>[sales.routes.ts]"]
  node_sales_controller["Sales controller"]
  node_mpesa_controller["M-Pesa controller"]
end

subgraph group_operations["Business operations"]
  node_sales_service["Sales service<br/>[sales.service.ts]"]
  node_products_service["Product catalog"]
  node_inventory_service["Inventory"]
  node_customers_service["Customers"]
  node_purchasing_service["Purchasing"]
  node_suppliers_service["Suppliers"]
  node_reports_service["Reports<br/>[reports.service.ts]"]
  node_mpesa_service["M-Pesa service<br/>[mpesa.service.ts]"]
end

subgraph group_platform["Platform services"]
  node_roles_service["Roles and access<br/>[roles.service.ts]"]
  node_users_service["Staff accounts<br/>[users.service.ts]"]
  node_auth_service["Authentication<br/>[auth.service.ts]"]
  node_prisma["Prisma client<br/>[prisma.ts]"]
end

node_staff(("Staff user"))
node_database[("PostgreSQL")]
node_safaricom["Safaricom Daraja"]

node_staff -->|"uses"| node_pos
node_pos -->|"submits sales"| node_api_app
node_web_records -->|"manages records"| node_api_app
node_web_reports -->|"requests reports"| node_api_app
node_web_inventory -->|"manages stock"| node_api_app
node_web_purchasing -->|"manages purchases"| node_api_app
node_web_mpesa -->|"starts payments"| node_api_app
node_api_app -->|"mounts"| node_sales_routes
node_sales_routes -->|"dispatches"| node_sales_controller
node_sales_controller -->|"calls"| node_sales_service
node_api_app -->|"mounts routes"| node_mpesa_controller
node_mpesa_controller -->|"calls"| node_mpesa_service
node_safaricom -->|"sends callback"| node_mpesa_controller
node_api_app -.->|"serves catalog"| node_products_service
node_api_app -.->|"serves stock"| node_inventory_service
node_api_app -.->|"serves customers"| node_customers_service
node_api_app -.->|"serves purchasing"| node_purchasing_service
node_api_app -.->|"serves suppliers"| node_suppliers_service
node_api_app -.->|"serves reports"| node_reports_service
node_api_app -.->|"serves roles"| node_roles_service
node_api_app -.->|"serves staff"| node_users_service
node_api_app -.->|"serves login"| node_auth_service
node_sales_service -.->|"persists sales"| node_database
node_products_service -.->|"stores catalog"| node_database
node_inventory_service -.->|"stores stock"| node_database
node_customers_service -.->|"stores customers"| node_database
node_purchasing_service -.->|"stores orders"| node_database
node_suppliers_service -.->|"stores suppliers"| node_database
node_reports_service -.->|"reads records"| node_database
node_mpesa_service -.->|"stores transactions"| node_database
node_auth_service -.->|"checks accounts"| node_database
node_roles_service -.->|"stores permissions"| node_database
node_users_service -.->|"stores accounts"| node_database
node_prisma -.->|"connects"| node_database

click node_pos "https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/pos/page.tsx"
click node_web_records "https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/customers/page.tsx"
click node_web_reports "https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/reports/page.tsx"
click node_web_inventory "https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/inventory/page.tsx"
click node_web_purchasing "https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/purchase-orders/page.tsx"
click node_web_mpesa "https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/mpesa/page.tsx"
click node_api_app "https://github.com/cheekydavy/pos/blob/main/apps/api/src/app.ts"
click node_sales_routes "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.routes.ts"
click node_sales_controller "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.controller.ts"
click node_sales_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.service.ts"
click node_products_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/products/products.service.ts"
click node_inventory_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/inventory/inventory.service.ts"
click node_customers_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/customers/customers.service.ts"
click node_purchasing_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/purchasing/purchasing.service.ts"
click node_suppliers_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/suppliers/suppliers.service.ts"
click node_reports_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/reports/reports.service.ts"
click node_mpesa_controller "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/mpesa/mpesa.controller.ts"
click node_mpesa_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/mpesa/mpesa.service.ts"
click node_roles_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/roles/roles.service.ts"
click node_users_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/users/users.service.ts"
click node_auth_service "https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/auth/auth.service.ts"
click node_prisma "https://github.com/cheekydavy/pos/blob/main/apps/api/src/core/prisma.ts"

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,node_web_records,node_web_reports,node_web_inventory,node_web_purchasing,node_web_mpesa,node_staff toneBlue
class node_api_app,node_sales_routes,node_sales_controller,node_mpesa_controller,node_database toneAmber
class node_sales_service,node_products_service,node_inventory_service,node_customers_service,node_purchasing_service,node_suppliers_service,node_reports_service,node_mpesa_service toneMint
class node_roles_service,node_users_service,node_auth_service,node_prisma toneRose
class node_safaricom toneIndigo
```

## Components

### Web app

- [POS checkout](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/pos/page.tsx): `apps/web/src/app/pos/page.tsx`
- [Web records](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/customers/page.tsx): `apps/web/src/app/customers/page.tsx`
- [Web reports](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/reports/page.tsx): `apps/web/src/app/reports/page.tsx`
- [Web inventory](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/inventory/page.tsx): `apps/web/src/app/inventory/page.tsx`
- [Web purchasing](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/purchase-orders/page.tsx): `apps/web/src/app/purchase-orders/page.tsx`
- [Web M-Pesa](https://github.com/cheekydavy/pos/blob/main/apps/web/src/app/mpesa/page.tsx): `apps/web/src/app/mpesa/page.tsx`

### API workflows

- [API application](https://github.com/cheekydavy/pos/blob/main/apps/api/src/app.ts): `apps/api/src/app.ts`
- [Sales routes](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.routes.ts): `apps/api/src/modules/sales/sales.routes.ts`
- [Sales controller](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.controller.ts): `apps/api/src/modules/sales/sales.controller.ts`
- [M-Pesa controller](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/mpesa/mpesa.controller.ts): `apps/api/src/modules/mpesa/mpesa.controller.ts`

### Business operations

- [Sales service](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/sales/sales.service.ts): `apps/api/src/modules/sales/sales.service.ts`
- [Product catalog](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/products/products.service.ts): `apps/api/src/modules/products/products.service.ts`
- [Inventory](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/inventory/inventory.service.ts): `apps/api/src/modules/inventory/inventory.service.ts`
- [Customers](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/customers/customers.service.ts): `apps/api/src/modules/customers/customers.service.ts`
- [Purchasing](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/purchasing/purchasing.service.ts): `apps/api/src/modules/purchasing/purchasing.service.ts`
- [Suppliers](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/suppliers/suppliers.service.ts): `apps/api/src/modules/suppliers/suppliers.service.ts`
- [Reports](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/reports/reports.service.ts): `apps/api/src/modules/reports/reports.service.ts`
- [M-Pesa service](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/mpesa/mpesa.service.ts): `apps/api/src/modules/mpesa/mpesa.service.ts`

### Platform services

- [Roles and access](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/roles/roles.service.ts): `apps/api/src/modules/roles/roles.service.ts`
- [Staff accounts](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/users/users.service.ts): `apps/api/src/modules/users/users.service.ts`
- [Authentication](https://github.com/cheekydavy/pos/blob/main/apps/api/src/modules/auth/auth.service.ts): `apps/api/src/modules/auth/auth.service.ts`
- [Prisma client](https://github.com/cheekydavy/pos/blob/main/apps/api/src/core/prisma.ts): `apps/api/src/core/prisma.ts`

### Other components

- **Staff user**
- **PostgreSQL**
- **Safaricom Daraja**

## Connections

- Staff user → POS checkout: uses (evidence: `README.md`)
- POS checkout → API application: submits sales (evidence: `README.md`)
- Web records → API application: manages records (evidence: `README.md`)
- Web reports → API application: requests reports (evidence: `README.md`)
- Web inventory → API application: manages stock (evidence: `README.md`)
- Web purchasing → API application: manages purchases (evidence: `README.md`)
- Web M-Pesa → API application: starts payments (evidence: `README.md`)
- API application → Sales routes: mounts (evidence: `apps/api/src/app.ts`)
- Sales routes → Sales controller: dispatches (evidence: `apps/api/src/modules/sales/sales.routes.ts`)
- Sales controller → Sales service: calls (evidence: `apps/api/src/modules/sales/sales.controller.ts`)
- API application → M-Pesa controller: mounts routes (evidence: `apps/api/src/app.ts`)
- M-Pesa controller → M-Pesa service: calls (evidence: `apps/api/src/modules/mpesa/mpesa.controller.ts`)
- Safaricom Daraja → M-Pesa controller: sends callback (evidence: `apps/api/src/modules/mpesa/mpesa.controller.ts`)
- API application → Product catalog: serves catalog
- API application → Inventory: serves stock
- API application → Customers: serves customers
- API application → Purchasing: serves purchasing
- API application → Suppliers: serves suppliers
- API application → Reports: serves reports
- API application → Roles and access: serves roles
- API application → Staff accounts: serves staff
- API application → Authentication: serves login
- Sales service → PostgreSQL: persists sales
- Product catalog → PostgreSQL: stores catalog
- Inventory → PostgreSQL: stores stock
- Customers → PostgreSQL: stores customers
- Purchasing → PostgreSQL: stores orders
- Suppliers → PostgreSQL: stores suppliers
- Reports → PostgreSQL: reads records
- M-Pesa service → PostgreSQL: stores transactions
- Authentication → PostgreSQL: checks accounts
- Roles and access → PostgreSQL: stores permissions
- Staff accounts → PostgreSQL: stores accounts
- Prisma client → PostgreSQL: connects
