# sharlr/bms architecture

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

## Overview

BMS is a multi-tenant restaurant management and POS system. Staff or customers use tenant-specific web workflows; requests pass through tenant resolution and authentication before reaching restaurant operations such as sales, kitchen, inventory, billing and reporting. A separate platform workflow provisions tenant databases, while the web app also provides kiosk, customer ordering, KDS and back-office screens. The README documents product capabilities beyond the sampled implementation; those branches are represented without inferring unsampled call chains. Edges cite the README or source-index/read evidence where available.

Main entry points: [`backend/src/server.ts`](https://github.com/sharlr/bms/blob/main/backend/src/server.ts) (HTTP API), [`backend/src/modules/pos.ts`](https://github.com/sharlr/bms/blob/main/backend/src/modules/pos.ts) (POS and billing), [`frontend/src/api.ts`](https://github.com/sharlr/bms/blob/main/frontend/src/api.ts) (API client), [`frontend/src/main.tsx`](https://github.com/sharlr/bms/blob/main/frontend/src/main.tsx) (Web app entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workflows"]
  node_web_entry["Web app entry<br/>[main.tsx]"]
  node_staff_session["Staff session<br/>[session.tsx]"]
  node_pos_ui["POS and terminals<br/>[Pos.tsx]"]
  node_customer_ui["Customer ordering<br/>[Customer.tsx]"]
  node_admin_ui["Back office<br/>[AdminApp.tsx]"]
  node_web_api["API client<br/>[api.ts]"]
end

subgraph group_api["API and access"]
  node_api_server["HTTP API<br/>[server.ts]"]
  node_tenant_context["Tenant context<br/>[context.ts]"]
  node_authentication["Authentication<br/>[auth.ts]"]
end

subgraph group_operations["Restaurant operations"]
  node_sales["POS and billing<br/>[pos.ts]"]
  node_kitchen["Kitchen and KOT<br/>[kitchen.ts]"]
  node_inventory["Inventory and stock<br/>[inventory.ts]"]
  node_menu_resources["Menu and resources"]
  node_reservations["Reservations<br/>[reservations.ts]"]
  node_finance_reports["Finance and reports<br/>[reports.ts]"]
end

subgraph group_platform["Tenant platform"]
  node_platform_ops["Platform operations<br/>[platform.ts]"]
  node_provisioning["Tenant provisioning<br/>[provision.ts]"]
end

subgraph group_infra["Persistence and integrations"]
  node_tenant_pools[("Tenant database pools<br/>[pools.ts]")]
  node_ticket_service["Ticket service<br/>[tickets.ts]"]
  node_print_agent["LAN print agent<br/>[agent.mjs]"]
end

node_staff(("Restaurant staff"))
node_customers(("Customers"))
node_platform_admin(("Platform admin"))

node_staff -->|"uses"| node_web_entry
node_customers -->|"orders through"| node_customer_ui
node_platform_admin -->|"manages tenants"| node_platform_ops
node_web_entry -->|"routes to"| node_pos_ui
node_web_entry -->|"routes to"| node_customer_ui
node_web_entry -->|"routes to"| node_admin_ui
node_staff -->|"signs in"| node_staff_session
node_staff_session -->|"requests session"| node_web_api
node_pos_ui -->|"sends operations"| node_web_api
node_customer_ui -->|"sends orders"| node_web_api
node_admin_ui -->|"requests admin data"| node_web_api
node_web_api -->|"HTTP requests"| node_api_server
node_api_server -->|"runs tenant hook"| node_tenant_context
node_api_server -->|"registers routes"| node_authentication
node_api_server -->|"registers routes"| node_sales
node_api_server -->|"registers routes"| node_kitchen
node_api_server -->|"registers routes"| node_inventory
node_api_server -->|"registers routes"| node_menu_resources
node_api_server -->|"registers routes"| node_reservations
node_api_server -->|"registers routes"| node_finance_reports
node_api_server -->|"registers routes"| node_platform_ops
node_tenant_context -->|"resolves tenant"| node_tenant_pools
node_authentication -->|"uses access context"| node_tenant_context
node_sales -->|"uses tickets"| node_ticket_service
node_platform_ops -->|"provisions tenants"| node_provisioning
node_provisioning -->|"configures tenant pools"| node_tenant_pools
node_sales -.->|"routes KOT"| node_kitchen
node_sales -.->|"records stock impact"| node_inventory
node_sales -.->|"prints receipts"| node_print_agent
node_kitchen -.->|"prints kitchen tickets"| node_print_agent

click node_web_entry "https://github.com/sharlr/bms/blob/main/frontend/src/main.tsx"
click node_staff_session "https://github.com/sharlr/bms/blob/main/frontend/src/session.tsx"
click node_pos_ui "https://github.com/sharlr/bms/blob/main/frontend/src/pages/Pos.tsx"
click node_customer_ui "https://github.com/sharlr/bms/blob/main/frontend/src/pages/Customer.tsx"
click node_admin_ui "https://github.com/sharlr/bms/blob/main/frontend/src/pages/admin/AdminApp.tsx"
click node_web_api "https://github.com/sharlr/bms/blob/main/frontend/src/api.ts"
click node_api_server "https://github.com/sharlr/bms/blob/main/backend/src/server.ts"
click node_tenant_context "https://github.com/sharlr/bms/blob/main/backend/src/plugins/context.ts"
click node_authentication "https://github.com/sharlr/bms/blob/main/backend/src/modules/auth.ts"
click node_sales "https://github.com/sharlr/bms/blob/main/backend/src/modules/pos.ts"
click node_kitchen "https://github.com/sharlr/bms/blob/main/backend/src/modules/kitchen.ts"
click node_inventory "https://github.com/sharlr/bms/blob/main/backend/src/modules/inventory.ts"
click node_menu_resources "https://github.com/sharlr/bms/tree/main/backend/src/modules"
click node_reservations "https://github.com/sharlr/bms/blob/main/backend/src/modules/reservations.ts"
click node_finance_reports "https://github.com/sharlr/bms/blob/main/backend/src/modules/reports.ts"
click node_platform_ops "https://github.com/sharlr/bms/blob/main/backend/src/modules/platform.ts"
click node_provisioning "https://github.com/sharlr/bms/blob/main/backend/src/master/provision.ts"
click node_tenant_pools "https://github.com/sharlr/bms/blob/main/backend/src/master/pools.ts"
click node_ticket_service "https://github.com/sharlr/bms/blob/main/backend/src/services/tickets.ts"
click node_print_agent "https://github.com/sharlr/bms/blob/main/print-agent/agent.mjs"

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_web_entry,node_staff_session,node_pos_ui,node_customer_ui,node_admin_ui,node_web_api toneBlue
class node_api_server,node_tenant_context,node_authentication toneAmber
class node_sales,node_kitchen,node_inventory,node_menu_resources,node_reservations,node_finance_reports toneMint
class node_platform_ops,node_provisioning toneRose
class node_tenant_pools,node_ticket_service,node_print_agent,node_staff,node_customers,node_platform_admin toneIndigo
```

## Components

### Web workflows

- [Web app entry](https://github.com/sharlr/bms/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Staff session](https://github.com/sharlr/bms/blob/main/frontend/src/session.tsx): `frontend/src/session.tsx`
- [POS and terminals](https://github.com/sharlr/bms/blob/main/frontend/src/pages/Pos.tsx): `frontend/src/pages/Pos.tsx`
- [Customer ordering](https://github.com/sharlr/bms/blob/main/frontend/src/pages/Customer.tsx): `frontend/src/pages/Customer.tsx`
- [Back office](https://github.com/sharlr/bms/blob/main/frontend/src/pages/admin/AdminApp.tsx): `frontend/src/pages/admin/AdminApp.tsx`
- [API client](https://github.com/sharlr/bms/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### API and access

- [HTTP API](https://github.com/sharlr/bms/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Tenant context](https://github.com/sharlr/bms/blob/main/backend/src/plugins/context.ts): `backend/src/plugins/context.ts`
- [Authentication](https://github.com/sharlr/bms/blob/main/backend/src/modules/auth.ts): `backend/src/modules/auth.ts`

### Restaurant operations

- [POS and billing](https://github.com/sharlr/bms/blob/main/backend/src/modules/pos.ts): `backend/src/modules/pos.ts`
- [Kitchen and KOT](https://github.com/sharlr/bms/blob/main/backend/src/modules/kitchen.ts): `backend/src/modules/kitchen.ts`
- [Inventory and stock](https://github.com/sharlr/bms/blob/main/backend/src/modules/inventory.ts): `backend/src/modules/inventory.ts`
- [Menu and resources](https://github.com/sharlr/bms/tree/main/backend/src/modules): `backend/src/modules`
- [Reservations](https://github.com/sharlr/bms/blob/main/backend/src/modules/reservations.ts): `backend/src/modules/reservations.ts`
- [Finance and reports](https://github.com/sharlr/bms/blob/main/backend/src/modules/reports.ts): `backend/src/modules/reports.ts`

### Tenant platform

- [Platform operations](https://github.com/sharlr/bms/blob/main/backend/src/modules/platform.ts): `backend/src/modules/platform.ts`
- [Tenant provisioning](https://github.com/sharlr/bms/blob/main/backend/src/master/provision.ts): `backend/src/master/provision.ts`

### Persistence and integrations

- [Tenant database pools](https://github.com/sharlr/bms/blob/main/backend/src/master/pools.ts): `backend/src/master/pools.ts`
- [Ticket service](https://github.com/sharlr/bms/blob/main/backend/src/services/tickets.ts): `backend/src/services/tickets.ts`
- [LAN print agent](https://github.com/sharlr/bms/blob/main/print-agent/agent.mjs): `print-agent/agent.mjs`

### Other components

- **Restaurant staff**
- **Customers**
- **Platform admin**

## Connections

- Restaurant staff → Web app entry: uses
- Customers → Customer ordering: orders through
- Platform admin → Platform operations: manages tenants
- Web app entry → POS and terminals: routes to (evidence: `frontend/src/main.tsx`)
- Web app entry → Customer ordering: routes to (evidence: `frontend/src/main.tsx`)
- Web app entry → Back office: routes to (evidence: `frontend/src/main.tsx`)
- Restaurant staff → Staff session: signs in
- Staff session → API client: requests session (evidence: `frontend/src/session.tsx`)
- POS and terminals → API client: sends operations (evidence: `frontend/src/pages/Pos.tsx`)
- Customer ordering → API client: sends orders (evidence: `frontend/src/pages/Customer.tsx`)
- Back office → API client: requests admin data (evidence: `frontend/src/pages/admin/AdminApp.tsx`)
- API client → HTTP API: HTTP requests
- HTTP API → Tenant context: runs tenant hook (evidence: `backend/src/server.ts`)
- HTTP API → Authentication: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → POS and billing: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → Kitchen and KOT: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → Inventory and stock: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → Menu and resources: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → Reservations: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → Finance and reports: registers routes (evidence: `backend/src/server.ts`)
- HTTP API → Platform operations: registers routes (evidence: `backend/src/server.ts`)
- Tenant context → Tenant database pools: resolves tenant (evidence: `backend/src/plugins/context.ts`)
- Authentication → Tenant context: uses access context (evidence: `backend/src/modules/auth.ts`)
- POS and billing → Ticket service: uses tickets (evidence: `backend/src/modules/pos.ts`)
- Platform operations → Tenant provisioning: provisions tenants
- Tenant provisioning → Tenant database pools: configures tenant pools (evidence: `backend/src/master/provision.ts`)
- POS and billing → Kitchen and KOT: routes KOT
- POS and billing → Inventory and stock: records stock impact
- POS and billing → LAN print agent: prints receipts
- Kitchen and KOT → LAN print agent: prints kitchen tickets
