How hoanvukhai/cafe-shop-management works
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: ProtectedRoute.tsx Protected route · firebase.ts Firebase client · App.tsx App shell · BartenderPage.tsx Bartender
Components 27
Frontend shell
React entry, app composition, routing, and shared chrome.
- App entry · Bootstraps the React app into the DOM.
drink-order/src/index.tsx - App shell · Top-level application composition and route wiring.
drink-order/src/App.tsx - Header · Shared navigation and page chrome.
drink-order/src/components/Header.tsx - Protected route · Enforces authenticated and role-based access.
drink-order/src/components/ProtectedRoute.tsx - Login · Authentication entry point before protected workflows.
drink-order/src/pages/LoginPage.tsx
Operations workflows
Role-specific screens for taking orders and preparing drinks.
- Orders · Main order-taking and table-management screen.
drink-order/src/pages/OrderPage.tsx - Order UI · Forms, lists, items, tables, and receipt generation.
- Bartender · Drink preparation queue and execution view.
drink-order/src/pages/BartenderPage.tsx - Bar tools · Queued order cards and recipe detail modal.
drink-order/src/components/bartender/BartenderOrderCard.tsx - Preparation · Staff-facing drink preparation instructions.
drink-order/src/pages/PreparationPage.tsx - Recipes · 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 · Operational analytics and configuration hub.
drink-order/src/pages/AdminPage.tsx - Admin tabs · Menu, revenue, peak-time, bestseller, and staffing views.
drink-order/src/components/admin/MenuEditTab.tsx - Daily tasks · Day-to-day task assignment and review.
drink-order/src/pages/DailyTasksPage.tsx - Timesheet · Attendance and working-hours tracking screen.
drink-order/src/pages/TimesheetPage.tsx - Manager · Manager-specific role landing page.
drink-order/src/pages/ManagerPage.tsx
Domain data
Reusable reference datasets used across the UI.
- Menu data · Menu items used by ordering and analytics.
drink-order/src/data/menu_items.ts - Tables data · Table models and seating metadata.
drink-order/src/data/tables.ts - Recipe data · Recipe definitions for preparation and bartender views.
drink-order/src/data/recipes.ts - Task data · Task definitions shared by staff workflows.
drink-order/src/data/tasks.ts - Users data · Role and staff identity data.
drink-order/src/data/users.ts - Prep instructions · Preparation instructions for beverage workflows.
drink-order/src/data/preparation_instructions.ts
Firebase boundary
Client Firebase integration and deployment/security config.
- Firebase client · Client-side Firebase service integration.
drink-order/src/firebase.ts - Firebase config · Hosting and Firebase project configuration.
drink-order/firebase.json - Firestore rules · Firestore access control and query constraints.
drink-order/firestore.rules - Firestore indexes · Indexed queries for operational screens.
drink-order/firestore.indexes.json - Database rules · Realtime Database security configuration.
drink-order/database.rules.json
Connections 32
- 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.