# msbillings/restaurant-billing architecture

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

- Interactive diagram: https://gitdiagram.com/msbillings/restaurant-billing
- Repository: https://github.com/msbillings/restaurant-billing

## Overview

This repository implements a restaurant POS and billing product, with a separate super-admin portal for managing customer accounts, licenses, and tenant clusters. The main workflow runs from staff POS actions or customer menu/order submissions through backend routes and order processing into tenant-isolated restaurant data, with billing, kitchen/table operations, and notifications. The frontend also supports offline queueing and synchronization. The tree documents broader inventory, analytics, CRM, loyalty, and integrations; excerpts confirm only selected wiring, so uncertain connections are omitted.

Main entry points: [`Backend/routes/publicRoutes.js`](https://github.com/msbillings/restaurant-billing/blob/main/Backend/routes/publicRoutes.js) (Public ordering routes), [`Backend/controllers/orderController.js`](https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/orderController.js) (Order processing), [`Backend/server.js`](https://github.com/msbillings/restaurant-billing/blob/main/Backend/server.js) (API server), [`SuperAdminServer/controllers/clientController.js`](https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/controllers/clientController.js) (Client management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pos["Restaurant POS"]
  node_posui["POS interface<br/>[App.jsx]"]
  node_billingui["Billing screens<br/>[BillingPage.jsx]"]
  node_onlineui["Customer ordering<br/>[CustomerMenu.jsx]"]
  node_offline["Offline sync<br/>[syncEngine.js]"]
  node_localdb[("Offline cache<br/>[offlineDb.js]")]
end

subgraph group_backend["Restaurant Backend"]
  node_api["API server<br/>[server.js]"]
  node_public["Public ordering routes<br/>[publicRoutes.js]"]
  node_orders["Order processing<br/>[orderController.js]"]
  node_billing[("Billing records<br/>[Bill.js]")]
  node_floor["Floor operations<br/>[floorController.js]"]
  node_inventory["Inventory operations"]
  node_tax["Tax calculation<br/>[billHelpers.js]"]
  node_printing["Kitchen printing<br/>[printerService.js]"]
  node_notify["Live notifications"]
  node_features["Restaurant features"]
  node_integrations["WhatsApp service<br/>[whatsappService.js]"]
end

subgraph group_platform["Tenant Platform"]
  node_tenant["Tenant resolution<br/>[tenantManager.js]"]
  node_restaurantdb[("Restaurant data<br/>[Bill.js]")]
end

subgraph group_admin["Super Admin"]
  node_superui["Admin portal<br/>[App.jsx]"]
  node_superapi["Admin server<br/>[server.js]"]
  node_clients["Client management"]
  node_licenses[("License records<br/>[License.js]")]
  node_cluster["Tenant cluster access<br/>[clusterManager.js]"]
  node_tenantusers[("Tenant user accounts")]
end

node_staff(("Restaurant staff"))
node_customers(("Online customers"))

node_staff -->|"uses"| node_posui
node_posui -->|"opens"| node_billingui
node_billingui -->|"requests"| node_api
node_customers -->|"orders through"| node_onlineui
node_onlineui -->|"submits orders"| node_api
node_api -->|"dispatches"| node_public
node_public -->|"creates bill"| node_billing
node_public -->|"updates status"| node_floor
node_public -->|"prints KOT"| node_printing
node_public -->|"emits alerts"| node_notify
node_api -->|"dispatches"| node_orders
node_orders -->|"reads and writes"| node_billing
node_orders -->|"gets tax rate"| node_tax
node_orders -->|"deducts stock"| node_inventory
node_orders -->|"updates table"| node_floor
node_orders -->|"persists via tenant model"| node_restaurantdb
node_public -->|"resolves models"| node_tenant
node_tenant -->|"selects tenant data"| node_restaurantdb
node_offline -->|"replays queued requests"| node_api
node_offline -->|"reads and updates queue"| node_localdb
node_offline -->|"caches menu data"| node_localdb
node_posui -->|"presents product areas"| node_features
node_superui -->|"manages platform"| node_superapi
node_superapi -->|"dispatches"| node_clients
node_clients -->|"creates licenses"| node_licenses
node_clients -->|"opens tenant database"| node_cluster
node_clients -->|"provisions accounts"| node_tenantusers

click node_posui "https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/App.jsx"
click node_billingui "https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/components/BillingPage.jsx"
click node_onlineui "https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/components/CustomerMenu.jsx"
click node_offline "https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/utils/syncEngine.js"
click node_localdb "https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/db/offlineDb.js"
click node_api "https://github.com/msbillings/restaurant-billing/blob/main/Backend/server.js"
click node_public "https://github.com/msbillings/restaurant-billing/blob/main/Backend/routes/publicRoutes.js"
click node_orders "https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/orderController.js"
click node_billing "https://github.com/msbillings/restaurant-billing/blob/main/Backend/models/Bill.js"
click node_floor "https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/floorController.js"
click node_inventory "https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/inventoryController.js"
click node_tax "https://github.com/msbillings/restaurant-billing/blob/main/Backend/utils/billHelpers.js"
click node_printing "https://github.com/msbillings/restaurant-billing/blob/main/Backend/services/printerService.js"
click node_notify "https://github.com/msbillings/restaurant-billing/blob/main/Backend/utils/notificationHelper.js"
click node_tenant "https://github.com/msbillings/restaurant-billing/blob/main/Backend/utils/tenantManager.js"
click node_restaurantdb "https://github.com/msbillings/restaurant-billing/blob/main/Backend/models/Bill.js"
click node_features "https://github.com/msbillings/restaurant-billing/tree/main/Backend/controllers"
click node_integrations "https://github.com/msbillings/restaurant-billing/blob/main/Backend/services/whatsappService.js"
click node_superui "https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminFrontend/src/App.jsx"
click node_superapi "https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/server.js"
click node_clients "https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/controllers/clientController.js"
click node_licenses "https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/models/License.js"
click node_cluster "https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/utils/clusterManager.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_posui,node_billingui,node_onlineui,node_offline,node_localdb toneBlue
class node_api,node_public,node_orders,node_billing,node_floor,node_inventory,node_tax,node_printing,node_notify,node_features,node_integrations toneAmber
class node_tenant,node_restaurantdb toneMint
class node_superui,node_superapi,node_clients,node_licenses,node_cluster,node_tenantusers toneRose
class node_staff,node_customers toneIndigo
```

## Components

### Restaurant POS

- [POS interface](https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/App.jsx): `Frontend/src/App.jsx`
- [Billing screens](https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/components/BillingPage.jsx): `Frontend/src/components/BillingPage.jsx`
- [Customer ordering](https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/components/CustomerMenu.jsx): `Frontend/src/components/CustomerMenu.jsx`
- [Offline sync](https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/utils/syncEngine.js): `Frontend/src/utils/syncEngine.js`
- [Offline cache](https://github.com/msbillings/restaurant-billing/blob/main/Frontend/src/db/offlineDb.js): `Frontend/src/db/offlineDb.js`

### Restaurant Backend

- [API server](https://github.com/msbillings/restaurant-billing/blob/main/Backend/server.js): `Backend/server.js`
- [Public ordering routes](https://github.com/msbillings/restaurant-billing/blob/main/Backend/routes/publicRoutes.js): `Backend/routes/publicRoutes.js`
- [Order processing](https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/orderController.js): `Backend/controllers/orderController.js`
- [Billing records](https://github.com/msbillings/restaurant-billing/blob/main/Backend/models/Bill.js): `Backend/models/Bill.js`
- [Floor operations](https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/floorController.js): `Backend/controllers/floorController.js`
- [Inventory operations](https://github.com/msbillings/restaurant-billing/blob/main/Backend/controllers/inventoryController.js): `Backend/controllers/inventoryController.js`
- [Tax calculation](https://github.com/msbillings/restaurant-billing/blob/main/Backend/utils/billHelpers.js): `Backend/utils/billHelpers.js`
- [Kitchen printing](https://github.com/msbillings/restaurant-billing/blob/main/Backend/services/printerService.js): `Backend/services/printerService.js`
- [Live notifications](https://github.com/msbillings/restaurant-billing/blob/main/Backend/utils/notificationHelper.js): `Backend/utils/notificationHelper.js`
- [Restaurant features](https://github.com/msbillings/restaurant-billing/tree/main/Backend/controllers): `Backend/controllers`
- [WhatsApp service](https://github.com/msbillings/restaurant-billing/blob/main/Backend/services/whatsappService.js): `Backend/services/whatsappService.js`

### Tenant Platform

- [Tenant resolution](https://github.com/msbillings/restaurant-billing/blob/main/Backend/utils/tenantManager.js): `Backend/utils/tenantManager.js`
- [Restaurant data](https://github.com/msbillings/restaurant-billing/blob/main/Backend/models/Bill.js): `Backend/models/Bill.js`

### Super Admin

- [Admin portal](https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminFrontend/src/App.jsx): `SuperAdminFrontend/src/App.jsx`
- [Admin server](https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/server.js): `SuperAdminServer/server.js`
- [Client management](https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/controllers/clientController.js): `SuperAdminServer/controllers/clientController.js`
- [License records](https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/models/License.js): `SuperAdminServer/models/License.js`
- [Tenant cluster access](https://github.com/msbillings/restaurant-billing/blob/main/SuperAdminServer/utils/clusterManager.js): `SuperAdminServer/utils/clusterManager.js`
- **Tenant user accounts**

### Other components

- **Restaurant staff**
- **Online customers**

## Connections

- Restaurant staff → POS interface: uses
- POS interface → Billing screens: opens
- Billing screens → API server: requests
- Online customers → Customer ordering: orders through
- Customer ordering → API server: submits orders
- API server → Public ordering routes: dispatches
- Public ordering routes → Billing records: creates bill
- Public ordering routes → Floor operations: updates status
- Public ordering routes → Kitchen printing: prints KOT
- Public ordering routes → Live notifications: emits alerts
- API server → Order processing: dispatches
- Order processing → Billing records: reads and writes
- Order processing → Tax calculation: gets tax rate
- Order processing → Inventory operations: deducts stock
- Order processing → Floor operations: updates table
- Order processing → Restaurant data: persists via tenant model
- Public ordering routes → Tenant resolution: resolves models
- Tenant resolution → Restaurant data: selects tenant data
- Offline sync → API server: replays queued requests
- Offline sync → Offline cache: reads and updates queue
- Offline sync → Offline cache: caches menu data
- POS interface → Restaurant features: presents product areas
- Admin portal → Admin server: manages platform
- Admin server → Client management: dispatches
- Client management → License records: creates licenses
- Client management → Tenant cluster access: opens tenant database
- Client management → Tenant user accounts: provisions accounts
