# ropastrana/qr-cafe-ordering-system architecture

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

- Interactive diagram: https://gitdiagram.com/ropastrana/qr-cafe-ordering-system
- Repository: https://github.com/ropastrana/qr-cafe-ordering-system

## Overview

This is a QR-based café self-ordering and cashier/POS system. Customers browse a menu, submit orders without accounts, and track their status; cashiers authenticate, take payment or enter walk-ins, advance orders through preparation, and review history and sales. The PHP API separates HTTP endpoints, services, repositories, and shared request/session/database handling. The README documents the broader customer and cashier screens; sampled source confirms the order, payment, repository, and shared API behavior. Frontend internals are not sampled, so their detailed calls are not inferred.

Main entry points: [`qr-cafe-cashier-html/qr-cafe-cashier`](https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/qr-cafe-cashier-html/qr-cafe-cashier) (Cashier POS), [`qr-cafe-customer-html/qr-cafe`](https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/qr-cafe-customer-html/qr-cafe) (Customer app), [`api/src/OrderService.php`](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/OrderService.php) (Order service), [`api/src/OrderRepository.php`](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/OrderRepository.php) (Order repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer ordering"]
  node_customer_app["Customer app"]
  node_receipt_page["E-receipt page"]
end

subgraph group_cashier["Cashier POS"]
  node_cashier_app["Cashier POS"]
end

subgraph group_api["API endpoints"]
  node_orders_api["Self-order API<br/>[orders.php]"]
  node_menu_api["Menu API<br/>[menu.php]"]
  node_tracking_api["Tracking API<br/>[track.php]"]
  node_receipt_api["Receipt API<br/>[receipt.php]"]
  node_auth_api["Login and session API<br/>[login.php]"]
  node_queue_api["Queue API<br/>[queue.php]"]
  node_payment_api["Payment API<br/>[pay.php]"]
  node_status_api["Status API<br/>[status.php]"]
  node_walkin_api["Walk-in API<br/>[walkin.php]"]
  node_history_api["History API<br/>[history.php]"]
end

subgraph group_domain["Order domain"]
  node_menu_repo["Menu repository<br/>[MenuRepository.php]"]
  node_order_repo["Order repository"]
  node_database[("Cafe database<br/>[cafe_pos.sql]")]
  node_order_service["Order service<br/>[OrderService.php]"]
  node_payment_service["Payment service<br/>[PaymentService.php]"]
  node_login_service["Login service<br/>[LoginService.php]"]
end

subgraph group_shared["API foundations"]
  node_request["Request parsing<br/>[Request.php]"]
  node_response["JSON responses<br/>[Response.php]"]
  node_session["Cashier sessions<br/>[Session.php]"]
  node_rate_limiter["Rate limiting<br/>[RateLimiter.php]"]
  node_db_connection["PDO connection<br/>[Database.php]"]
  node_bootstrap["API bootstrap<br/>[bootstrap.php]"]
  node_errors["Error handling<br/>[ErrorHandler.php]"]
  node_api_exception["API exceptions<br/>[ApiException.php]"]
  node_pay_exception["Payment exceptions<br/>[PayException.php]"]
end

node_customer_user(("Customer"))
node_cashier_user(("Cashier"))

node_customer_user -->|"uses"| node_customer_app
node_customer_app -->|"fetches menu"| node_menu_api
node_customer_app -->|"places orders"| node_orders_api
node_customer_app -->|"polls status"| node_tracking_api
node_customer_app -->|"opens receipt"| node_receipt_page
node_menu_api -->|"reads menu"| node_menu_repo
node_orders_api -->|"creates order"| node_order_service
node_tracking_api -->|"reads tracking"| node_order_repo
node_receipt_api -->|"reads receipt"| node_order_repo
node_receipt_page -->|"loads receipt data"| node_receipt_api
node_cashier_user -->|"uses"| node_cashier_app
node_cashier_app -->|"signs in"| node_auth_api
node_cashier_app -->|"views queue"| node_queue_api
node_cashier_app -->|"takes payment"| node_payment_api
node_cashier_app -->|"enters walk-ins"| node_walkin_api
node_cashier_app -->|"advances orders"| node_status_api
node_cashier_app -->|"views history"| node_history_api
node_auth_api -->|"authenticates"| node_login_service
node_queue_api -->|"reads queue"| node_order_repo
node_payment_api -->|"settles payment"| node_payment_service
node_status_api -->|"changes status"| node_order_service
node_walkin_api -->|"creates walk-in"| node_order_service
node_history_api -->|"reads history"| node_order_repo
node_order_service -->|"settles walk-in"| node_payment_service
node_order_service -->|"prices and saves"| node_database
node_payment_service -->|"records payment"| node_database
node_order_repo -->|"reads orders"| node_database
node_menu_repo -.->|"reads menu"| node_database
node_auth_api -->|"starts session"| node_session
node_auth_api -->|"limits attempts"| node_rate_limiter
node_orders_api -->|"limits orders"| node_rate_limiter
node_orders_api -->|"checks CSRF"| node_session
node_request -->|"raises errors"| node_api_exception
node_pay_exception -->|"extends"| node_api_exception
node_errors -->|"handles"| node_api_exception
node_errors -->|"sends errors"| node_response
node_bootstrap -->|"registers"| node_errors
node_db_connection -->|"connects to"| node_database

click node_customer_app "https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/qr-cafe-customer-html/qr-cafe"
click node_menu_repo "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/MenuRepository.php"
click node_order_repo "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/OrderRepository.php"
click node_database "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/database/cafe_pos.sql"
click node_orders_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/orders.php"
click node_menu_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/menu.php"
click node_tracking_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/track.php"
click node_receipt_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/receipt.php"
click node_cashier_app "https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/qr-cafe-cashier-html/qr-cafe-cashier"
click node_auth_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/login.php"
click node_queue_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/queue.php"
click node_payment_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/pay.php"
click node_status_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/status.php"
click node_walkin_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/walkin.php"
click node_history_api "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/history.php"
click node_order_service "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/OrderService.php"
click node_payment_service "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/PaymentService.php"
click node_login_service "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/LoginService.php"
click node_request "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Request.php"
click node_response "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Response.php"
click node_session "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Session.php"
click node_rate_limiter "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/RateLimiter.php"
click node_db_connection "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Database.php"
click node_bootstrap "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/bootstrap.php"
click node_errors "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/ErrorHandler.php"
click node_api_exception "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/ApiException.php"
click node_pay_exception "https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/PayException.php"
click node_receipt_page "https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/receipt"

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_customer_app,node_receipt_page toneBlue
class node_cashier_app toneAmber
class node_orders_api,node_menu_api,node_tracking_api,node_receipt_api,node_auth_api,node_queue_api,node_payment_api,node_status_api,node_walkin_api,node_history_api toneMint
class node_menu_repo,node_order_repo,node_database,node_order_service,node_payment_service,node_login_service toneRose
class node_request,node_response,node_session,node_rate_limiter,node_db_connection,node_bootstrap,node_errors,node_api_exception,node_pay_exception,node_customer_user,node_cashier_user toneIndigo
```

## Components

### Customer ordering

- [Customer app](https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/qr-cafe-customer-html/qr-cafe): `qr-cafe-customer-html/qr-cafe`
- [E-receipt page](https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/receipt): `receipt`

### Cashier POS

- [Cashier POS](https://github.com/ropastrana/qr-cafe-ordering-system/tree/main/qr-cafe-cashier-html/qr-cafe-cashier): `qr-cafe-cashier-html/qr-cafe-cashier`

### API endpoints

- [Self-order API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/orders.php): `api/orders.php`
- [Menu API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/menu.php): `api/menu.php`
- [Tracking API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/track.php): `api/track.php`
- [Receipt API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/receipt.php): `api/receipt.php`
- [Login and session API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/login.php): `api/login.php`
- [Queue API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/queue.php): `api/queue.php`
- [Payment API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/pay.php): `api/pay.php`
- [Status API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/status.php): `api/status.php`
- [Walk-in API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/walkin.php): `api/walkin.php`
- [History API](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/history.php): `api/history.php`

### Order domain

- [Menu repository](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/MenuRepository.php): `api/src/MenuRepository.php`
- [Order repository](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/OrderRepository.php): `api/src/OrderRepository.php`
- [Cafe database](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/database/cafe_pos.sql): `database/cafe_pos.sql`
- [Order service](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/OrderService.php): `api/src/OrderService.php`
- [Payment service](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/PaymentService.php): `api/src/PaymentService.php`
- [Login service](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/LoginService.php): `api/src/LoginService.php`

### API foundations

- [Request parsing](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Request.php): `api/src/Request.php`
- [JSON responses](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Response.php): `api/src/Response.php`
- [Cashier sessions](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Session.php): `api/src/Session.php`
- [Rate limiting](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/RateLimiter.php): `api/src/RateLimiter.php`
- [PDO connection](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/Database.php): `api/src/Database.php`
- [API bootstrap](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/bootstrap.php): `api/src/bootstrap.php`
- [Error handling](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/ErrorHandler.php): `api/src/ErrorHandler.php`
- [API exceptions](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/ApiException.php): `api/src/ApiException.php`
- [Payment exceptions](https://github.com/ropastrana/qr-cafe-ordering-system/blob/main/api/src/PayException.php): `api/src/PayException.php`

### Other components

- **Customer**
- **Cashier**

## Connections

- Customer → Customer app: uses (evidence: `README.md`)
- Customer app → Menu API: fetches menu (evidence: `README.md`)
- Customer app → Self-order API: places orders (evidence: `README.md`)
- Customer app → Tracking API: polls status (evidence: `README.md`)
- Customer app → E-receipt page: opens receipt (evidence: `README.md`)
- Menu API → Menu repository: reads menu (evidence: `api/menu.php`)
- Self-order API → Order service: creates order (evidence: `api/orders.php`)
- Tracking API → Order repository: reads tracking (evidence: `api/track.php`)
- Receipt API → Order repository: reads receipt (evidence: `api/receipt.php`)
- E-receipt page → Receipt API: loads receipt data (evidence: `README.md`)
- Cashier → Cashier POS: uses (evidence: `README.md`)
- Cashier POS → Login and session API: signs in (evidence: `README.md`)
- Cashier POS → Queue API: views queue (evidence: `README.md`)
- Cashier POS → Payment API: takes payment (evidence: `README.md`)
- Cashier POS → Walk-in API: enters walk-ins (evidence: `README.md`)
- Cashier POS → Status API: advances orders (evidence: `README.md`)
- Cashier POS → History API: views history (evidence: `README.md`)
- Login and session API → Login service: authenticates (evidence: `api/login.php`)
- Queue API → Order repository: reads queue (evidence: `api/queue.php`)
- Payment API → Payment service: settles payment (evidence: `api/pay.php`)
- Status API → Order service: changes status (evidence: `api/status.php`)
- Walk-in API → Order service: creates walk-in (evidence: `api/walkin.php`)
- History API → Order repository: reads history (evidence: `api/history.php`)
- Order service → Payment service: settles walk-in (evidence: `api/src/OrderService.php`)
- Order service → Cafe database: prices and saves (evidence: `api/src/OrderService.php`)
- Payment service → Cafe database: records payment (evidence: `api/src/PaymentService.php`)
- Order repository → Cafe database: reads orders (evidence: `api/src/OrderRepository.php`)
- Menu repository → Cafe database: reads menu
- Login and session API → Cashier sessions: starts session (evidence: `api/login.php`)
- Login and session API → Rate limiting: limits attempts (evidence: `api/login.php`)
- Self-order API → Rate limiting: limits orders (evidence: `api/orders.php`)
- Self-order API → Cashier sessions: checks CSRF (evidence: `api/orders.php`)
- Request parsing → API exceptions: raises errors (evidence: `api/src/Request.php`)
- Payment exceptions → API exceptions: extends (evidence: `api/src/PayException.php`)
- Error handling → API exceptions: handles (evidence: `api/src/ErrorHandler.php`)
- Error handling → JSON responses: sends errors (evidence: `api/src/ErrorHandler.php`)
- API bootstrap → Error handling: registers (evidence: `api/src/bootstrap.php`)
- PDO connection → Cafe database: connects to (evidence: `api/src/Database.php`)
