# liliwqt/e-menu-web architecture

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

- Interactive diagram: https://gitdiagram.com/liliwqt/e-menu-web
- Repository: https://github.com/liliwqt/e-menu-web

## Overview

E-Menu Portal is the restaurant-facing TouchOrders product: staff sign in, select a branch, observe live restaurant data, and use deterministic analytics and recommendations to guide operations. For AI features, computed context goes from the frontend through an authenticated FastAPI gateway to OpenAI for interpretation; the gateway is documented as stateless with respect to restaurant data. The repository also contains backend order, payment, and lifecycle capabilities. Some frontend and backend modules were not sampled, so those areas are represented at subsystem level and only documented or indexed relationships are shown.

Main entry points: [`src/context/BranchDataContext.jsx`](https://github.com/liliwqt/e-menu-web/blob/main/src/context/BranchDataContext.jsx) (Branch data context), [`agent-core/src/touchorders_core/api/app.py`](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/app.py) (FastAPI application), [`src/lib/aiAnalystService.js`](https://github.com/liliwqt/e-menu-web/blob/main/src/lib/aiAnalystService.js) (AI request client), [`agent-core/src/touchorders_core/api/routes/ai.py`](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/routes/ai.py) (AI routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Restaurant portal"]
  node_portal["Portal routing<br/>[App.jsx]"]
  node_identity["Identity and workspace<br/>[AuthContext.jsx]"]
  node_access["Plan and AI access<br/>[useAiAccess.js]"]
  node_dashboard["Operations dashboard<br/>[DashboardPage.jsx]"]
  node_inventory_ui["Inventory workflows<br/>[InventoryPage.jsx]"]
  node_subscription["Subscription state"]
  node_reports["Analytics and reports<br/>[AnalyticsPage.jsx]"]
  node_public_pages["Public pages<br/>[PublicPage.jsx]"]
end

subgraph group_operations["Restaurant operations"]
  node_branch_context["Branch data context"]
  node_firebase["Firebase client<br/>[firebase.js]"]
  node_analytics["Sales analytics<br/>[analyticsApi.js]"]
  node_inventory["Inventory and menu<br/>[menuApi.js]"]
end

subgraph group_intelligence["AI intelligence"]
  node_executive["Executive presentation"]
  node_analyst_service["AI request client"]
  node_ai_ui["AI analyst surfaces"]
  node_backend_fetch["Backend transport<br/>[backendFetch.js]"]
end

subgraph group_backend["Gateway and services"]
  node_gateway_app["FastAPI application<br/>[app.py]"]
  node_ai_routes["AI routes<br/>[ai.py]"]
  node_token_auth["Token verification<br/>[auth.py]"]
  node_ai_context["AI context shaping<br/>[ai_context.py]"]
  node_llm_gateway["LLM gateway<br/>[gateway.py]"]
  node_orders["Order services<br/>[orders.py]"]
  node_payments["Payment services<br/>[payments.py]"]
  node_lifecycle["Lifecycle services<br/>[lifecycle.py]"]
end

node_owner(("Restaurant staff"))
node_realtime_db[("Realtime Database")]
node_openai{{"OpenAI"}}

node_owner -->|"uses"| node_portal
node_portal -->|"renders"| node_identity
node_identity -->|"authenticates through"| node_firebase
node_identity -->|"loads workspace data"| node_realtime_db
node_portal -->|"scopes branch"| node_branch_context
node_branch_context -->|"sets branch context"| node_firebase
node_branch_context -->|"subscribes to"| node_analytics
node_branch_context -->|"subscribes to"| node_inventory
node_firebase -->|"reads and writes"| node_realtime_db
node_dashboard -->|"consumes"| node_branch_context
node_dashboard -->|"computes metrics with"| node_analytics
node_inventory_ui -->|"uses live data"| node_branch_context
node_reports -->|"presents metrics"| node_analytics
node_subscription -->|"watches entitlements"| node_firebase
node_access -->|"checks plan"| node_subscription
node_dashboard -->|"requests interpretation"| node_analyst_service
node_executive -->|"requests narration"| node_analyst_service
node_ai_ui -.->|"requests analysis"| node_analyst_service
node_analyst_service -->|"posts analysis"| node_backend_fetch
node_backend_fetch -->|"sends AI request"| node_gateway_app
node_gateway_app -->|"registers routes"| node_ai_routes
node_ai_routes -->|"verifies identity"| node_token_auth
node_ai_routes -.->|"builds request context"| node_ai_context
node_ai_routes -.->|"dispatches analysis"| node_llm_gateway
node_llm_gateway -->|"requests explanation"| node_openai
node_openai -->|"returns structured insights"| node_analyst_service
node_gateway_app -->|"registers routes"| node_orders
node_gateway_app -->|"registers routes"| node_payments
node_gateway_app -->|"registers routes"| node_lifecycle
node_inventory -->|"observes inventory"| node_realtime_db
node_public_pages -->|"presents product information"| node_owner

click node_portal "https://github.com/liliwqt/e-menu-web/blob/main/src/App.jsx"
click node_identity "https://github.com/liliwqt/e-menu-web/blob/main/src/context/AuthContext.jsx"
click node_access "https://github.com/liliwqt/e-menu-web/blob/main/src/hooks/useAiAccess.js"
click node_branch_context "https://github.com/liliwqt/e-menu-web/blob/main/src/context/BranchDataContext.jsx"
click node_firebase "https://github.com/liliwqt/e-menu-web/blob/main/src/lib/firebase.js"
click node_analytics "https://github.com/liliwqt/e-menu-web/blob/main/src/lib/analyticsApi.js"
click node_inventory "https://github.com/liliwqt/e-menu-web/blob/main/src/lib/menuApi.js"
click node_dashboard "https://github.com/liliwqt/e-menu-web/blob/main/src/pages/DashboardPage.jsx"
click node_inventory_ui "https://github.com/liliwqt/e-menu-web/blob/main/src/pages/InventoryPage.jsx"
click node_executive "https://github.com/liliwqt/e-menu-web/blob/main/src/components/ai/ExecutivePresentation.jsx"
click node_analyst_service "https://github.com/liliwqt/e-menu-web/blob/main/src/lib/aiAnalystService.js"
click node_ai_ui "https://github.com/liliwqt/e-menu-web/blob/main/src/components/ai/AIAnalystDrawer.jsx"
click node_backend_fetch "https://github.com/liliwqt/e-menu-web/blob/main/src/lib/backendFetch.js"
click node_gateway_app "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/app.py"
click node_ai_routes "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/routes/ai.py"
click node_token_auth "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/auth.py"
click node_ai_context "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/ai_context.py"
click node_llm_gateway "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/llm/gateway.py"
click node_orders "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/orders.py"
click node_payments "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/payments.py"
click node_lifecycle "https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/lifecycle.py"
click node_subscription "https://github.com/liliwqt/e-menu-web/blob/main/src/context/SubscriptionContext.jsx"
click node_reports "https://github.com/liliwqt/e-menu-web/blob/main/src/pages/AnalyticsPage.jsx"
click node_public_pages "https://github.com/liliwqt/e-menu-web/blob/main/src/pages/PublicPage.jsx"

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_portal,node_identity,node_access,node_dashboard,node_inventory_ui,node_subscription,node_reports,node_public_pages toneBlue
class node_branch_context,node_firebase,node_analytics,node_inventory,node_realtime_db toneAmber
class node_executive,node_analyst_service,node_ai_ui,node_backend_fetch toneMint
class node_gateway_app,node_ai_routes,node_token_auth,node_ai_context,node_llm_gateway,node_orders,node_payments,node_lifecycle toneRose
class node_owner,node_openai toneIndigo
```

## Components

### Restaurant portal

- [Portal routing](https://github.com/liliwqt/e-menu-web/blob/main/src/App.jsx): `src/App.jsx`
- [Identity and workspace](https://github.com/liliwqt/e-menu-web/blob/main/src/context/AuthContext.jsx): `src/context/AuthContext.jsx`
- [Plan and AI access](https://github.com/liliwqt/e-menu-web/blob/main/src/hooks/useAiAccess.js): `src/hooks/useAiAccess.js`
- [Operations dashboard](https://github.com/liliwqt/e-menu-web/blob/main/src/pages/DashboardPage.jsx): `src/pages/DashboardPage.jsx`
- [Inventory workflows](https://github.com/liliwqt/e-menu-web/blob/main/src/pages/InventoryPage.jsx): `src/pages/InventoryPage.jsx`
- [Subscription state](https://github.com/liliwqt/e-menu-web/blob/main/src/context/SubscriptionContext.jsx): `src/context/SubscriptionContext.jsx`
- [Analytics and reports](https://github.com/liliwqt/e-menu-web/blob/main/src/pages/AnalyticsPage.jsx): `src/pages/AnalyticsPage.jsx`
- [Public pages](https://github.com/liliwqt/e-menu-web/blob/main/src/pages/PublicPage.jsx): `src/pages/PublicPage.jsx`

### Restaurant operations

- [Branch data context](https://github.com/liliwqt/e-menu-web/blob/main/src/context/BranchDataContext.jsx): `src/context/BranchDataContext.jsx`
- [Firebase client](https://github.com/liliwqt/e-menu-web/blob/main/src/lib/firebase.js): `src/lib/firebase.js`
- [Sales analytics](https://github.com/liliwqt/e-menu-web/blob/main/src/lib/analyticsApi.js): `src/lib/analyticsApi.js`
- [Inventory and menu](https://github.com/liliwqt/e-menu-web/blob/main/src/lib/menuApi.js): `src/lib/menuApi.js`

### AI intelligence

- [Executive presentation](https://github.com/liliwqt/e-menu-web/blob/main/src/components/ai/ExecutivePresentation.jsx): `src/components/ai/ExecutivePresentation.jsx`
- [AI request client](https://github.com/liliwqt/e-menu-web/blob/main/src/lib/aiAnalystService.js): `src/lib/aiAnalystService.js`
- [AI analyst surfaces](https://github.com/liliwqt/e-menu-web/blob/main/src/components/ai/AIAnalystDrawer.jsx): `src/components/ai/AIAnalystDrawer.jsx`
- [Backend transport](https://github.com/liliwqt/e-menu-web/blob/main/src/lib/backendFetch.js): `src/lib/backendFetch.js`

### Gateway and services

- [FastAPI application](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/app.py): `agent-core/src/touchorders_core/api/app.py`
- [AI routes](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/routes/ai.py): `agent-core/src/touchorders_core/api/routes/ai.py`
- [Token verification](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/auth.py): `agent-core/src/touchorders_core/api/auth.py`
- [AI context shaping](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/ai_context.py): `agent-core/src/touchorders_core/api/ai_context.py`
- [LLM gateway](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/llm/gateway.py): `agent-core/src/touchorders_core/llm/gateway.py`
- [Order services](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/orders.py): `agent-core/src/touchorders_core/api/orders.py`
- [Payment services](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/payments.py): `agent-core/src/touchorders_core/api/payments.py`
- [Lifecycle services](https://github.com/liliwqt/e-menu-web/blob/main/agent-core/src/touchorders_core/api/lifecycle.py): `agent-core/src/touchorders_core/api/lifecycle.py`

### Other components

- **Restaurant staff**
- **Realtime Database**
- **OpenAI**

## Connections

- Restaurant staff → Portal routing: uses (evidence: `README.md`)
- Portal routing → Identity and workspace: renders (evidence: `src/App.jsx`)
- Identity and workspace → Firebase client: authenticates through (evidence: `src/context/AuthContext.jsx`)
- Identity and workspace → Realtime Database: loads workspace data (evidence: `src/context/AuthContext.jsx`)
- Portal routing → Branch data context: scopes branch (evidence: `src/App.jsx`)
- Branch data context → Firebase client: sets branch context (evidence: `src/context/BranchDataContext.jsx`)
- Branch data context → Sales analytics: subscribes to (evidence: `src/context/BranchDataContext.jsx`)
- Branch data context → Inventory and menu: subscribes to (evidence: `src/context/BranchDataContext.jsx`)
- Firebase client → Realtime Database: reads and writes (evidence: `README.md`)
- Operations dashboard → Branch data context: consumes (evidence: `src/pages/DashboardPage.jsx`)
- Operations dashboard → Sales analytics: computes metrics with (evidence: `src/pages/DashboardPage.jsx`)
- Inventory workflows → Branch data context: uses live data (evidence: `README.md`)
- Analytics and reports → Sales analytics: presents metrics (evidence: `README.md`)
- Subscription state → Firebase client: watches entitlements (evidence: `src/context/SubscriptionContext.jsx`)
- Plan and AI access → Subscription state: checks plan (evidence: `src/hooks/useAiAccess.js`)
- Operations dashboard → AI request client: requests interpretation (evidence: `src/pages/DashboardPage.jsx`)
- Executive presentation → AI request client: requests narration (evidence: `src/components/ai/ExecutivePresentation.jsx`)
- AI analyst surfaces → AI request client: requests analysis
- AI request client → Backend transport: posts analysis (evidence: `src/lib/aiAnalystService.js`)
- Backend transport → FastAPI application: sends AI request (evidence: `README.md`)
- FastAPI application → AI routes: registers routes (evidence: `agent-core/src/touchorders_core/api/app.py`)
- AI routes → Token verification: verifies identity (evidence: `README.md`)
- AI routes → AI context shaping: builds request context
- AI routes → LLM gateway: dispatches analysis
- LLM gateway → OpenAI: requests explanation (evidence: `README.md`)
- OpenAI → AI request client: returns structured insights (evidence: `README.md`)
- FastAPI application → Order services: registers routes (evidence: `agent-core/src/touchorders_core/api/app.py`)
- FastAPI application → Payment services: registers routes (evidence: `agent-core/src/touchorders_core/api/app.py`)
- FastAPI application → Lifecycle services: registers routes (evidence: `agent-core/src/touchorders_core/api/app.py`)
- Inventory and menu → Realtime Database: observes inventory (evidence: `README.md`)
- Public pages → Restaurant staff: presents product information (evidence: `README.md`)
