How yzu1103309/order works
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 Browser · tests Tests · order.js Order UI · done.php Kitchen queue
Components 19
Browser UI
Role-specific pages and shared client assets
- Browser · User entry point for ordering, kitchen, delivery, and history screens
index.html - Static assets · Shared CSS, JavaScript, and audio used across the app
- Order UI · Interactive ordering flow for dine-in and takeout
js/order.js - Page shell · Shared client page behavior and polling coordination
js/main.js - Charts · Client-side revenue chart rendering
js/D3.js - Settings · Menu, sound, and UI configuration values
js/custom_settings.js
PHP app
Page endpoints, actions, renderers, and query builders
- Order pages · Entry pages for ordering and menu display
php/orderPage.php - Send order · Persists new orders into the database
php/send.php - Order queries · Database queries for creating and fetching live orders
php/queries/send_queries.php - Service screens · Dine-in and takeout renderers for order handling
php/renderers/dine_in_renderer.php - Kitchen queue · Endpoints for marking orders done, complete, and viewing details
php/done.php - Kitchen renderers · HTML generation for kitchen slips and detail views
php/renderers/detail_renderer.php - Delivery screen · Dedicated view for serving completed items
php/deliverPage.php - History screen · Browsing, paging, and deleting past orders
php/historyPage.php - History actions · Remove single records or clear all history
php/remove.php - Revenue chart · Year lookup and monthly data for the D3 chart
php/searchYear.php - MySQL · Backing store for live orders, delivery state, and history
Automation
Tests and GitHub Actions
- Tests · Jest and PHP coverage for major UI and endpoint flows
tests - GitHub Actions · Automated checks and deployment-related workflows
.github/workflows
Connections 23
- 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