# prachaya971-jpg/cafe_boardgame_server architecture

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

- Interactive diagram: https://gitdiagram.com/prachaya971-jpg/cafe_boardgame_server
- Repository: https://github.com/prachaya971-jpg/cafe_boardgame_server

## Overview

This is a restaurant operations backend with customer food ordering, table requests, board-game borrowing, staff and catalog administration, and sales reporting. The main evidenced customer workflow is menu lookup followed by adding food and options to an open table order; staff workflows manage requests and operational records, while reporting summarizes sales. The excerpts show selected server routes and database access patterns, but not the complete route wiring or the implementations of every listed subsystem, so uncertain links are omitted.

Main entry points: [`server.js`](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/server.js) (HTTP API), [`models/user_account.js`](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/models/user_account.js) (Account checks), [`report/report_food.js`](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/report/report_food.js) (Food maintenance), [`tablecus/table_check.js`](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/tablecus/table_check.js) (Table verification)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and identity"]
  node_server["HTTP API<br/>[server.js]"]
  node_accounts["Account checks<br/>[user_account.js]"]
  node_jwt["Token signing<br/>[jwt.js]"]
end

subgraph group_food["Food ordering"]
  node_menu["Customer menu<br/>[menu.js]"]
  node_food_catalog["Food catalog<br/>[createfood.js]"]
  node_food_admin["Food maintenance<br/>[report_food.js]"]
  node_orders["Order handling<br/>[order.js]"]
end

subgraph group_operations["Tables and games"]
  node_table_auth["Table verification<br/>[table_check.js]"]
  node_table_requests["Table requests<br/>[tablereq.js]"]
  node_boardgame_borrow["Game borrowing<br/>[borrow.js]"]
  node_boardgame_types["Game types"]
end

subgraph group_admin["Staff and reporting"]
  node_employees["Employee records<br/>[emp.js]"]
  node_dashboard["Revenue dashboard<br/>[dashboard.js]"]
  node_sales_report["Sales reporting<br/>[salereport.js]"]
end

node_customer(("Customer"))
node_staff(("Staff"))
node_db[("MariaDB")]

node_customer -->|"sends requests"| node_server
node_staff -->|"sends requests"| node_server
node_server -->|"checks identity"| node_accounts
node_server -->|"signs table token"| node_jwt
node_server -->|"gets revenue data"| node_dashboard
node_server -->|"gets employee data"| node_employees
node_server -->|"checks table request"| node_table_auth
node_server -->|"deletes food variant"| node_food_admin
node_server -->|"deletes game type"| node_boardgame_types
node_menu -->|"reads and writes"| node_db
node_food_catalog -->|"writes catalog"| node_db
node_food_admin -->|"reads and writes"| node_db
node_orders -->|"reads and writes"| node_db
node_accounts -->|"checks accounts"| node_db
node_table_auth -->|"checks tables"| node_db
node_table_requests -->|"reads and writes"| node_db
node_employees -->|"reads and writes"| node_db
node_dashboard -->|"queries sales"| node_db
node_boardgame_types -->|"reads and writes"| node_db

click node_server "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/server.js"
click node_accounts "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/models/user_account.js"
click node_jwt "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/libs/jwt.js"
click node_menu "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/customer/menu/menu.js"
click node_food_catalog "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/create/createfood.js"
click node_food_admin "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/report/report_food.js"
click node_orders "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/order/order.js"
click node_table_auth "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/tablecus/table_check.js"
click node_table_requests "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/table/tablereq.js"
click node_boardgame_borrow "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/borrow/borrow.js"
click node_boardgame_types "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/borrow/edit_boardgame_type.js"
click node_employees "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/emp/emp.js"
click node_dashboard "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/dashboard/dashboard.js"
click node_sales_report "https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/salereport/salereport.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_server,node_accounts,node_jwt toneBlue
class node_menu,node_food_catalog,node_food_admin,node_orders,node_db toneAmber
class node_table_auth,node_table_requests,node_boardgame_borrow,node_boardgame_types toneMint
class node_employees,node_dashboard,node_sales_report toneRose
class node_customer,node_staff toneIndigo
```

## Components

### API and identity

- [HTTP API](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/server.js): `server.js`
- [Account checks](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/models/user_account.js): `models/user_account.js`
- [Token signing](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/libs/jwt.js): `libs/jwt.js`

### Food ordering

- [Customer menu](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/customer/menu/menu.js): `customer/menu/menu.js`
- [Food catalog](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/create/createfood.js): `create/createfood.js`
- [Food maintenance](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/report/report_food.js): `report/report_food.js`
- [Order handling](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/order/order.js): `order/order.js`

### Tables and games

- [Table verification](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/tablecus/table_check.js): `tablecus/table_check.js`
- [Table requests](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/table/tablereq.js): `table/tablereq.js`
- [Game borrowing](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/borrow/borrow.js): `borrow/borrow.js`
- [Game types](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/borrow/edit_boardgame_type.js): `borrow/edit_boardgame_type.js`

### Staff and reporting

- [Employee records](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/emp/emp.js): `emp/emp.js`
- [Revenue dashboard](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/dashboard/dashboard.js): `dashboard/dashboard.js`
- [Sales reporting](https://github.com/prachaya971-jpg/cafe_boardgame_server/blob/main/salereport/salereport.js): `salereport/salereport.js`

### Other components

- **Customer**
- **Staff**
- **MariaDB**

## Connections

- Customer → HTTP API: sends requests
- Staff → HTTP API: sends requests
- HTTP API → Account checks: checks identity
- HTTP API → Token signing: signs table token
- HTTP API → Revenue dashboard: gets revenue data
- HTTP API → Employee records: gets employee data
- HTTP API → Table verification: checks table request
- HTTP API → Food maintenance: deletes food variant
- HTTP API → Game types: deletes game type
- Customer menu → MariaDB: reads and writes
- Food catalog → MariaDB: writes catalog
- Food maintenance → MariaDB: reads and writes
- Order handling → MariaDB: reads and writes
- Account checks → MariaDB: checks accounts
- Table verification → MariaDB: checks tables
- Table requests → MariaDB: reads and writes
- Employee records → MariaDB: reads and writes
- Revenue dashboard → MariaDB: queries sales
- Game types → MariaDB: reads and writes
