Database Layout
This document outlines how the customer-facing database (/home) and the admin-managed database share information. The schema below is a reference for the shared data and should serve as a guide when rebuilding the actual database structure.
User flow (/login)
- The guest enters their name, phone number, and party size.
- The system checks the current queue and assigns the best-matching available table (maximizing seating efficiency).
Admin (/admin/setting)
- Store name
- Logo URL
Guest record (user_n)
- user_id
- name
- phone number
- party size
- table number
- queue number
- assignment timestamp
Admin menu (/admin/menu) → Guest home (/home)
- Menu item: name, description, price, image URL
Cart popup
- Cart items: name, price
- Order history: timestamp, item name, quantity
- Settlement request
Expanded guest dataset
- user_id
- cart popup (items including name, price, order history, settlement requests)
- name, phone number, party size, table number
Admin tables/history (/admin/tables and /admin/history)
- Reference the guest dataset to refresh those pages
- Table X detail: currently occupied by user_n → assignment time, party size, order history, item names, quantities, totals, settlement requests (all referenced data)
- Order history (admin/history): timestamp, table number, guest name, item names, totals, settlement status
When a guest requests settlement and the admin completes it at the counter, the guest is considered to have left the premises. The record remains only as history; the queue and table lists remove them.
The most critical quality in the database design is that data is referenced rather than duplicated, allowing updates to propagate in real time across admin and guest views. Apply this principle when refining the schema, and audit the existing frontend/backend/database codebase for unused parts and optimization opportunities.
The queue logic is not implemented yet. The behavior should be:
- A guest submits name, phone number, and party size.
- The system checks if all tables are occupied. If so, it assigns a queue position.
- When a table becomes available (after a guest requests settlement and the admin processes it), the next queue entry automatically receives that table.