# yzu1103309/order architecture

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

- Interactive diagram: https://gitdiagram.com/yzu1103309/order
- Repository: https://github.com/yzu1103309/order

## Overview

1. **Overall shape**
   This repository is a small, self-contained restaurant ordering system built as a classic PHP/MySQL web app with a JavaScript front end. It is not a modern SPA; instead, the browser loads role-specific pages and then uses AJAX polling to keep kitchen and delivery screens in sync.

2. **Primary user-facing flows**
   The system has three main operational roles: ordering/front desk, kitchen preparation, and delivery/service. The landing page (`index.html`) routes the user into these different views, and the app behavior is designed to feel like an internal tool rather than a public website.

3. **Front-end presentation layer**
   Static styling lives in `css/` and is split by concern (`banner.css`, `content.css`, `tutor.css`). The browser-side logic is in `js/`, with `main.js` likely coordinating page behavior, `order.js` handling order entry interactions, `D3.js` handling chart rendering, and `custom_settings.js` centralizing configurable menu/sound/settings values.

4. **Order entry subsystem**
   The ordering flow lets the user build an order, choose dine-in vs. takeout, and submit it. Takeout numbering and table/seat-related behavior are part of the front-end workflow, while `php/send.php` and related query files persist the order. The ordering UI is heavily interactive, but the actual source of truth lives on the server/database.

5. **Kitchen / preparation subsystem**
   The kitchen side is driven by PHP endpoints like `php/done.php`, `php/complete.php`, and `php/detail.php`, with renderers under `php/renderers/`. This layer turns database order records into large, paper-slip-like views optimized for fast reading and minimal touch interaction. It also supports automatic splitting of long orders into multiple displays.

6. **Delivery / service subsystem**
   The delivery workflow appears to be a separate queue from the kitchen queue. Files such as `deliverPage.php` and `php/renderers/deliver_page_renderer.php` indicate a dedicated screen for serving completed items, with status transitions managed through the PHP endpoints.

7. **History and reporting subsystem**
   Historical orders are handled separately from live orders. `history.php`, `historyPage.php`, and the `remove*.php` endpoints support browsing, paging, deleting single orders, and deleting all history. The history feature also computes total revenue and exposes yearly/monthly data for reporting.

8. **Charting and analytics**
   `php/searchYear.php` and `php/returnD3.php` suggest a two-step analytics flow: the client first discovers available years, then requests a selected year’s data in a CSV-like form for `D3.js` to render a monthly revenue chart. This is one of the few places where client-side visualization is a major architectural concern.

9. **Server-side structure**
   The PHP code is deliberately split into controllers/endpoints, renderers, and query builders. `php/queries/` contains the database-facing SQL logic, while `php/renderers/` builds HTML fragments or structured responses for each page or action. This separation makes the app easier to test even though it is not framework-based.

10. **Data persistence boundary**
    The persistent state is in MySQL, accessed only through PHP. The repository itself does not show schema files, so the database is treated as an external backing store behind the PHP layer. Live orders, completed orders, delivery-ready items, and history records are all managed through this database boundary.

11. **Real-time behavior**
    “Real-time” updates are implemented with browser polling rather than websockets. The README describes interval-based refreshing, and the notification audio files in `audio/` indicate the UI plays a sound when new orders or completed dishes appear. This means the app is architected for periodic synchronization, not push messaging.

12. **Testing and delivery**
    The repository includes Jest tests for the JavaScript modules and PHP tests for each major endpoint. GitHub Actions workflows in `.github/workflows/` support CI checks and a test/deployment environment, so the repo is built around automated verification of both front-end behavior and PHP endpoints.

13. **What to draw in an architecture diagram**
    A good diagram would show: browser clients on the left; three role-specific UI paths on top of shared static assets/JS; a PHP application layer in the middle with distinct order/history/chart endpoints; and MySQL as the persistent store on the right. The important arrows are order submission to PHP/DB, polling from kitchen/delivery screens back to PHP/DB, and history/chart requests from the client to the analytics endpoints.

Main entry points: [`index.html`](https://github.com/yzu1103309/order/blob/main/index.html) (Browser), [`tests`](https://github.com/yzu1103309/order/tree/main/tests) (Tests), [`js/order.js`](https://github.com/yzu1103309/order/blob/main/js/order.js) (Order UI), [`php/done.php`](https://github.com/yzu1103309/order/blob/main/php/done.php) (Kitchen queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_frontend["Browser UI"]
  node_browser(("Browser<br/>client<br/>[index.html]"))
  node_ui_static["Static assets<br/>styles/scripts"]
  node_order_ui["Order UI<br/>front desk<br/>[order.js]"]
  node_main_ui["Page shell<br/>browser logic<br/>[main.js]"]
  node_chart_ui["Charts<br/>visualization<br/>[D3.js]"]
  node_config_ui["Settings<br/>client config<br/>[custom_settings.js]"]
end

subgraph group_group_server["PHP app"]
  node_order_page["Order pages<br/>php views<br/>[orderPage.php]"]
  node_order_action["Send order<br/>php action<br/>[send.php]"]
  node_order_queries["Order queries<br/>sql builders<br/>[send_queries.php]"]
  node_service_views["Service screens<br/>php views"]
  node_prep_queue["Kitchen queue<br/>prep workflow<br/>[done.php]"]
  node_prep_renderers["Kitchen renderers<br/>rendering"]
  node_delivery_view["Delivery screen<br/>service queue<br/>[deliverPage.php]"]
  node_history_view["History screen<br/>reporting<br/>[historyPage.php]"]
  node_history_actions["History actions<br/>php action<br/>[remove.php]"]
  node_analytics["Revenue chart<br/>analytics api<br/>[searchYear.php]"]
  node_db[("MySQL<br/>persistent store")]
end

subgraph group_group_ci["Automation"]
  node_tests["Tests<br/>js/php test suite"]
  node_ci["GitHub Actions<br/>ci workflows<br/>[workflows]"]
end

node_browser -->|"loads"| node_ui_static
node_browser -->|"orders"| node_order_ui
node_browser -->|"navigates"| node_main_ui
node_browser -->|"renders"| node_chart_ui
node_browser -->|"opens"| node_order_page
node_order_ui -->|"submits"| node_order_action
node_order_ui -->|"chooses mode"| node_service_views
node_order_action -->|"uses"| node_order_queries
node_order_queries -->|"writes"| node_db
node_service_views -->|"reads"| node_db
node_prep_queue -->|"renders"| node_prep_renderers
node_prep_renderers -->|"reads"| node_db
node_prep_queue -->|"updates"| node_db
node_delivery_view -->|"reads"| node_db
node_history_view -->|"modifies"| node_history_actions
node_history_view -->|"reads"| node_db
node_history_actions -->|"deletes"| node_db
node_analytics -->|"queries"| node_db
node_chart_ui -->|"requests"| node_analytics
node_tests -.->|"covers"| node_order_ui
node_tests -.->|"covers"| node_prep_queue
node_tests -.->|"covers"| node_history_view
node_ci -->|"runs"| node_tests

click node_browser "https://github.com/yzu1103309/order/blob/main/index.html"
click node_order_ui "https://github.com/yzu1103309/order/blob/main/js/order.js"
click node_main_ui "https://github.com/yzu1103309/order/blob/main/js/main.js"
click node_chart_ui "https://github.com/yzu1103309/order/blob/main/js/D3.js"
click node_config_ui "https://github.com/yzu1103309/order/blob/main/js/custom_settings.js"
click node_order_page "https://github.com/yzu1103309/order/blob/main/php/orderPage.php"
click node_order_action "https://github.com/yzu1103309/order/blob/main/php/send.php"
click node_order_queries "https://github.com/yzu1103309/order/blob/main/php/queries/send_queries.php"
click node_service_views "https://github.com/yzu1103309/order/blob/main/php/renderers/dine_in_renderer.php"
click node_prep_queue "https://github.com/yzu1103309/order/blob/main/php/done.php"
click node_prep_renderers "https://github.com/yzu1103309/order/blob/main/php/renderers/detail_renderer.php"
click node_delivery_view "https://github.com/yzu1103309/order/blob/main/php/deliverPage.php"
click node_history_view "https://github.com/yzu1103309/order/blob/main/php/historyPage.php"
click node_history_actions "https://github.com/yzu1103309/order/blob/main/php/remove.php"
click node_analytics "https://github.com/yzu1103309/order/blob/main/php/searchYear.php"
click node_tests "https://github.com/yzu1103309/order/tree/main/tests"
click node_ci "https://github.com/yzu1103309/order/blob/main/.github/workflows"

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_browser,node_ui_static,node_order_ui,node_main_ui,node_chart_ui,node_config_ui toneBlue
class node_order_page,node_order_action,node_order_queries,node_service_views,node_prep_queue,node_prep_renderers,node_delivery_view,node_history_view,node_history_actions,node_analytics,node_db toneAmber
class node_tests,node_ci toneMint
```

## Components

### Browser UI

Role-specific pages and shared client assets

- [Browser](https://github.com/yzu1103309/order/blob/main/index.html): client · User entry point for ordering, kitchen, delivery, and history screens · `index.html`
- **Static assets**: styles/scripts · Shared CSS, JavaScript, and audio used across the app
- [Order UI](https://github.com/yzu1103309/order/blob/main/js/order.js): front desk · Interactive ordering flow for dine-in and takeout · `js/order.js`
- [Page shell](https://github.com/yzu1103309/order/blob/main/js/main.js): browser logic · Shared client page behavior and polling coordination · `js/main.js`
- [Charts](https://github.com/yzu1103309/order/blob/main/js/D3.js): visualization · Client-side revenue chart rendering · `js/D3.js`
- [Settings](https://github.com/yzu1103309/order/blob/main/js/custom_settings.js): client config · Menu, sound, and UI configuration values · `js/custom_settings.js`

### PHP app

Page endpoints, actions, renderers, and query builders

- [Order pages](https://github.com/yzu1103309/order/blob/main/php/orderPage.php): php views · Entry pages for ordering and menu display · `php/orderPage.php`
- [Send order](https://github.com/yzu1103309/order/blob/main/php/send.php): php action · Persists new orders into the database · `php/send.php`
- [Order queries](https://github.com/yzu1103309/order/blob/main/php/queries/send_queries.php): sql builders · Database queries for creating and fetching live orders · `php/queries/send_queries.php`
- [Service screens](https://github.com/yzu1103309/order/blob/main/php/renderers/dine_in_renderer.php): php views · Dine-in and takeout renderers for order handling · `php/renderers/dine_in_renderer.php`
- [Kitchen queue](https://github.com/yzu1103309/order/blob/main/php/done.php): prep workflow · Endpoints for marking orders done, complete, and viewing details · `php/done.php`
- [Kitchen renderers](https://github.com/yzu1103309/order/blob/main/php/renderers/detail_renderer.php): rendering · HTML generation for kitchen slips and detail views · `php/renderers/detail_renderer.php`
- [Delivery screen](https://github.com/yzu1103309/order/blob/main/php/deliverPage.php): service queue · Dedicated view for serving completed items · `php/deliverPage.php`
- [History screen](https://github.com/yzu1103309/order/blob/main/php/historyPage.php): reporting · Browsing, paging, and deleting past orders · `php/historyPage.php`
- [History actions](https://github.com/yzu1103309/order/blob/main/php/remove.php): php action · Remove single records or clear all history · `php/remove.php`
- [Revenue chart](https://github.com/yzu1103309/order/blob/main/php/searchYear.php): analytics api · Year lookup and monthly data for the D3 chart · `php/searchYear.php`
- **MySQL**: persistent store · Backing store for live orders, delivery state, and history

### Automation

Tests and GitHub Actions

- [Tests](https://github.com/yzu1103309/order/tree/main/tests): js/php test suite · Jest and PHP coverage for major UI and endpoint flows · `tests`
- [GitHub Actions](https://github.com/yzu1103309/order/blob/main/.github/workflows): ci workflows · Automated checks and deployment-related workflows · `.github/workflows`

## Connections

- Browser → Static assets: loads · Browser consumes shared CSS, JS, and audio
- Browser → Order UI: orders · Front desk order entry is handled in the client
- Browser → Page shell: navigates · Shared page behavior coordinates role-specific views
- Browser → Charts: renders · History analytics chart is drawn in the browser
- Browser → Order pages: opens · Landing and role pages route users into the app
- Order UI → Send order: submits · Order entry posts new orders to PHP
- Order UI → Service screens: chooses mode · Dine-in or takeout flow depends on order type
- Send order → Order queries: uses · Order endpoint delegates database work to query builders
- Order queries → MySQL: writes · New orders are persisted in MySQL
- Service screens → MySQL: reads · Service screens load order state from the database
- Kitchen queue → Kitchen renderers: renders · Kitchen endpoints use dedicated renderers for slips and details
- Kitchen renderers → MySQL: reads · Kitchen views are built from stored order records
- Kitchen queue → MySQL: updates · Done/complete actions change order status
- Delivery screen → MySQL: reads · Delivery queue reflects completed items from storage
- History screen → History actions: modifies · History screen supports delete operations
- History screen → MySQL: reads · History pages browse archived orders and totals
- History actions → MySQL: deletes · Single-item and bulk removal update history records
- Revenue chart → MySQL: queries · Year and revenue data are fetched from stored orders
- Charts → Revenue chart: requests · Client fetches year lists and chart data
- Tests → Order UI: covers · Front-end order interactions are tested
- Tests → Kitchen queue: covers · PHP endpoint behavior is tested
- Tests → History screen: covers · History and reporting flows are tested
- GitHub Actions → Tests: runs · Workflows execute automated checks
