# lollllz/ezycaf architecture

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

- Interactive diagram: https://gitdiagram.com/lollllz/ezycaf
- Repository: https://github.com/lollllz/ezycaf

## Overview

EzyCaf is a local-network restaurant ordering system: customers use table QR codes to order, kitchen staff update order progress, and cashiers record service and payment; admins configure branding and menus. The React client connects through a shared socket hook to the Node Hub, which coordinates order validation, security, SQLite state, and optional integrations. The README also documents guided setup, a client-only demo, and optional mobile-data customer access. Some server and client excerpts are partial; optional relay and sync links are shown only where documented or evidenced.

Main entry points: [`server/src/index.js`](https://github.com/lollllz/ezycaf/blob/main/server/src/index.js) (Hub API and sockets), [`client/src/App.tsx`](https://github.com/lollllz/ezycaf/blob/main/client/src/App.tsx) (Route shell), [`client/src/hooks/useSocket.ts`](https://github.com/lollllz/ezycaf/blob/main/client/src/hooks/useSocket.ts) (Live client state), [`client/src/pages/CustomerPage.tsx`](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/CustomerPage.tsx) (Customer ordering)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Restaurant screens"]
  node_app["Route shell<br/>[App.tsx]"]
  node_hubpage["QR board<br/>[HubPage.tsx]"]
  node_customerpage["Customer ordering<br/>[CustomerPage.tsx]"]
  node_customerorders["Order tracking<br/>[CustomerOrders.tsx]"]
  node_kitchen["Kitchen display<br/>[KitchenPage.tsx]"]
  node_cashier["Cashier<br/>[CashierPage.tsx]"]
  node_admin["Menu and branding<br/>[AdminPage.tsx]"]
  node_setupui["Setup guide<br/>[SetupPage.tsx]"]
  node_socket["Live client state<br/>[useSocket.ts]"]
  node_demo["Demo state<br/>[demo.ts]"]
end

subgraph group_hub["LAN hub"]
  node_hubserver["Hub API and sockets<br/>[index.js]"]
  node_ordersvc["Order validation<br/>[order-service.js]"]
end

subgraph group_state["Local state"]
  node_sqlite[("Restaurant database<br/>[db.js]")]
end

subgraph group_setup["Setup and access"]
  node_staffsecurity["Staff access<br/>[staff-security.js]"]
  node_network["LAN addressing<br/>[network-access.js]"]
end

subgraph group_integrations["Optional services"]
  node_customerrelay["Customer relay sync<br/>[customer-relay.js]"]
  node_relayservice["Public customer service<br/>[index.js]"]
  node_supabase["Supabase menu sync<br/>[supabase-sync.js]"]
end

node_customer(("Customer"))
node_staff(("Cafe staff"))

node_customer -->|"opens QR board"| node_hubpage
node_customer -->|"scans table QR"| node_customerpage
node_staff -->|"updates orders"| node_kitchen
node_staff -->|"records payment"| node_cashier
node_staff -->|"manages menu"| node_admin
node_app -->|"uses live state"| node_socket
node_app -->|"routes to"| node_hubpage
node_app -->|"routes to"| node_customerpage
node_app -->|"routes to"| node_kitchen
node_app -->|"routes to"| node_cashier
node_app -->|"routes to"| node_setupui
node_app -->|"routes to"| node_admin
node_app -->|"gates staff screens"| node_staffsecurity
node_customerpage -->|"creates orders"| node_socket
node_customerpage -->|"renders receipts"| node_customerorders
node_customerorders -->|"polls receipt status"| node_hubserver
node_kitchen -->|"reads and updates"| node_socket
node_cashier -->|"reads and updates"| node_socket
node_admin -->|"reads menu state"| node_socket
node_socket -->|"uses demo mode"| node_demo
node_socket -->|"exchanges socket events"| node_hubserver
node_hubserver -->|"validates orders"| node_ordersvc
node_ordersvc -->|"reads and writes orders"| node_sqlite
node_hubserver -->|"reads and writes state"| node_sqlite
node_hubserver -->|"installs access routes"| node_staffsecurity
node_hubserver -->|"gets LAN address"| node_network
node_hubserver -->|"syncs menu"| node_supabase
node_hubserver -->|"handles customer relay"| node_customerrelay
node_hubserver -.->|"publishes customer access"| node_relayservice
node_relayservice -->|"stores snapshots and receipts"| node_sqlite

click node_app "https://github.com/lollllz/ezycaf/blob/main/client/src/App.tsx"
click node_hubpage "https://github.com/lollllz/ezycaf/blob/main/client/src/pages/HubPage.tsx"
click node_customerpage "https://github.com/lollllz/ezycaf/blob/main/client/src/pages/CustomerPage.tsx"
click node_customerorders "https://github.com/lollllz/ezycaf/blob/main/client/src/components/CustomerOrders.tsx"
click node_kitchen "https://github.com/lollllz/ezycaf/blob/main/client/src/pages/KitchenPage.tsx"
click node_cashier "https://github.com/lollllz/ezycaf/blob/main/client/src/pages/CashierPage.tsx"
click node_admin "https://github.com/lollllz/ezycaf/blob/main/client/src/pages/AdminPage.tsx"
click node_setupui "https://github.com/lollllz/ezycaf/blob/main/client/src/pages/SetupPage.tsx"
click node_socket "https://github.com/lollllz/ezycaf/blob/main/client/src/hooks/useSocket.ts"
click node_demo "https://github.com/lollllz/ezycaf/blob/main/client/src/lib/demo.ts"
click node_hubserver "https://github.com/lollllz/ezycaf/blob/main/server/src/index.js"
click node_ordersvc "https://github.com/lollllz/ezycaf/blob/main/server/src/order-service.js"
click node_staffsecurity "https://github.com/lollllz/ezycaf/blob/main/server/src/staff-security.js"
click node_network "https://github.com/lollllz/ezycaf/blob/main/server/src/network-access.js"
click node_sqlite "https://github.com/lollllz/ezycaf/blob/main/server/src/db.js"
click node_customerrelay "https://github.com/lollllz/ezycaf/blob/main/server/src/customer-relay.js"
click node_relayservice "https://github.com/lollllz/ezycaf/blob/main/relay/index.js"
click node_supabase "https://github.com/lollllz/ezycaf/blob/main/server/src/supabase-sync.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_hubpage,node_customerpage,node_customerorders,node_kitchen,node_cashier,node_admin,node_setupui,node_socket,node_demo toneBlue
class node_hubserver,node_ordersvc toneAmber
class node_sqlite toneMint
class node_staffsecurity,node_network toneRose
class node_customerrelay,node_relayservice,node_supabase,node_customer,node_staff toneIndigo
```

## Components

### Restaurant screens

- [Route shell](https://github.com/lollllz/ezycaf/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [QR board](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/HubPage.tsx): `client/src/pages/HubPage.tsx`
- [Customer ordering](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/CustomerPage.tsx): `client/src/pages/CustomerPage.tsx`
- [Order tracking](https://github.com/lollllz/ezycaf/blob/main/client/src/components/CustomerOrders.tsx): `client/src/components/CustomerOrders.tsx`
- [Kitchen display](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/KitchenPage.tsx): `client/src/pages/KitchenPage.tsx`
- [Cashier](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/CashierPage.tsx): `client/src/pages/CashierPage.tsx`
- [Menu and branding](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/AdminPage.tsx): `client/src/pages/AdminPage.tsx`
- [Setup guide](https://github.com/lollllz/ezycaf/blob/main/client/src/pages/SetupPage.tsx): `client/src/pages/SetupPage.tsx`
- [Live client state](https://github.com/lollllz/ezycaf/blob/main/client/src/hooks/useSocket.ts): `client/src/hooks/useSocket.ts`
- [Demo state](https://github.com/lollllz/ezycaf/blob/main/client/src/lib/demo.ts): `client/src/lib/demo.ts`

### LAN hub

- [Hub API and sockets](https://github.com/lollllz/ezycaf/blob/main/server/src/index.js): `server/src/index.js`
- [Order validation](https://github.com/lollllz/ezycaf/blob/main/server/src/order-service.js): `server/src/order-service.js`

### Local state

- [Restaurant database](https://github.com/lollllz/ezycaf/blob/main/server/src/db.js): `server/src/db.js`

### Setup and access

- [Staff access](https://github.com/lollllz/ezycaf/blob/main/server/src/staff-security.js): `server/src/staff-security.js`
- [LAN addressing](https://github.com/lollllz/ezycaf/blob/main/server/src/network-access.js): `server/src/network-access.js`

### Optional services

- [Customer relay sync](https://github.com/lollllz/ezycaf/blob/main/server/src/customer-relay.js): `server/src/customer-relay.js`
- [Public customer service](https://github.com/lollllz/ezycaf/blob/main/relay/index.js): `relay/index.js`
- [Supabase menu sync](https://github.com/lollllz/ezycaf/blob/main/server/src/supabase-sync.js): `server/src/supabase-sync.js`

### Other components

- **Customer**
- **Cafe staff**

## Connections

- Customer → QR board: opens QR board (evidence: `README.md`)
- Customer → Customer ordering: scans table QR (evidence: `README.md`)
- Cafe staff → Kitchen display: updates orders (evidence: `README.md`)
- Cafe staff → Cashier: records payment (evidence: `README.md`)
- Cafe staff → Menu and branding: manages menu (evidence: `README.md`)
- Route shell → Live client state: uses live state (evidence: `client/src/App.tsx`)
- Route shell → QR board: routes to (evidence: `client/src/App.tsx`)
- Route shell → Customer ordering: routes to (evidence: `client/src/App.tsx`)
- Route shell → Kitchen display: routes to (evidence: `client/src/App.tsx`)
- Route shell → Cashier: routes to (evidence: `client/src/App.tsx`)
- Route shell → Setup guide: routes to (evidence: `client/src/App.tsx`)
- Route shell → Menu and branding: routes to (evidence: `client/src/App.tsx`)
- Route shell → Staff access: gates staff screens (evidence: `client/src/App.tsx`)
- Customer ordering → Live client state: creates orders (evidence: `client/src/pages/CustomerPage.tsx`)
- Customer ordering → Order tracking: renders receipts (evidence: `client/src/pages/CustomerPage.tsx`)
- Order tracking → Hub API and sockets: polls receipt status (evidence: `client/src/components/CustomerOrders.tsx`)
- Kitchen display → Live client state: reads and updates (evidence: `client/src/pages/KitchenPage.tsx`)
- Cashier → Live client state: reads and updates (evidence: `client/src/pages/CashierPage.tsx`)
- Menu and branding → Live client state: reads menu state (evidence: `client/src/pages/AdminPage.tsx`)
- Live client state → Demo state: uses demo mode (evidence: `client/src/hooks/useSocket.ts`)
- Live client state → Hub API and sockets: exchanges socket events (evidence: `README.md`)
- Hub API and sockets → Order validation: validates orders (evidence: `server/src/index.js`)
- Order validation → Restaurant database: reads and writes orders (evidence: `server/src/order-service.js`)
- Hub API and sockets → Restaurant database: reads and writes state (evidence: `server/src/index.js`)
- Hub API and sockets → Staff access: installs access routes (evidence: `server/src/index.js`)
- Hub API and sockets → LAN addressing: gets LAN address (evidence: `server/src/index.js`)
- Hub API and sockets → Supabase menu sync: syncs menu (evidence: `server/src/index.js`)
- Hub API and sockets → Customer relay sync: handles customer relay (evidence: `server/src/index.js`)
- Hub API and sockets → Public customer service: publishes customer access
- Public customer service → Restaurant database: stores snapshots and receipts (evidence: `relay/index.js`)
