# klisarsana/warcoffe-13 architecture

> Architecture diagram of the GitHub repository klisarsana/warcoffe-13, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/klisarsana/warcoffe-13
- Repository: https://github.com/klisarsana/warcoffe-13

## Overview

Warcoffe 13 is an owner-only café management web app. The owner signs in, then records sales through POS or operational expenses, maintains the menu and stock, and reviews transaction history, dashboard summaries, and monthly reports; an AI assistant offers chat and owner-confirmed transaction drafts. The shared business context coordinates domain data and persistence, while calculation and formatting utilities support views. Relationships reflect README statements and source-index references; unsampled implementation details are not inferred.

Main entry points: [`src/context/warcoffe-context.tsx`](https://github.com/klisarsana/warcoffe-13/blob/main/src/context/warcoffe-context.tsx) (Business State), [`src/lib/ai-adapter.ts`](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/ai-adapter.ts) (AI Service Adapter), [`src/app/ai-assistant/page.tsx`](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/ai-assistant/page.tsx) (AI Assistant UI), [`src/context/auth-context.tsx`](https://github.com/klisarsana/warcoffe-13/blob/main/src/context/auth-context.tsx) (Auth Provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Owner Access"]
  node_login["Owner Login<br/>[page.tsx]"]
  node_auth_ui["Auth Provider<br/>[auth-context.tsx]"]
  node_auth_helpers["Auth Helpers<br/>[auth.ts]"]
  node_shell["Protected App Shell<br/>[app-shell.tsx]"]
end

subgraph group_operations["Business Operations"]
  node_pos["Point of Sale<br/>[page.tsx]"]
  node_transactions["Transaction History<br/>[page.tsx]"]
  node_expenses["Expense Management<br/>[page.tsx]"]
  node_menu["Menu Management<br/>[page.tsx]"]
  node_stock["Stock Management<br/>[page.tsx]"]
end

subgraph group_insights["Business Insights"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_reports["Monthly Reports<br/>[page.tsx]"]
end

subgraph group_platform["Shared Data and Services"]
  node_business_context["Business State"]
  node_persistence["Persistence Adapter<br/>[supabase.ts]"]
  node_supabase_auth["Supabase Auth"]
  node_business_store[("Business Data Store")]
  node_calculations["Business Calculations<br/>[calculations.ts]"]
  node_formatting["Locale and CSV Utilities<br/>[format.ts]"]
  node_menu_seed["Official Menu Seed<br/>[menu-seed-data.ts]"]
end

subgraph group_assistant["AI Assistant"]
  node_ai_page["AI Assistant UI<br/>[page.tsx]"]
  node_ai_adapter["AI Service Adapter<br/>[ai-adapter.ts]"]
  node_parse_route["Transaction Parse Proxy<br/>[route.ts]"]
  node_chat_route["Chat Proxy<br/>[route.ts]"]
end

node_owner(("Business Owner"))
node_ai_service["FastAPI AI Service"]

node_owner -->|"signs in"| node_login
node_login -->|"uses auth"| node_auth_ui
node_auth_ui -->|"delegates auth"| node_auth_helpers
node_auth_helpers -->|"authenticates with"| node_supabase_auth
node_auth_ui -->|"checks configuration"| node_persistence
node_shell -->|"reads session"| node_auth_ui
node_shell -->|"reads storage mode"| node_business_context
node_owner -->|"records sales"| node_pos
node_owner -->|"records expenses"| node_expenses
node_owner -->|"manages catalog"| node_menu
node_owner -->|"updates stock"| node_stock
node_owner -->|"reviews records"| node_transactions
node_pos -->|"creates sales"| node_business_context
node_expenses -->|"manages expenses"| node_business_context
node_menu -->|"manages menu"| node_business_context
node_stock -->|"manages stock"| node_business_context
node_transactions -->|"edits records"| node_business_context
node_business_context -->|"loads and persists"| node_persistence
node_persistence -->|"reads and writes"| node_business_store
node_business_context -->|"loads seed data"| node_menu_seed
node_dashboard -->|"reads business data"| node_business_context
node_reports -->|"reads business data"| node_business_context
node_dashboard -->|"calculates summaries"| node_calculations
node_reports -->|"calculates reports"| node_calculations
node_pos -->|"validates sales"| node_calculations
node_stock -->|"calculates stock"| node_calculations
node_dashboard -->|"formats values"| node_formatting
node_reports -->|"formats and exports"| node_formatting
node_owner -->|"asks and drafts"| node_ai_page
node_ai_page -->|"sends requests"| node_ai_adapter
node_ai_page -->|"reads business context"| node_business_context
node_ai_adapter -->|"posts draft request"| node_parse_route
node_ai_adapter -->|"posts chat request"| node_chat_route
node_parse_route -->|"uses adapter"| node_ai_adapter
node_chat_route -->|"uses adapter"| node_ai_adapter
node_parse_route -->|"forwards parse request"| node_ai_service
node_chat_route -->|"forwards chat request"| node_ai_service
node_ai_page -.->|"saves confirmed drafts"| node_business_context

click node_login "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/page.tsx"
click node_auth_ui "https://github.com/klisarsana/warcoffe-13/blob/main/src/context/auth-context.tsx"
click node_auth_helpers "https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/auth.ts"
click node_shell "https://github.com/klisarsana/warcoffe-13/blob/main/src/components/layout/app-shell.tsx"
click node_pos "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/pos/page.tsx"
click node_transactions "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/transactions/page.tsx"
click node_expenses "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/expenses/page.tsx"
click node_menu "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/menu/page.tsx"
click node_stock "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/stock/page.tsx"
click node_dashboard "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/dashboard/page.tsx"
click node_reports "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/reports/page.tsx"
click node_business_context "https://github.com/klisarsana/warcoffe-13/blob/main/src/context/warcoffe-context.tsx"
click node_persistence "https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/supabase.ts"
click node_calculations "https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/calculations.ts"
click node_formatting "https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/format.ts"
click node_menu_seed "https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/menu-seed-data.ts"
click node_ai_page "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/ai-assistant/page.tsx"
click node_ai_adapter "https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/ai-adapter.ts"
click node_parse_route "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/api/ai/parse-transaction/route.ts"
click node_chat_route "https://github.com/klisarsana/warcoffe-13/blob/main/src/app/api/ai/chat/route.ts"

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_login,node_auth_ui,node_auth_helpers,node_shell toneBlue
class node_pos,node_transactions,node_expenses,node_menu,node_stock toneAmber
class node_dashboard,node_reports,node_ai_service toneMint
class node_business_context,node_persistence,node_supabase_auth,node_business_store,node_calculations,node_formatting,node_menu_seed toneRose
class node_ai_page,node_ai_adapter,node_parse_route,node_chat_route,node_owner toneIndigo
```

## Components

### Owner Access

- [Owner Login](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Auth Provider](https://github.com/klisarsana/warcoffe-13/blob/main/src/context/auth-context.tsx): `src/context/auth-context.tsx`
- [Auth Helpers](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Protected App Shell](https://github.com/klisarsana/warcoffe-13/blob/main/src/components/layout/app-shell.tsx): `src/components/layout/app-shell.tsx`

### Business Operations

- [Point of Sale](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/pos/page.tsx): `src/app/pos/page.tsx`
- [Transaction History](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/transactions/page.tsx): `src/app/transactions/page.tsx`
- [Expense Management](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/expenses/page.tsx): `src/app/expenses/page.tsx`
- [Menu Management](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/menu/page.tsx): `src/app/menu/page.tsx`
- [Stock Management](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/stock/page.tsx): `src/app/stock/page.tsx`

### Business Insights

- [Dashboard](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/dashboard/page.tsx): `src/app/dashboard/page.tsx`
- [Monthly Reports](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/reports/page.tsx): `src/app/reports/page.tsx`

### Shared Data and Services

- [Business State](https://github.com/klisarsana/warcoffe-13/blob/main/src/context/warcoffe-context.tsx): `src/context/warcoffe-context.tsx`
- [Persistence Adapter](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/supabase.ts): `src/lib/supabase.ts`
- **Supabase Auth**
- **Business Data Store**
- [Business Calculations](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/calculations.ts): `src/lib/calculations.ts`
- [Locale and CSV Utilities](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/format.ts): `src/lib/format.ts`
- [Official Menu Seed](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/menu-seed-data.ts): `src/lib/menu-seed-data.ts`

### AI Assistant

- [AI Assistant UI](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/ai-assistant/page.tsx): `src/app/ai-assistant/page.tsx`
- [AI Service Adapter](https://github.com/klisarsana/warcoffe-13/blob/main/src/lib/ai-adapter.ts): `src/lib/ai-adapter.ts`
- [Transaction Parse Proxy](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/api/ai/parse-transaction/route.ts): `src/app/api/ai/parse-transaction/route.ts`
- [Chat Proxy](https://github.com/klisarsana/warcoffe-13/blob/main/src/app/api/ai/chat/route.ts): `src/app/api/ai/chat/route.ts`

### Other components

- **Business Owner**
- **FastAPI AI Service**

## Connections

- Business Owner → Owner Login: signs in (evidence: `README.md`)
- Owner Login → Auth Provider: uses auth (evidence: `src/app/page.tsx`)
- Auth Provider → Auth Helpers: delegates auth (evidence: `src/context/auth-context.tsx`)
- Auth Helpers → Supabase Auth: authenticates with (evidence: `src/lib/auth.ts`)
- Auth Provider → Persistence Adapter: checks configuration (evidence: `src/context/auth-context.tsx`)
- Protected App Shell → Auth Provider: reads session (evidence: `src/components/layout/app-shell.tsx`)
- Protected App Shell → Business State: reads storage mode (evidence: `src/components/layout/app-shell.tsx`)
- Business Owner → Point of Sale: records sales (evidence: `README.md`)
- Business Owner → Expense Management: records expenses (evidence: `README.md`)
- Business Owner → Menu Management: manages catalog (evidence: `README.md`)
- Business Owner → Stock Management: updates stock (evidence: `README.md`)
- Business Owner → Transaction History: reviews records (evidence: `README.md`)
- Point of Sale → Business State: creates sales (evidence: `src/app/pos/page.tsx`)
- Expense Management → Business State: manages expenses (evidence: `src/app/expenses/page.tsx`)
- Menu Management → Business State: manages menu (evidence: `src/app/menu/page.tsx`)
- Stock Management → Business State: manages stock (evidence: `src/app/stock/page.tsx`)
- Transaction History → Business State: edits records (evidence: `src/app/transactions/page.tsx`)
- Business State → Persistence Adapter: loads and persists (evidence: `src/context/warcoffe-context.tsx`)
- Persistence Adapter → Business Data Store: reads and writes (evidence: `src/lib/supabase.ts`)
- Business State → Official Menu Seed: loads seed data (evidence: `src/context/warcoffe-context.tsx`)
- Dashboard → Business State: reads business data (evidence: `src/app/dashboard/page.tsx`)
- Monthly Reports → Business State: reads business data (evidence: `src/app/reports/page.tsx`)
- Dashboard → Business Calculations: calculates summaries (evidence: `src/app/dashboard/page.tsx`)
- Monthly Reports → Business Calculations: calculates reports (evidence: `src/app/reports/page.tsx`)
- Point of Sale → Business Calculations: validates sales (evidence: `src/app/pos/page.tsx`)
- Stock Management → Business Calculations: calculates stock (evidence: `src/app/stock/page.tsx`)
- Dashboard → Locale and CSV Utilities: formats values (evidence: `src/app/dashboard/page.tsx`)
- Monthly Reports → Locale and CSV Utilities: formats and exports (evidence: `src/app/reports/page.tsx`)
- Business Owner → AI Assistant UI: asks and drafts (evidence: `README.md`)
- AI Assistant UI → AI Service Adapter: sends requests (evidence: `src/app/ai-assistant/page.tsx`)
- AI Assistant UI → Business State: reads business context (evidence: `src/app/ai-assistant/page.tsx`)
- AI Service Adapter → Transaction Parse Proxy: posts draft request (evidence: `src/lib/ai-adapter.ts`)
- AI Service Adapter → Chat Proxy: posts chat request (evidence: `src/lib/ai-adapter.ts`)
- Transaction Parse Proxy → AI Service Adapter: uses adapter (evidence: `src/app/api/ai/parse-transaction/route.ts`)
- Chat Proxy → AI Service Adapter: uses adapter (evidence: `src/app/api/ai/chat/route.ts`)
- Transaction Parse Proxy → FastAPI AI Service: forwards parse request (evidence: `README.md`)
- Chat Proxy → FastAPI AI Service: forwards chat request (evidence: `README.md`)
- AI Assistant UI → Business State: saves confirmed drafts (evidence: `README.md`)
