# joseph-mutonga/pointofsale architecture

> Architecture diagram of the GitHub repository joseph-mutonga/pointofsale, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/joseph-mutonga/pointofsale
- Repository: https://github.com/joseph-mutonga/pointofsale

## Overview

This is a browser-based point-of-sale and tailoring shop application with a React interface and Express/MySQL backend. Cashiers and administrators use the app to manage sales, services, custom tailoring, wedding orders, inventory, and shop operations; requests pass through the browser API to server routes and persisted data. M-Pesa payment initiation is an external integration. The excerpts establish several UI/API and server/payment relationships, but do not expose all routes or persistence calls, so unsampled connections are omitted.

Main entry points: [`src/api.js`](https://github.com/joseph-mutonga/pointofsale/blob/main/src/api.js) (Browser API), [`src/App.jsx`](https://github.com/joseph-mutonga/pointofsale/blob/main/src/App.jsx) (Shop app), [`server/server.js`](https://github.com/joseph-mutonga/pointofsale/blob/main/server/server.js) (HTTP API server), [`src/AdminPanel.jsx`](https://github.com/joseph-mutonga/pointofsale/blob/main/src/AdminPanel.jsx) (Admin panel)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Shop interface"]
  node_app["Shop app<br/>[App.jsx]"]
end

subgraph group_commerce["Sales and tailoring"]
  node_gallery["Style gallery<br/>[GalleryView.jsx]"]
  node_tailoring["Tailoring orders<br/>[TailoringView.jsx]"]
  node_weddings["Wedding orders<br/>[WeddingsView.jsx]"]
end

subgraph group_backend["API and persistence"]
  node_api["Browser API<br/>[api.js]"]
  node_server["HTTP API server<br/>[server.js]"]
  node_database[("MySQL store<br/>[db.js]")]
  node_payments["M-Pesa client<br/>[mpesa.js]"]
end

subgraph group_operations["Shop operations"]
  node_admin["Admin panel<br/>[AdminPanel.jsx]"]
  node_printer["Printer settings"]
  node_receipts["Receipt templates"]
end

node_cashier(("Cashier / admin"))
node_mpesa_service{{"Safaricom Daraja"}}

node_cashier -->|"uses"| node_app
node_app -->|"opens"| node_admin
node_app -->|"opens"| node_tailoring
node_app -->|"opens"| node_gallery
node_app -->|"opens"| node_weddings
node_tailoring -->|"requests"| node_api
node_weddings -->|"requests"| node_api
node_gallery -->|"requests"| node_api
node_admin -->|"requests"| node_api
node_api -->|"HTTP requests"| node_server
node_server -->|"queries"| node_database
node_server -->|"initiates payment"| node_payments
node_server -->|"registers C2B"| node_payments
node_payments -->|"calls Daraja"| node_mpesa_service
node_admin -->|"renders"| node_printer
node_printer -->|"prints via"| node_api

click node_app "https://github.com/joseph-mutonga/pointofsale/blob/main/src/App.jsx"
click node_admin "https://github.com/joseph-mutonga/pointofsale/blob/main/src/AdminPanel.jsx"
click node_gallery "https://github.com/joseph-mutonga/pointofsale/blob/main/src/views/GalleryView.jsx"
click node_tailoring "https://github.com/joseph-mutonga/pointofsale/blob/main/src/views/TailoringView.jsx"
click node_weddings "https://github.com/joseph-mutonga/pointofsale/blob/main/src/views/WeddingsView.jsx"
click node_api "https://github.com/joseph-mutonga/pointofsale/blob/main/src/api.js"
click node_server "https://github.com/joseph-mutonga/pointofsale/blob/main/server/server.js"
click node_database "https://github.com/joseph-mutonga/pointofsale/blob/main/server/db.js"
click node_payments "https://github.com/joseph-mutonga/pointofsale/blob/main/server/mpesa.js"
click node_printer "https://github.com/joseph-mutonga/pointofsale/blob/main/src/components/PrinterSettings.jsx"
click node_receipts "https://github.com/joseph-mutonga/pointofsale/blob/main/src/utils/receiptTemplates.js"

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_app toneBlue
class node_gallery,node_tailoring,node_weddings toneAmber
class node_api,node_server,node_database,node_payments toneMint
class node_admin,node_printer,node_receipts toneRose
class node_cashier,node_mpesa_service toneIndigo
```

## Components

### Shop interface

- [Shop app](https://github.com/joseph-mutonga/pointofsale/blob/main/src/App.jsx): `src/App.jsx`

### Sales and tailoring

- [Style gallery](https://github.com/joseph-mutonga/pointofsale/blob/main/src/views/GalleryView.jsx): `src/views/GalleryView.jsx`
- [Tailoring orders](https://github.com/joseph-mutonga/pointofsale/blob/main/src/views/TailoringView.jsx): `src/views/TailoringView.jsx`
- [Wedding orders](https://github.com/joseph-mutonga/pointofsale/blob/main/src/views/WeddingsView.jsx): `src/views/WeddingsView.jsx`

### API and persistence

- [Browser API](https://github.com/joseph-mutonga/pointofsale/blob/main/src/api.js): `src/api.js`
- [HTTP API server](https://github.com/joseph-mutonga/pointofsale/blob/main/server/server.js): `server/server.js`
- [MySQL store](https://github.com/joseph-mutonga/pointofsale/blob/main/server/db.js): `server/db.js`
- [M-Pesa client](https://github.com/joseph-mutonga/pointofsale/blob/main/server/mpesa.js): `server/mpesa.js`

### Shop operations

- [Admin panel](https://github.com/joseph-mutonga/pointofsale/blob/main/src/AdminPanel.jsx): `src/AdminPanel.jsx`
- [Printer settings](https://github.com/joseph-mutonga/pointofsale/blob/main/src/components/PrinterSettings.jsx): `src/components/PrinterSettings.jsx`
- [Receipt templates](https://github.com/joseph-mutonga/pointofsale/blob/main/src/utils/receiptTemplates.js): `src/utils/receiptTemplates.js`

### Other components

- **Cashier / admin**
- **Safaricom Daraja**

## Connections

- Cashier / admin → Shop app: uses
- Shop app → Admin panel: opens (evidence: `src/App.jsx`)
- Shop app → Tailoring orders: opens (evidence: `src/App.jsx`)
- Shop app → Style gallery: opens (evidence: `src/App.jsx`)
- Shop app → Wedding orders: opens (evidence: `src/App.jsx`)
- Tailoring orders → Browser API: requests (evidence: `src/views/TailoringView.jsx`)
- Wedding orders → Browser API: requests (evidence: `src/views/WeddingsView.jsx`)
- Style gallery → Browser API: requests (evidence: `src/views/GalleryView.jsx`)
- Admin panel → Browser API: requests (evidence: `src/AdminPanel.jsx`)
- Browser API → HTTP API server: HTTP requests (evidence: `src/api.js`)
- HTTP API server → MySQL store: queries (evidence: `server/server.js`)
- HTTP API server → M-Pesa client: initiates payment (evidence: `server/server.js`)
- HTTP API server → M-Pesa client: registers C2B (evidence: `server/server.js`)
- M-Pesa client → Safaricom Daraja: calls Daraja (evidence: `server/mpesa.js`)
- Admin panel → Printer settings: renders (evidence: `src/AdminPanel.jsx`)
- Printer settings → Browser API: prints via (evidence: `src/components/PrinterSettings.jsx`)
