# abdur-rouf20/pos-all-in-one architecture

> Architecture diagram of the GitHub repository abdur-rouf20/pos-all-in-one, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abdur-rouf20/pos-all-in-one
- Repository: https://github.com/abdur-rouf20/pos-all-in-one

## Overview

This is a bilingual, branch-aware POS application. Staff sign in, select a branch, then manage products and stock, create invoices, collect payments, handle returns and expenses, and review dashboards or reports. The React pages call a shared API client; Express routes authenticate and scope requests before controllers apply business operations to MongoDB models. The graph includes the documented customer, receipt, settings, and administration capabilities, though several of those implementations were not sampled; their internal call relationships are therefore not asserted.

Main entry points: [`backend/src/models`](https://github.com/abdur-rouf20/pos-all-in-one/tree/main/backend/src/models) (POS records), [`frontend/src/App.jsx`](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/App.jsx) (App routing), [`backend/src/server.js`](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/server.js) (Express server), [`backend/src/routes`](https://github.com/abdur-rouf20/pos-all-in-one/tree/main/backend/src/routes) (REST routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["POS interface"]
  node_app["App routing<br/>[App.jsx]"]
  node_invoice_ui["Invoice entry<br/>[InvoiceForm.jsx]"]
  node_return_ui["Sales returns<br/>[SalesReturns.jsx]"]
  node_dashboard_ui["Dashboard<br/>[Dashboard.jsx]"]
  node_other_pages["Other POS pages"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_server["Express server<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_routes["REST routes"]
end

subgraph group_sales["Sales operations"]
  node_invoice_ctrl["Invoice handling"]
  node_return_ctrl["Return handling"]
  node_inventory_ctrl["Inventory handling"]
  node_dashboard_ctrl["Dashboard aggregation"]
  node_report_ctrl["Report aggregation"]
end

subgraph group_state["POS data"]
  node_models[("POS records")]
  node_audit["Audit attribution<br/>[audit.js]"]
  node_db["Mongo connection<br/>[db.js]"]
end

node_staff(("Owner or staff"))
node_mongodb[("MongoDB")]

node_staff -->|"uses"| node_app
node_app -->|"routes to"| node_invoice_ui
node_app -->|"routes to"| node_return_ui
node_app -->|"routes to"| node_dashboard_ui
node_app -->|"routes to"| node_other_pages
node_invoice_ui -->|"calls"| node_api_client
node_return_ui -->|"calls"| node_api_client
node_dashboard_ui -->|"calls"| node_api_client
node_other_pages -.->|"calls"| node_api_client
node_api_client -->|"sends requests"| node_server
node_server -->|"mounts"| node_routes
node_server -->|"protects summary"| node_auth
node_routes -->|"applies guards"| node_auth
node_routes -->|"dispatches"| node_invoice_ctrl
node_routes -->|"dispatches"| node_return_ctrl
node_routes -->|"dispatches"| node_inventory_ctrl
node_server -->|"serves summary"| node_dashboard_ctrl
node_invoice_ctrl -->|"reads and writes"| node_models
node_return_ctrl -->|"reads and writes"| node_models
node_inventory_ctrl -->|"reads and writes"| node_models
node_dashboard_ctrl -->|"aggregates"| node_models
node_report_ctrl -->|"aggregates"| node_models
node_inventory_ctrl -->|"records actions"| node_audit
node_return_ctrl -->|"records actions"| node_audit
node_audit -->|"creates logs"| node_models
node_server -->|"connects"| node_db
node_db -->|"connects to"| node_mongodb

click node_app "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/App.jsx"
click node_invoice_ui "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/pages/InvoiceForm.jsx"
click node_return_ui "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/pages/SalesReturns.jsx"
click node_dashboard_ui "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/pages/Dashboard.jsx"
click node_other_pages "https://github.com/abdur-rouf20/pos-all-in-one/tree/main/frontend/src/pages"
click node_api_client "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/services/api.js"
click node_server "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/server.js"
click node_auth "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/middleware/auth.js"
click node_routes "https://github.com/abdur-rouf20/pos-all-in-one/tree/main/backend/src/routes"
click node_invoice_ctrl "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/invoiceController.js"
click node_return_ctrl "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/salesReturnController.js"
click node_inventory_ctrl "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/inventoryController.js"
click node_dashboard_ctrl "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/dashboardController.js"
click node_report_ctrl "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/reportController.js"
click node_models "https://github.com/abdur-rouf20/pos-all-in-one/tree/main/backend/src/models"
click node_audit "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/utils/audit.js"
click node_db "https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/config/db.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,node_invoice_ui,node_return_ui,node_dashboard_ui,node_other_pages,node_api_client toneBlue
class node_server,node_auth,node_routes,node_mongodb toneAmber
class node_invoice_ctrl,node_return_ctrl,node_inventory_ctrl,node_dashboard_ctrl,node_report_ctrl toneMint
class node_models,node_audit,node_db toneRose
class node_staff toneIndigo
```

## Components

### POS interface

- [App routing](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Invoice entry](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/pages/InvoiceForm.jsx): `frontend/src/pages/InvoiceForm.jsx`
- [Sales returns](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/pages/SalesReturns.jsx): `frontend/src/pages/SalesReturns.jsx`
- [Dashboard](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/pages/Dashboard.jsx): `frontend/src/pages/Dashboard.jsx`
- [Other POS pages](https://github.com/abdur-rouf20/pos-all-in-one/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Backend API

- [Express server](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/server.js): `backend/src/server.js`
- [Authentication](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [REST routes](https://github.com/abdur-rouf20/pos-all-in-one/tree/main/backend/src/routes): `backend/src/routes`

### Sales operations

- [Invoice handling](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/invoiceController.js): `backend/src/controllers/invoiceController.js`
- [Return handling](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/salesReturnController.js): `backend/src/controllers/salesReturnController.js`
- [Inventory handling](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/inventoryController.js): `backend/src/controllers/inventoryController.js`
- [Dashboard aggregation](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/dashboardController.js): `backend/src/controllers/dashboardController.js`
- [Report aggregation](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/controllers/reportController.js): `backend/src/controllers/reportController.js`

### POS data

- [POS records](https://github.com/abdur-rouf20/pos-all-in-one/tree/main/backend/src/models): `backend/src/models`
- [Audit attribution](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/utils/audit.js): `backend/src/utils/audit.js`
- [Mongo connection](https://github.com/abdur-rouf20/pos-all-in-one/blob/main/backend/src/config/db.js): `backend/src/config/db.js`

### Other components

- **Owner or staff**
- **MongoDB**

## Connections

- Owner or staff → App routing: uses (evidence: `README.md`)
- App routing → Invoice entry: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Sales returns: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Other POS pages: routes to (evidence: `frontend/src/App.jsx`)
- Invoice entry → API client: calls (evidence: `frontend/src/pages/InvoiceForm.jsx`)
- Sales returns → API client: calls (evidence: `frontend/src/pages/SalesReturns.jsx`)
- Dashboard → API client: calls (evidence: `frontend/src/pages/Dashboard.jsx`)
- Other POS pages → API client: calls (evidence: `frontend/src/pages/InvoiceForm.jsx`)
- API client → Express server: sends requests (evidence: `README.md`)
- Express server → REST routes: mounts (evidence: `backend/src/server.js`)
- Express server → Authentication: protects summary (evidence: `backend/src/server.js`)
- REST routes → Authentication: applies guards (evidence: `backend/src/routes/inventoryRoutes.js`)
- REST routes → Invoice handling: dispatches (evidence: `backend/src/routes/invoiceRoutes.js`)
- REST routes → Return handling: dispatches (evidence: `backend/src/routes/salesReturnRoutes.js`)
- REST routes → Inventory handling: dispatches (evidence: `backend/src/routes/inventoryRoutes.js`)
- Express server → Dashboard aggregation: serves summary (evidence: `backend/src/server.js`)
- Invoice handling → POS records: reads and writes (evidence: `backend/src/controllers/invoiceController.js`)
- Return handling → POS records: reads and writes (evidence: `backend/src/controllers/salesReturnController.js`)
- Inventory handling → POS records: reads and writes (evidence: `backend/src/controllers/inventoryController.js`)
- Dashboard aggregation → POS records: aggregates (evidence: `backend/src/controllers/dashboardController.js`)
- Report aggregation → POS records: aggregates (evidence: `backend/src/controllers/reportController.js`)
- Inventory handling → Audit attribution: records actions (evidence: `backend/src/controllers/inventoryController.js`)
- Return handling → Audit attribution: records actions (evidence: `backend/src/controllers/salesReturnController.js`)
- Audit attribution → POS records: creates logs (evidence: `backend/src/utils/audit.js`)
- Express server → Mongo connection: connects (evidence: `backend/src/server.js`)
- Mongo connection → MongoDB: connects to (evidence: `README.md`)
