How comanda-digital-code/frontend-comanda-digital works
Purpose and runtime
A Next.js App Router frontend for restaurant operations: public menu/table access, authenticated staff workflows, kitchen fulfillment, and manager administration/reporting. It runs as a TypeScript React application with route layouts and Tailwind/global styling. Root bootstrap is src/app/layout.tsx; the landing route is src/app/page.tsx.
Route domains and entry points
Routes are separated into public and protected groups:
• Public customer/auth entry points: src/app/(public)/menu/page.tsx, src/app/(public)/tab/table/[tableNumber]/page.tsx, src/app/(public)/login/page.tsx.
• Protected role workspaces: manager, server, and kitchen routes under src/app/(protected)/manager, src/app/(protected)/server, and src/app/(protected)/kitchen.
• Protected shell and role-specific layouts establish workspace navigation/chrome: src/app/(protected)/layout.tsx, src/app/(protected)/manager/layout.tsx, src/app/(protected)/server/layout.tsx.
Authentication and access boundary
Authentication is feature-owned, with provider/context, login/reset forms, token handling, and an auth service:
src/features/auth/context/AuthProvider.tsx, src/features/auth/services/auth.service.ts, src/features/auth/tokens/auth.token.ts.
src/proxy.ts is the likely application-wide request/access boundary, while src/config/role-mapper.ts and protected route groups support role-directed navigation and authorization behavior.
Backend integration and client/server split
Feature services consistently distinguish browser and server API access, insulating UI from the backend contract:
src/services/api.client.ts, src/services/api.server.ts, src/features/product/service/product.client.ts.
Core domain services cover products, categories/extras, employees, tabs, orders, dashboard data, and reports. React Query provisioning in src/providers/react-query-provider.tsx is the shared client-side remote-state layer. The frontend depends on an external API; its implementation is not present in this repository.
Restaurant transaction flow
The central operational flow is table/tab → order → kitchen → settlement/reporting:
• Servers open and manage tabs, select products, edit orders, and send orders through src/app/(protected)/server/tabs/open/[id]/page.tsx, src/app/(protected)/server/products/select/page.tsx, and src/app/(protected)/server/orders/[id]/send/page.tsx.
• Tab state and order data are modeled and persisted through src/features/tab/services/tabs.client.service.ts, src/features/tab/components/order/service/order.client.ts, and src/features/order/services/orders.client.service.ts.
• Kitchen staff consume and advance fulfillment work through src/features/kitchen/components/KitchenDashboard.tsx and src/features/order/components/KitchenOrdersClient.tsx.
Real-time synchronization
WebSocket infrastructure and domain hooks propagate operational changes to active screens:
src/services/websocket.ts, src/features/order/hooks/useKitchenOrdersRealtime.ts, src/features/tab/hooks/useTabsRealtime.ts.
This boundary is material: server/order/kitchen dashboards render local UI state but must reconcile events from the backend, including typed order and tab event contracts in src/features/order/types/orderEvents.ts and src/features/tab/types/tabEvents.ts.
Management, customer presentation, and outputs
Managers maintain the sellable catalog and staff, then monitor performance:
src/app/(protected)/manager/products/page.tsx, src/app/(protected)/manager/employees/page.tsx, src/app/(protected)/manager/dashboard/page.tsx.
Dashboard hooks/services aggregate KPIs, revenue, rankings, and recent tabs via src/features/dashboard/services/dashboard.service.ts and src/features/dashboard/hooks/use-manager-dashboard-realtime.ts. QR functionality creates menu/table entry URLs and print/download actions (src/features/qr/domain/qr.urls.ts, src/features/qr/services/qr-print.client.ts). Cloudinary integration supports media handling through src/features/cloudinary/services/cloudinary.client.ts; reporting generates PDF-oriented outputs under src/features/report/pdf/.
Main entry points: api.client.ts API client/server layer · page.tsx Manager workspace · layout.tsx Protected workspace shell · tabs.client.service.ts Tab & order services
Components 19
App routes
Next.js route entry points and workspace shells.
- Root bootstrap
src/app/layout.tsx - Landing route
src/app/page.tsx - Customer & auth routes · Menu, table access, and login entry points.
src/app/(public)/menu/page.tsx - Protected workspace shell · Shared authenticated workspace chrome.
src/app/(protected)/layout.tsx - Server workspace · Tab, product selection, and order-send workflows.
src/app/(protected)/server/tabs/open/[id]/page.tsx - Manager workspace · Catalog, staff, and dashboard administration.
src/app/(protected)/manager/dashboard/page.tsx
Access & data
Authentication, API access, and shared remote state.
- Auth provider & service · Owns session context, login flows, and tokens.
src/features/auth/context/AuthProvider.tsx - Request access boundary · Applies application-wide access handling.
src/proxy.ts - API client/server layer · Separates browser and server calls to the external API.
src/services/api.client.ts - Remote-state provider
src/providers/react-query-provider.tsx
Restaurant operations
Tab, order, kitchen, and real-time workflow.
- Tab & order services · Persists tabs, order edits, and order lifecycle changes.
src/features/tab/services/tabs.client.service.ts - Kitchen fulfillment · Displays and advances kitchen work.
src/features/kitchen/components/KitchenDashboard.tsx - WebSocket synchronization · Reconciles typed tab and order events into active screens.
src/services/websocket.ts
Management & outputs
Catalog, administration, presentation, and reporting.
- Catalog management · Product, category, extras, and media operations.
src/app/(protected)/manager/products/page.tsx - Staff management
src/app/(protected)/manager/employees/page.tsx - Manager dashboard · KPIs, revenue, rankings, and recent tabs.
src/features/dashboard/services/dashboard.service.ts - QR menu & table entry · Creates menu/table URLs and print/download actions.
src/features/qr/domain/qr.urls.ts - PDF reporting
src/features/report/pdf/RevenuePdfDocument.tsx
Other components
- External restaurant API · Backend implementation is outside this repository.
Connections 25
- Root bootstrap → Landing route: renders
- Root bootstrap → Customer & auth routes: hosts
- Root bootstrap → Protected workspace shell: hosts
- Request access boundary → Protected workspace shell: guards
- Auth provider & service → Request access boundary: session access
- Protected workspace shell → Server workspace: routes staff
- Protected workspace shell → Manager workspace: routes managers
- Customer & auth routes → Auth provider & service: login
- Auth provider & service → API client/server layer: auth requests
- Remote-state provider → API client/server layer: fetches through
- API client/server layer → External restaurant API: HTTP API
- Server workspace → Tab & order services: opens, edits, sends
- Tab & order services → API client/server layer: persists
- Kitchen fulfillment → Tab & order services: advances orders
- WebSocket synchronization → Tab & order services: tab/order events
- WebSocket synchronization → Kitchen fulfillment: fulfillment updates
- WebSocket synchronization → External restaurant API: WebSocket events
- Manager workspace → Catalog management: maintains
- Manager workspace → Staff management: maintains
- Manager workspace → Manager dashboard: monitors
- Manager dashboard → API client/server layer: aggregates data
- Manager dashboard → PDF reporting: produces outputs
- QR menu & table entry → Customer & auth routes: links customers
- Catalog management → API client/server layer: manages catalog
- Staff management → API client/server layer: manages employees