# hoanvukhai/cafe-shop-management architecture

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

- Interactive diagram: https://gitdiagram.com/hoanvukhai/cafe-shop-management
- Repository: https://github.com/hoanvukhai/cafe-shop-management

## Overview

1. **Overall shape**
   - This is a **single-page React + TypeScript application** for cafe operations, deployed through **Firebase Hosting**.
   - The codebase is organized by **role-specific workflows** rather than by generic technical layers, which is important for the architecture diagram.

2. **Frontend entry and shell**
   - `src/index.tsx` bootstraps the app into the DOM, and `src/App.tsx` is the top-level composition point.
   - `Header.tsx` appears to provide the shared chrome/navigation used across pages.
   - Global styling is split between `App.css`, `index.css`, and Tailwind configuration.

3. **Routing and access control**
   - The app uses page-level routes under `src/pages`, with `ProtectedRoute.tsx` enforcing authenticated/authorized access.
   - The access boundary is role-based: the app explicitly models **Admin, Bartender, Manager, and other staff views**.
   - `LoginPage.tsx` is the entry point for authentication before the user reaches protected flows.

4. **Firebase backend boundary**
   - `src/firebase.ts` is the client-side integration layer for Firebase services.
   - The repository includes `firebase.json`, `.firebaserc`, `firestore.rules`, `firestore.indexes.json`, and `database.rules.json`, showing that backend concerns are handled entirely by Firebase with security rules and indexed queries.
   - There is no custom server code in the repo; the frontend talks directly to Firebase.

5. **Core operational data flow**
   - The main domain flow is: **login → role-based page → shared domain components → Firebase-backed data and/or local seed data**.
   - The domain objects are centered on cafe operations: orders, tables, menu items, recipes, tasks, timesheets, and performance metrics.
   - The presence of Firestore rules and indexes suggests several screens rely on queryable operational data rather than just static UI state.

6. **Order management subsystem**
   - `OrderPage.tsx` is the main order workspace, composed from `OrderForm`, `OrderList`, `OrderItem`, `TableCard`, `TableDetail`, and `ReceiptGenerator`.
   - `src/data/tables.ts` and `src/data/menu_items.ts` likely provide the base menu/table models used by these screens.
   - This subsystem is the operational center for taking orders, mapping them to tables, and producing receipts.

7. **Bartender workflow subsystem**
   - `BartenderPage.tsx` and components under `src/components/bartender` focus on preparing drinks.
   - `BartenderOrderCard.tsx` presents queued orders, while `RecipeModal.tsx` exposes preparation details for a selected drink.
   - `public/sounds/doorbell.mp3` suggests an audible alert path for new or urgent orders.

8. **Preparation and recipe knowledge**
   - `PreparationPage.tsx` and `RecipesPage.tsx` expose drink-making instructions and recipe content.
   - The supporting data lives in `src/data/recipes.ts` and `src/data/preparation_instructions.ts`.
   - This is a separate knowledge layer from order-taking: it helps staff execute the order, not just record it.

9. **Admin and management dashboard**
   - `AdminPage.tsx` aggregates operational analytics and configuration tabs under `src/components/admin`.
   - The admin subsystem includes menu editing, bestseller analysis, menu statistics, peak-time analysis, revenue reporting, tasks, timesheet review, and working-hours tracking.
   - These views form the management boundary: they consume operational data and turn it into staffing, menu, and revenue insights.

10. **Staff tasks and time tracking**
   - `DailyTasksPage.tsx` and `TimesheetPage.tsx` expose day-to-day work allocation and attendance tracking.
   - `src/data/tasks.ts` and `src/components/admin/TasksTab.tsx` / `Timesheet.tsx` indicate a structured workflow for assigning and reviewing work.
   - This is a distinct subsystem from order fulfillment, but it shares staff identity and operational data.

11. **Shared reference data**
   - `src/data/menu_items.ts`, `tables.ts`, `recipes.ts`, `tasks.ts`, `users.ts`, and `preparation_instructions.ts` act as reusable domain datasets.
   - In architecture terms, these files form the app’s **reference/model layer** for menu, table, staff, and recipe concepts.
   - Some of this may be seed/mock data, while persisted state is expected to live in Firebase.

12. **Deployment and operations**
   - The app is intended for Firebase deployment, not a custom application server.
   - The presence of `firestore.rules`, `firestore.indexes.json`, and hosting cache artifacts indicates that production behavior depends on Firebase security and query configuration.
   - Testing support exists through `App.test.tsx` and `setupTests.ts`, but the repo is primarily oriented around frontend delivery and Firebase-backed operations.

Main entry points: [`drink-order/src/components/ProtectedRoute.tsx`](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/ProtectedRoute.tsx) (Protected route), [`drink-order/src/firebase.ts`](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/firebase.ts) (Firebase client), [`drink-order/src/App.tsx`](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/App.tsx) (App shell), [`drink-order/src/pages/BartenderPage.tsx`](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/BartenderPage.tsx) (Bartender)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend shell"]
  node_src_index["App entry<br/>react bootstrap<br/>[index.tsx]"]
  node_app_shell["App shell<br/>route composer<br/>[App.tsx]"]
  node_header["Header<br/>shared chrome<br/>[Header.tsx]"]
  node_protected_route["Protected route<br/>access gate<br/>[ProtectedRoute.tsx]"]
  node_login_page["Login<br/>auth page<br/>[LoginPage.tsx]"]
end

subgraph group_operations["Operations workflows"]
  node_order_page["Orders<br/>order workspace<br/>[OrderPage.tsx]"]
  node_order_components["Order UI<br/>order components"]
  node_bartender_page["Bartender<br/>prep workspace<br/>[BartenderPage.tsx]"]
  node_bartender_components["Bar tools<br/>prep components"]
  node_preparation_page["Preparation<br/>prep guide"]
  node_recipes_page["Recipes<br/>recipe reference<br/>[RecipesPage.tsx]"]
end

subgraph group_management["Management views"]
  node_admin_page["Admin<br/>management hub<br/>[AdminPage.tsx]"]
  node_admin_tabs["Admin tabs<br/>analytics/config tabs<br/>[MenuEditTab.tsx]"]
  node_tasks_page["Daily tasks<br/>staff workflow<br/>[DailyTasksPage.tsx]"]
  node_timesheet_page["Timesheet<br/>staff tracking<br/>[TimesheetPage.tsx]"]
  node_manager_page["Manager<br/>role page<br/>[ManagerPage.tsx]"]
end

subgraph group_data["Domain data"]
  node_menu_data["Menu data<br/>reference data<br/>[menu_items.ts]"]
  node_table_data["Tables data<br/>reference data<br/>[tables.ts]"]
  node_recipe_data["Recipe data<br/>reference data<br/>[recipes.ts]"]
  node_task_data["Task data<br/>reference data<br/>[tasks.ts]"]
  node_user_data["Users data<br/>reference data<br/>[users.ts]"]
  node_prep_data["Prep instructions<br/>reference data"]
end

subgraph group_backend["Firebase boundary"]
  node_firebase_client["Firebase client<br/>integration layer<br/>[firebase.ts]"]
  node_firebase_config["Firebase config<br/>deployment config<br/>[firebase.json]"]
  node_firestore_rules["Firestore rules<br/>security rules<br/>[firestore.rules]"]
  node_firestore_indexes["Firestore indexes<br/>query indexes"]
  node_database_rules["Database rules<br/>security rules"]
end

node_src_index -->|"mounts"| node_app_shell
node_app_shell -->|"uses"| node_header
node_app_shell -->|"wraps"| node_protected_route
node_app_shell -->|"routes to"| node_login_page
node_protected_route -->|"permits"| node_order_page
node_protected_route -->|"permits"| node_bartender_page
node_protected_route -->|"permits"| node_preparation_page
node_protected_route -->|"permits"| node_recipes_page
node_protected_route -->|"permits"| node_admin_page
node_protected_route -->|"permits"| node_tasks_page
node_protected_route -->|"permits"| node_timesheet_page
node_protected_route -->|"permits"| node_manager_page
node_order_page -->|"composes"| node_order_components
node_order_components -->|"reads"| node_menu_data
node_order_components -->|"reads"| node_table_data
node_order_components -->|"persists"| node_firebase_client
node_bartender_page -->|"composes"| node_bartender_components
node_bartender_components -->|"reads"| node_recipe_data
node_bartender_page -->|"reads"| node_prep_data
node_bartender_page -->|"syncs"| node_firebase_client
node_preparation_page -->|"reads"| node_prep_data
node_recipes_page -->|"reads"| node_recipe_data
node_admin_page -->|"composes"| node_admin_tabs
node_admin_tabs -->|"analyzes"| node_menu_data
node_admin_tabs -->|"analyzes"| node_task_data
node_admin_tabs -->|"queries"| node_firebase_client
node_tasks_page -->|"uses"| node_task_data
node_timesheet_page -->|"uses"| node_user_data
node_firebase_client -->|"deploys with"| node_firebase_config
node_firebase_client -->|"governed by"| node_firestore_rules
node_firebase_client -->|"optimized by"| node_firestore_indexes
node_firebase_client -->|"governed by"| node_database_rules

click node_src_index "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/index.tsx"
click node_app_shell "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/App.tsx"
click node_header "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/Header.tsx"
click node_protected_route "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/ProtectedRoute.tsx"
click node_login_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/LoginPage.tsx"
click node_order_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/OrderPage.tsx"
click node_bartender_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/BartenderPage.tsx"
click node_bartender_components "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/bartender/BartenderOrderCard.tsx"
click node_preparation_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/PreparationPage.tsx"
click node_recipes_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/RecipesPage.tsx"
click node_admin_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/AdminPage.tsx"
click node_admin_tabs "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/admin/MenuEditTab.tsx"
click node_tasks_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/DailyTasksPage.tsx"
click node_timesheet_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/TimesheetPage.tsx"
click node_manager_page "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/ManagerPage.tsx"
click node_menu_data "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/menu_items.ts"
click node_table_data "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/tables.ts"
click node_recipe_data "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/recipes.ts"
click node_task_data "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/tasks.ts"
click node_user_data "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/users.ts"
click node_prep_data "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/preparation_instructions.ts"
click node_firebase_client "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/firebase.ts"
click node_firebase_config "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/firebase.json"
click node_firestore_rules "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/firestore.rules"
click node_firestore_indexes "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/firestore.indexes.json"
click node_database_rules "https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/database.rules.json"

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_src_index,node_app_shell,node_header,node_protected_route,node_login_page toneBlue
class node_order_page,node_order_components,node_bartender_page,node_bartender_components,node_preparation_page,node_recipes_page toneAmber
class node_admin_page,node_admin_tabs,node_tasks_page,node_timesheet_page,node_manager_page toneMint
class node_menu_data,node_table_data,node_recipe_data,node_task_data,node_user_data,node_prep_data toneRose
class node_firebase_client,node_firebase_config,node_firestore_rules,node_firestore_indexes,node_database_rules toneIndigo
```

## Components

### Frontend shell

React entry, app composition, routing, and shared chrome.

- [App entry](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/index.tsx): react bootstrap · Bootstraps the React app into the DOM. · `drink-order/src/index.tsx`
- [App shell](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/App.tsx): route composer · Top-level application composition and route wiring. · `drink-order/src/App.tsx`
- [Header](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/Header.tsx): shared chrome · Shared navigation and page chrome. · `drink-order/src/components/Header.tsx`
- [Protected route](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/ProtectedRoute.tsx): access gate · Enforces authenticated and role-based access. · `drink-order/src/components/ProtectedRoute.tsx`
- [Login](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/LoginPage.tsx): auth page · Authentication entry point before protected workflows. · `drink-order/src/pages/LoginPage.tsx`

### Operations workflows

Role-specific screens for taking orders and preparing drinks.

- [Orders](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/OrderPage.tsx): order workspace · Main order-taking and table-management screen. · `drink-order/src/pages/OrderPage.tsx`
- **Order UI**: order components · Forms, lists, items, tables, and receipt generation.
- [Bartender](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/BartenderPage.tsx): prep workspace · Drink preparation queue and execution view. · `drink-order/src/pages/BartenderPage.tsx`
- [Bar tools](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/bartender/BartenderOrderCard.tsx): prep components · Queued order cards and recipe detail modal. · `drink-order/src/components/bartender/BartenderOrderCard.tsx`
- [Preparation](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/PreparationPage.tsx): prep guide · Staff-facing drink preparation instructions. · `drink-order/src/pages/PreparationPage.tsx`
- [Recipes](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/RecipesPage.tsx): recipe reference · Recipe knowledge used for drink-making workflows. · `drink-order/src/pages/RecipesPage.tsx`

### Management views

Admin and staff-facing oversight, tasks, and time tracking.

- [Admin](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/AdminPage.tsx): management hub · Operational analytics and configuration hub. · `drink-order/src/pages/AdminPage.tsx`
- [Admin tabs](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/components/admin/MenuEditTab.tsx): analytics/config tabs · Menu, revenue, peak-time, bestseller, and staffing views. · `drink-order/src/components/admin/MenuEditTab.tsx`
- [Daily tasks](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/DailyTasksPage.tsx): staff workflow · Day-to-day task assignment and review. · `drink-order/src/pages/DailyTasksPage.tsx`
- [Timesheet](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/TimesheetPage.tsx): staff tracking · Attendance and working-hours tracking screen. · `drink-order/src/pages/TimesheetPage.tsx`
- [Manager](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/pages/ManagerPage.tsx): role page · Manager-specific role landing page. · `drink-order/src/pages/ManagerPage.tsx`

### Domain data

Reusable reference datasets used across the UI.

- [Menu data](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/menu_items.ts): reference data · Menu items used by ordering and analytics. · `drink-order/src/data/menu_items.ts`
- [Tables data](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/tables.ts): reference data · Table models and seating metadata. · `drink-order/src/data/tables.ts`
- [Recipe data](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/recipes.ts): reference data · Recipe definitions for preparation and bartender views. · `drink-order/src/data/recipes.ts`
- [Task data](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/tasks.ts): reference data · Task definitions shared by staff workflows. · `drink-order/src/data/tasks.ts`
- [Users data](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/users.ts): reference data · Role and staff identity data. · `drink-order/src/data/users.ts`
- [Prep instructions](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/data/preparation_instructions.ts): reference data · Preparation instructions for beverage workflows. · `drink-order/src/data/preparation_instructions.ts`

### Firebase boundary

Client Firebase integration and deployment/security config.

- [Firebase client](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/src/firebase.ts): integration layer · Client-side Firebase service integration. · `drink-order/src/firebase.ts`
- [Firebase config](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/firebase.json): deployment config · Hosting and Firebase project configuration. · `drink-order/firebase.json`
- [Firestore rules](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/firestore.rules): security rules · Firestore access control and query constraints. · `drink-order/firestore.rules`
- [Firestore indexes](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/firestore.indexes.json): query indexes · Indexed queries for operational screens. · `drink-order/firestore.indexes.json`
- [Database rules](https://github.com/hoanvukhai/cafe-shop-management/blob/main/drink-order/database.rules.json): security rules · Realtime Database security configuration. · `drink-order/database.rules.json`

## Connections

- App entry → App shell: mounts · Application entry initializes the root shell.
- App shell → Header: uses · Shared chrome appears across pages.
- App shell → Protected route: wraps · Protected flows are gated before rendering role pages.
- App shell → Login: routes to · Unauthenticated users enter through login.
- Protected route → Orders: permits · Authorized users can reach order operations.
- Protected route → Bartender: permits · Authorized users can reach bartender workflows.
- Protected route → Preparation: permits · Authorized users can reach preparation guidance.
- Protected route → Recipes: permits · Authorized users can reach recipe reference pages.
- Protected route → Admin: permits · Admin access opens management views.
- Protected route → Daily tasks: permits · Staff task views are behind access control.
- Protected route → Timesheet: permits · Time tracking is behind access control.
- Protected route → Manager: permits · Manager role has its own protected landing page.
- Orders → Order UI: composes · Order workspace is built from specialized order UI.
- Order UI → Menu data: reads · Menu items drive order creation and display.
- Order UI → Tables data: reads · Tables support seat-aware order handling.
- Order UI → Firebase client: persists · Orders and related state are backed by Firebase.
- Bartender → Bar tools: composes · Bartender workflow uses queue cards and recipe modal.
- Bar tools → Recipe data: reads · Preparation details come from recipe definitions.
- Bartender → Prep instructions: reads · Prep guidance supports drink execution.
- Bartender → Firebase client: syncs · Queued operational data is synchronized with Firebase.
- Preparation → Prep instructions: reads · Instructional content is sourced from prep data.
- Recipes → Recipe data: reads · Recipe browsing is backed by recipe data.
- Admin → Admin tabs: composes · Admin dashboard aggregates multiple analytic tabs.
- Admin tabs → Menu data: analyzes · Menu editing and stats consume menu definitions.
- Admin tabs → Task data: analyzes · Tasks tab uses structured task definitions.
- Admin tabs → Firebase client: queries · Management views consume Firebase-backed operational data.
- Daily tasks → Task data: uses · Daily task assignment relies on shared task definitions.
- Timesheet → Users data: uses · Timesheet review ties back to staff identity data.
- Firebase client → Firebase config: deploys with · Client integration operates within Firebase hosting config.
- Firebase client → Firestore rules: governed by · Firestore access is constrained by security rules.
- Firebase client → Firestore indexes: optimized by · Query-heavy screens rely on indexed Firestore access.
- Firebase client → Database rules: governed by · Realtime Database access is controlled by rules.
