# antonious-sameh/tahoonaaaaback architecture

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

- Interactive diagram: https://gitdiagram.com/antonious-sameh/tahoonaaaaback
- Repository: https://github.com/antonious-sameh/tahoonaaaaback

## Overview

System 1 is a single-shop inventory, point-of-sale, and bookkeeping backend built with Express and MongoDB. A client request enters the shared API app, is routed to an endpoint and its domain service, and returns operational data or reports; authentication protects shop operations. Major documented areas include inventory, people and balances, sales and purchases, returns, cashbox and expenses, reporting, settings, uploads, and audit/activity records. Source excerpts show app wiring, authentication, person routing, and reporting; some domain links below rely on README documentation and the source index.

Main entry points: [`src/routes/index.js`](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/routes/index.js) (API Routes), [`src/config/db.js`](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/config/db.js) (MongoDB), [`src/services/auditLog.service.js`](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/auditLog.service.js) (Audit Trail), [`src/services/auth.service.js`](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/auth.service.js) (Auth and Devices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and Routing"]
  node_app["Express App<br/>[app.js]"]
  node_routes["API Routes<br/>[index.js]"]
  node_auth_route["Auth Routes<br/>[auth.route.js]"]
  node_auth_controller["Auth Controller<br/>[auth.controller.js]"]
end

subgraph group_security["Shop Access"]
  node_auth_service["Auth and Devices<br/>[auth.service.js]"]
  node_auth_models[("Shop Credentials<br/>[ShopAuth.js]")]
  node_device_models[("Device Sessions<br/>[DeviceSession.js]")]
end

subgraph group_commerce["Commerce Operations"]
  node_product_ops["Products and Inventory<br/>[product.service.js]"]
  node_people_ops["Customers and Suppliers<br/>[personService.js]"]
  node_sales_ops["Sales and Returns<br/>[sale.service.js]"]
  node_purchases_ops["Purchases and Returns"]
end

subgraph group_finance["Finance and Insights"]
  node_customer_finance["Customer Settlements"]
  node_supplier_finance["Supplier Settlements"]
  node_cashbox["Cashbox and Expenses<br/>[cashbox.service.js]"]
  node_reports["Reports<br/>[reports.service.js]"]
end

subgraph group_platform["Persistence and Support"]
  node_settings["Shop Settings"]
  node_uploads["Product Image Uploads<br/>[upload.service.js]"]
  node_activity["Activity Feed"]
  node_audit["Audit Trail"]
  node_mongo[("MongoDB<br/>[db.js]")]
end

node_client(("Shop Client"))
node_cloudinary["Cloudinary"]

node_client -->|"sends request"| node_app
node_app -->|"mounts API"| node_routes
node_routes -->|"mounts auth"| node_auth_route
node_auth_route -->|"dispatches"| node_auth_controller
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"reads and writes"| node_auth_models
node_auth_service -->|"manages sessions"| node_device_models
node_routes -->|"routes inventory"| node_product_ops
node_routes -->|"routes people"| node_people_ops
node_routes -->|"routes sales"| node_sales_ops
node_routes -->|"routes purchases"| node_purchases_ops
node_routes -->|"routes payments"| node_customer_finance
node_routes -->|"routes settlements"| node_supplier_finance
node_routes -->|"routes cashbox"| node_cashbox
node_routes -->|"routes reports"| node_reports
node_routes -->|"routes settings"| node_settings
node_routes -->|"routes uploads"| node_uploads
node_routes -->|"routes activity"| node_activity
node_routes -->|"routes audit"| node_audit
node_product_ops -->|"persists inventory"| node_mongo
node_people_ops -->|"persists people"| node_mongo
node_sales_ops -->|"records transactions"| node_mongo
node_purchases_ops -->|"records transactions"| node_mongo
node_customer_finance -->|"records settlements"| node_mongo
node_supplier_finance -->|"records settlements"| node_mongo
node_cashbox -->|"stores cash activity"| node_mongo
node_reports -->|"aggregates records"| node_mongo
node_uploads -.->|"requests signature"| node_cloudinary
node_activity -->|"records activity"| node_mongo
node_audit -->|"records audit events"| node_mongo
node_auth_service -->|"records auth events"| node_audit
node_sales_ops -->|"records mutations"| node_audit
node_purchases_ops -->|"records mutations"| node_audit

click node_app "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/app.js"
click node_routes "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/routes/index.js"
click node_auth_route "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/routes/auth.route.js"
click node_auth_controller "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/controllers/auth.controller.js"
click node_auth_service "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/auth.service.js"
click node_auth_models "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/models/ShopAuth.js"
click node_device_models "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/models/DeviceSession.js"
click node_product_ops "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/product.service.js"
click node_people_ops "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/personService.js"
click node_sales_ops "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/sale.service.js"
click node_purchases_ops "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/purchase.service.js"
click node_customer_finance "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/customerPayment.service.js"
click node_supplier_finance "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/supplierPayment.service.js"
click node_cashbox "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/cashbox.service.js"
click node_reports "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/reports.service.js"
click node_settings "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/settings.service.js"
click node_uploads "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/upload.service.js"
click node_activity "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/activityLog.service.js"
click node_audit "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/auditLog.service.js"
click node_mongo "https://github.com/antonious-sameh/tahoonaaaaback/blob/main/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_routes,node_auth_route,node_auth_controller,node_client toneBlue
class node_auth_service,node_auth_models,node_device_models toneAmber
class node_product_ops,node_people_ops,node_sales_ops,node_purchases_ops toneMint
class node_customer_finance,node_supplier_finance,node_cashbox,node_reports toneRose
class node_settings,node_uploads,node_activity,node_audit,node_mongo,node_cloudinary toneIndigo
```

## Components

### API and Routing

- [Express App](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/app.js): `src/app.js`
- [API Routes](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/routes/index.js): `src/routes/index.js`
- [Auth Routes](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/routes/auth.route.js): `src/routes/auth.route.js`
- [Auth Controller](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/controllers/auth.controller.js): `src/controllers/auth.controller.js`

### Shop Access

- [Auth and Devices](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/auth.service.js): `src/services/auth.service.js`
- [Shop Credentials](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/models/ShopAuth.js): `src/models/ShopAuth.js`
- [Device Sessions](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/models/DeviceSession.js): `src/models/DeviceSession.js`

### Commerce Operations

- [Products and Inventory](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/product.service.js): `src/services/product.service.js`
- [Customers and Suppliers](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/personService.js): `src/services/personService.js`
- [Sales and Returns](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/sale.service.js): `src/services/sale.service.js`
- [Purchases and Returns](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/purchase.service.js): `src/services/purchase.service.js`

### Finance and Insights

- [Customer Settlements](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/customerPayment.service.js): `src/services/customerPayment.service.js`
- [Supplier Settlements](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/supplierPayment.service.js): `src/services/supplierPayment.service.js`
- [Cashbox and Expenses](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/cashbox.service.js): `src/services/cashbox.service.js`
- [Reports](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/reports.service.js): `src/services/reports.service.js`

### Persistence and Support

- [Shop Settings](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/settings.service.js): `src/services/settings.service.js`
- [Product Image Uploads](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/upload.service.js): `src/services/upload.service.js`
- [Activity Feed](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/activityLog.service.js): `src/services/activityLog.service.js`
- [Audit Trail](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/services/auditLog.service.js): `src/services/auditLog.service.js`
- [MongoDB](https://github.com/antonious-sameh/tahoonaaaaback/blob/main/src/config/db.js): `src/config/db.js`

### Other components

- **Shop Client**
- **Cloudinary**

## Connections

- Shop Client → Express App: sends request
- Express App → API Routes: mounts API (evidence: `src/app.js`)
- API Routes → Auth Routes: mounts auth (evidence: `src/routes/index.js`)
- Auth Routes → Auth Controller: dispatches (evidence: `src/routes/auth.route.js`)
- Auth Controller → Auth and Devices: calls (evidence: `src/controllers/auth.controller.js`)
- Auth and Devices → Shop Credentials: reads and writes (evidence: `src/services/auth.service.js`)
- Auth and Devices → Device Sessions: manages sessions (evidence: `src/services/auth.service.js`)
- API Routes → Products and Inventory: routes inventory (evidence: `src/routes/index.js`)
- API Routes → Customers and Suppliers: routes people (evidence: `src/routes/index.js`)
- API Routes → Sales and Returns: routes sales (evidence: `src/routes/index.js`)
- API Routes → Purchases and Returns: routes purchases (evidence: `src/routes/index.js`)
- API Routes → Customer Settlements: routes payments (evidence: `src/routes/index.js`)
- API Routes → Supplier Settlements: routes settlements (evidence: `src/routes/index.js`)
- API Routes → Cashbox and Expenses: routes cashbox (evidence: `src/routes/index.js`)
- API Routes → Reports: routes reports (evidence: `src/routes/index.js`)
- API Routes → Shop Settings: routes settings (evidence: `src/routes/index.js`)
- API Routes → Product Image Uploads: routes uploads (evidence: `src/routes/index.js`)
- API Routes → Activity Feed: routes activity (evidence: `src/routes/index.js`)
- API Routes → Audit Trail: routes audit (evidence: `src/routes/index.js`)
- Products and Inventory → MongoDB: persists inventory
- Customers and Suppliers → MongoDB: persists people (evidence: `src/services/personService.js`)
- Sales and Returns → MongoDB: records transactions
- Purchases and Returns → MongoDB: records transactions
- Customer Settlements → MongoDB: records settlements
- Supplier Settlements → MongoDB: records settlements
- Cashbox and Expenses → MongoDB: stores cash activity
- Reports → MongoDB: aggregates records (evidence: `src/services/reports.service.js`)
- Product Image Uploads → Cloudinary: requests signature
- Activity Feed → MongoDB: records activity (evidence: `src/services/activityLog.service.js`)
- Audit Trail → MongoDB: records audit events (evidence: `src/services/auditLog.service.js`)
- Auth and Devices → Audit Trail: records auth events (evidence: `src/services/auth.service.js`)
- Sales and Returns → Audit Trail: records mutations
- Purchases and Returns → Audit Trail: records mutations
