# seven742/restaurant-qr-ordering architecture

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

- Interactive diagram: https://gitdiagram.com/seven742/restaurant-qr-ordering
- Repository: https://github.com/seven742/restaurant-qr-ordering

## Overview

This is a Next.js QR-based restaurant ordering system. Customers scan a table QR code, browse the menu, build a cart, submit an order, and view order status/history; staff and admins manage orders, menu, tables, settings, and analytics. The sampled ordering client and order API show the principal flow, including server-side price lookup and transactional persistence. The README documents broader admin capabilities; some of their page and route implementations were not sampled, so those links are documented rather than inferred from unseen calls.

Main entry points: [`app/order/OrderClient.js`](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/order/OrderClient.js) (Menu ordering), [`app/admin`](https://github.com/seven742/restaurant-qr-ordering/tree/main/app/admin) (Admin dashboard), [`app/api/orders/route.js`](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/orders/route.js) (Order API), [`lib/auth.js`](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/auth.js) (Session and roles)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer ordering"]
  node_orderclient["Menu ordering<br/>[OrderClient.js]"]
  node_cart["Cart checkout<br/>[Cart.js]"]
  node_confirmation["Order confirmation"]
  node_history["Order history<br/>[OrderHistory.js]"]
end

subgraph group_admin["Restaurant operations"]
  node_adminpages["Admin dashboard"]
  node_menuadmin["Menu management<br/>[page.js]"]
  node_orderadmin["Order management<br/>[page.js]"]
  node_tableadmin["Table management<br/>[page.js]"]
  node_settingsadmin["Restaurant settings<br/>[page.js]"]
end

subgraph group_api["API endpoints"]
  node_dashboardapi["Analytics API<br/>[route.js]"]
  node_ordersapi["Order API<br/>[route.js]"]
  node_orderstatusapi["Order status API<br/>[route.js]"]
  node_productsapi["Product API<br/>[route.js]"]
  node_categoriesapi["Category API<br/>[route.js]"]
  node_tablesapi["Table API<br/>[route.js]"]
  node_settingsapi["Settings API<br/>[route.js]"]
  node_uploadapi["Image upload API<br/>[route.js]"]
  node_authapi["Authentication API<br/>[route.js]"]
end

subgraph group_services["Shared services"]
  node_cartstate["Cart state<br/>[cart.js]"]
  node_lang["Translations<br/>[i18n.js]"]
  node_clientapi["Browser API client<br/>[client.js]"]
  node_auth["Session and roles<br/>[auth.js]"]
  node_jwt["JWT handling<br/>[jwt.js]"]
  node_validation["Request validation<br/>[validate.js]"]
  node_apiresponse["API responses<br/>[api.js]"]
  node_orderservice["Order item loading<br/>[orders.js]"]
end

subgraph group_storage["Persistence"]
  node_database[("MySQL database<br/>[db.js]")]
end

node_customer(("QR customer"))
node_adminstaff(("Admin and staff"))
node_cloudinary["Cloudinary"]

node_customer -->|"scans QR"| node_orderclient
node_orderclient -->|"loads menu data"| node_clientapi
node_orderclient -->|"opens checkout"| node_cart
node_orderclient -->|"uses cart state"| node_cartstate
node_orderclient -->|"translates UI"| node_lang
node_cart -->|"reads and clears"| node_cartstate
node_cart -->|"submits order"| node_clientapi
node_clientapi -->|"posts order"| node_ordersapi
node_cart -->|"sets placed order"| node_confirmation
node_orderclient -->|"shows history"| node_history
node_adminstaff -->|"manages restaurant"| node_adminpages
node_adminpages -->|"routes to menu"| node_menuadmin
node_adminpages -->|"routes to orders"| node_orderadmin
node_adminpages -->|"routes to tables"| node_tableadmin
node_adminpages -->|"routes to settings"| node_settingsadmin
node_menuadmin -->|"manages products"| node_productsapi
node_menuadmin -->|"manages categories"| node_categoriesapi
node_menuadmin -->|"uploads images"| node_uploadapi
node_orderadmin -->|"views orders"| node_ordersapi
node_orderadmin -->|"updates status"| node_orderstatusapi
node_tableadmin -->|"manages tables"| node_tablesapi
node_settingsadmin -->|"configures restaurant"| node_settingsapi
node_adminpages -->|"loads analytics"| node_dashboardapi
node_ordersapi -->|"queries and writes"| node_database
node_ordersapi -->|"validates input"| node_validation
node_ordersapi -->|"checks staff role"| node_auth
node_ordersapi -->|"attaches items"| node_orderservice
node_productsapi -->|"queries and writes"| node_database
node_productsapi -->|"checks admin role"| node_auth
node_productsapi -->|"validates input"| node_validation
node_tablesapi -->|"queries and writes"| node_database
node_tablesapi -->|"checks staff role"| node_auth
node_authapi -->|"sets session"| node_auth
node_auth -->|"signs and verifies"| node_jwt
node_dashboardapi -->|"reads metrics"| node_database
node_dashboardapi -->|"checks role"| node_auth
node_uploadapi -.->|"stores images"| node_cloudinary

click node_orderclient "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/order/OrderClient.js"
click node_cart "https://github.com/seven742/restaurant-qr-ordering/blob/main/components/customer/Cart.js"
click node_confirmation "https://github.com/seven742/restaurant-qr-ordering/blob/main/components/customer/OrderConfirmation.js"
click node_history "https://github.com/seven742/restaurant-qr-ordering/blob/main/components/customer/OrderHistory.js"
click node_cartstate "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/cart.js"
click node_lang "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/i18n.js"
click node_clientapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/client.js"
click node_adminpages "https://github.com/seven742/restaurant-qr-ordering/tree/main/app/admin"
click node_menuadmin "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/menu/page.js"
click node_orderadmin "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/orders/page.js"
click node_tableadmin "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/tables/page.js"
click node_settingsadmin "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/settings/page.js"
click node_dashboardapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/admin/dashboard/route.js"
click node_ordersapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/orders/route.js"
click node_orderstatusapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/orders/%5Bid%5D/status/route.js"
click node_productsapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/products/route.js"
click node_categoriesapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/categories/route.js"
click node_tablesapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/tables/route.js"
click node_settingsapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/settings/route.js"
click node_uploadapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/upload/route.js"
click node_authapi "https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/auth/login/route.js"
click node_auth "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/auth.js"
click node_jwt "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/jwt.js"
click node_validation "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/validate.js"
click node_apiresponse "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/api.js"
click node_orderservice "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/orders.js"
click node_database "https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/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_orderclient,node_cart,node_confirmation,node_history toneBlue
class node_adminpages,node_menuadmin,node_orderadmin,node_tableadmin,node_settingsadmin toneAmber
class node_dashboardapi,node_ordersapi,node_orderstatusapi,node_productsapi,node_categoriesapi,node_tablesapi,node_settingsapi,node_uploadapi,node_authapi toneMint
class node_cartstate,node_lang,node_clientapi,node_auth,node_jwt,node_validation,node_apiresponse,node_orderservice toneRose
class node_database,node_customer,node_adminstaff,node_cloudinary toneIndigo
```

## Components

### Customer ordering

- [Menu ordering](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/order/OrderClient.js): `app/order/OrderClient.js`
- [Cart checkout](https://github.com/seven742/restaurant-qr-ordering/blob/main/components/customer/Cart.js): `components/customer/Cart.js`
- [Order confirmation](https://github.com/seven742/restaurant-qr-ordering/blob/main/components/customer/OrderConfirmation.js): `components/customer/OrderConfirmation.js`
- [Order history](https://github.com/seven742/restaurant-qr-ordering/blob/main/components/customer/OrderHistory.js): `components/customer/OrderHistory.js`

### Restaurant operations

- [Admin dashboard](https://github.com/seven742/restaurant-qr-ordering/tree/main/app/admin): `app/admin`
- [Menu management](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/menu/page.js): `app/admin/menu/page.js`
- [Order management](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/orders/page.js): `app/admin/orders/page.js`
- [Table management](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/tables/page.js): `app/admin/tables/page.js`
- [Restaurant settings](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/admin/settings/page.js): `app/admin/settings/page.js`

### API endpoints

- [Analytics API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/admin/dashboard/route.js): `app/api/admin/dashboard/route.js`
- [Order API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/orders/route.js): `app/api/orders/route.js`
- [Order status API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/orders/%5Bid%5D/status/route.js): `app/api/orders/[id]/status/route.js`
- [Product API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/products/route.js): `app/api/products/route.js`
- [Category API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/categories/route.js): `app/api/categories/route.js`
- [Table API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/tables/route.js): `app/api/tables/route.js`
- [Settings API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/settings/route.js): `app/api/settings/route.js`
- [Image upload API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/upload/route.js): `app/api/upload/route.js`
- [Authentication API](https://github.com/seven742/restaurant-qr-ordering/blob/main/app/api/auth/login/route.js): `app/api/auth/login/route.js`

### Shared services

- [Cart state](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/cart.js): `lib/cart.js`
- [Translations](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/i18n.js): `lib/i18n.js`
- [Browser API client](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/client.js): `lib/client.js`
- [Session and roles](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/auth.js): `lib/auth.js`
- [JWT handling](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/jwt.js): `lib/jwt.js`
- [Request validation](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/validate.js): `lib/validate.js`
- [API responses](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/api.js): `lib/api.js`
- [Order item loading](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/orders.js): `lib/orders.js`

### Persistence

- [MySQL database](https://github.com/seven742/restaurant-qr-ordering/blob/main/lib/db.js): `lib/db.js`

### Other components

- **QR customer**
- **Admin and staff**
- **Cloudinary**

## Connections

- QR customer → Menu ordering: scans QR
- Menu ordering → Browser API client: loads menu data (evidence: `app/order/OrderClient.js`)
- Menu ordering → Cart checkout: opens checkout (evidence: `app/order/OrderClient.js`)
- Menu ordering → Cart state: uses cart state (evidence: `app/order/OrderClient.js`)
- Menu ordering → Translations: translates UI (evidence: `app/order/OrderClient.js`)
- Cart checkout → Cart state: reads and clears (evidence: `components/customer/Cart.js`)
- Cart checkout → Browser API client: submits order (evidence: `components/customer/Cart.js`)
- Browser API client → Order API: posts order
- Cart checkout → Order confirmation: sets placed order (evidence: `components/customer/Cart.js`)
- Menu ordering → Order history: shows history (evidence: `app/order/OrderClient.js`)
- Admin and staff → Admin dashboard: manages restaurant
- Admin dashboard → Menu management: routes to menu
- Admin dashboard → Order management: routes to orders
- Admin dashboard → Table management: routes to tables
- Admin dashboard → Restaurant settings: routes to settings
- Menu management → Product API: manages products
- Menu management → Category API: manages categories
- Menu management → Image upload API: uploads images
- Order management → Order API: views orders
- Order management → Order status API: updates status
- Table management → Table API: manages tables
- Restaurant settings → Settings API: configures restaurant
- Admin dashboard → Analytics API: loads analytics
- Order API → MySQL database: queries and writes (evidence: `app/api/orders/route.js`)
- Order API → Request validation: validates input (evidence: `app/api/orders/route.js`)
- Order API → Session and roles: checks staff role (evidence: `app/api/orders/route.js`)
- Order API → Order item loading: attaches items (evidence: `app/api/orders/route.js`)
- Product API → MySQL database: queries and writes (evidence: `app/api/products/route.js`)
- Product API → Session and roles: checks admin role (evidence: `app/api/products/route.js`)
- Product API → Request validation: validates input (evidence: `app/api/products/route.js`)
- Table API → MySQL database: queries and writes (evidence: `app/api/tables/route.js`)
- Table API → Session and roles: checks staff role (evidence: `app/api/tables/route.js`)
- Authentication API → Session and roles: sets session (evidence: `app/api/auth/login/route.js`)
- Session and roles → JWT handling: signs and verifies (evidence: `lib/auth.js`)
- Analytics API → MySQL database: reads metrics (evidence: `app/api/admin/dashboard/route.js`)
- Analytics API → Session and roles: checks role (evidence: `app/api/admin/dashboard/route.js`)
- Image upload API → Cloudinary: stores images
