# tharungowda03/cake-box-bakery architecture

> Architecture diagram of the GitHub repository tharungowda03/cake-box-bakery, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tharungowda03/cake-box-bakery
- Repository: https://github.com/tharungowda03/cake-box-bakery

## Overview

Cake Box Kakinada is a bakery storefront and operations platform. Customers browse the live catalogue, build a cart, check out for delivery or pickup, and track orders; custom-cake requests follow a separate owner-reviewed quotation workflow. Owners manage orders, products, settings, and business knowledge. The server validates commerce and delivery rules, while the chat assistant retrieves approved knowledge and live catalogue context before answering. The map combines sampled client/service code with README-documented capabilities; unsampled route internals are represented only where documented.

Main entry points: [`client/src/services/apiService.ts`](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/apiService.ts) (API client), [`client/src/App.tsx`](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/App.tsx) (Application router), [`server/src/app.ts`](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/app.ts) (API application), [`server/src/config/supabase.ts`](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/config/supabase.ts) (Supabase access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Application router<br/>[App.tsx]"]
  node_catalogue["Catalogue browsing"]
  node_showcase["Home showcase<br/>[showcaseService.ts]"]
  node_auth["Authentication<br/>[AuthContext.tsx]"]
end

subgraph group_commerce["Ordering"]
  node_cart["Cart<br/>[CartContext.tsx]"]
  node_checkout["Checkout<br/>[CheckoutPage.tsx]"]
  node_orders["Orders and tracking<br/>[OrdersPage.tsx]"]
  node_customcakes["Custom cake requests<br/>[CustomCakePage.tsx]"]
end

subgraph group_operations["Bakery operations"]
  node_ownerconsole["Owner dashboard"]
end

subgraph group_backend["Backend services"]
  node_clientapi["API client<br/>[apiService.ts]"]
  node_server["API application<br/>[app.ts]"]
  node_orderroute["Order endpoints<br/>[orders.ts]"]
  node_customroute["Custom-order endpoints<br/>[customOrders.ts]"]
  node_ownerroutes["Owner endpoints<br/>[owner.ts]"]
  node_delivery["Delivery calculation<br/>[deliveryService.ts]"]
  node_supabaseclient["Supabase client<br/>[supabase.ts]"]
  node_supabaseserver["Supabase access<br/>[supabase.ts]"]
end

subgraph group_assistant["AI assistant"]
  node_chatwidget["Chat interface<br/>[ChatWidget.tsx]"]
  node_chatroute["Chat endpoint<br/>[chat.ts]"]
  node_rag["Knowledge retrieval<br/>[ragService.ts]"]
end

node_customer(("Customer"))
node_owner(("Owner"))
node_database[("Supabase PostgreSQL")]
node_gemini{{"Gemini AI"}}

node_customer -->|"uses"| node_app
node_owner -->|"uses"| node_app
node_app -->|"loads catalogue"| node_catalogue
node_catalogue -->|"queries products"| node_supabaseclient
node_supabaseclient -->|"reads catalogue"| node_database
node_app -->|"loads slides"| node_showcase
node_showcase -->|"requests slides"| node_clientapi
node_app -->|"provides session"| node_auth
node_auth -->|"authenticates"| node_supabaseclient
node_customer -->|"adds products"| node_cart
node_cart -->|"supplies cart"| node_checkout
node_checkout -->|"submits order"| node_clientapi
node_clientapi -->|"sends API request"| node_server
node_server -->|"dispatches orders"| node_orderroute
node_orderroute -->|"checks delivery"| node_delivery
node_orderroute -->|"validates and stores"| node_supabaseserver
node_supabaseserver -->|"reads and writes"| node_database
node_clientapi -->|"returns order data"| node_orders
node_app -->|"opens request flow"| node_customcakes
node_customcakes -->|"submits request"| node_clientapi
node_server -->|"dispatches requests"| node_customroute
node_customroute -->|"stores requests"| node_supabaseserver
node_owner -->|"manages bakery"| node_ownerconsole
node_ownerconsole -->|"requests operations"| node_clientapi
node_server -->|"dispatches owner APIs"| node_ownerroutes
node_ownerroutes -->|"manages business data"| node_supabaseserver
node_customer -->|"asks question"| node_chatwidget
node_chatwidget -->|"sends chat"| node_clientapi
node_server -->|"dispatches chat"| node_chatroute
node_chatroute -->|"builds context"| node_rag
node_rag -->|"embeds query"| node_gemini
node_rag -->|"retrieves knowledge and products"| node_supabaseserver
node_rag -->|"returns context"| node_chatroute
node_chatroute -->|"generates answer"| node_gemini

click node_app "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/App.tsx"
click node_catalogue "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/catalogueService.ts"
click node_showcase "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/showcaseService.ts"
click node_auth "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/contexts/AuthContext.tsx"
click node_cart "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/contexts/CartContext.tsx"
click node_checkout "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/CheckoutPage.tsx"
click node_orders "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/OrdersPage.tsx"
click node_customcakes "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/CustomCakePage.tsx"
click node_ownerconsole "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/OwnerDashboardPage.tsx"
click node_clientapi "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/apiService.ts"
click node_server "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/app.ts"
click node_orderroute "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/orders.ts"
click node_customroute "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/customOrders.ts"
click node_ownerroutes "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/owner.ts"
click node_delivery "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/services/deliveryService.ts"
click node_chatwidget "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/components/chat/ChatWidget.tsx"
click node_chatroute "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/chat.ts"
click node_rag "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/services/ragService.ts"
click node_supabaseclient "https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/lib/supabase.ts"
click node_supabaseserver "https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/config/supabase.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_app,node_catalogue,node_showcase,node_auth toneBlue
class node_cart,node_checkout,node_orders,node_customcakes,node_database toneAmber
class node_ownerconsole toneMint
class node_clientapi,node_server,node_orderroute,node_customroute,node_ownerroutes,node_delivery,node_supabaseclient,node_supabaseserver toneRose
class node_chatwidget,node_chatroute,node_rag,node_customer,node_owner,node_gemini toneIndigo
```

## Components

### Storefront

- [Application router](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Catalogue browsing](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/catalogueService.ts): `client/src/services/catalogueService.ts`
- [Home showcase](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/showcaseService.ts): `client/src/services/showcaseService.ts`
- [Authentication](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/contexts/AuthContext.tsx): `client/src/contexts/AuthContext.tsx`

### Ordering

- [Cart](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/contexts/CartContext.tsx): `client/src/contexts/CartContext.tsx`
- [Checkout](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/CheckoutPage.tsx): `client/src/pages/CheckoutPage.tsx`
- [Orders and tracking](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/OrdersPage.tsx): `client/src/pages/OrdersPage.tsx`
- [Custom cake requests](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/CustomCakePage.tsx): `client/src/pages/CustomCakePage.tsx`

### Bakery operations

- [Owner dashboard](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/pages/OwnerDashboardPage.tsx): `client/src/pages/OwnerDashboardPage.tsx`

### Backend services

- [API client](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/services/apiService.ts): `client/src/services/apiService.ts`
- [API application](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/app.ts): `server/src/app.ts`
- [Order endpoints](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/orders.ts): `server/src/routes/orders.ts`
- [Custom-order endpoints](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/customOrders.ts): `server/src/routes/customOrders.ts`
- [Owner endpoints](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/owner.ts): `server/src/routes/owner.ts`
- [Delivery calculation](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/services/deliveryService.ts): `server/src/services/deliveryService.ts`
- [Supabase client](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/lib/supabase.ts): `client/src/lib/supabase.ts`
- [Supabase access](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/config/supabase.ts): `server/src/config/supabase.ts`

### AI assistant

- [Chat interface](https://github.com/tharungowda03/cake-box-bakery/blob/main/client/src/components/chat/ChatWidget.tsx): `client/src/components/chat/ChatWidget.tsx`
- [Chat endpoint](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/routes/chat.ts): `server/src/routes/chat.ts`
- [Knowledge retrieval](https://github.com/tharungowda03/cake-box-bakery/blob/main/server/src/services/ragService.ts): `server/src/services/ragService.ts`

### Other components

- **Customer**
- **Owner**
- **Supabase PostgreSQL**
- **Gemini AI**

## Connections

- Customer → Application router: uses
- Owner → Application router: uses
- Application router → Catalogue browsing: loads catalogue
- Catalogue browsing → Supabase client: queries products
- Supabase client → Supabase PostgreSQL: reads catalogue
- Application router → Home showcase: loads slides
- Home showcase → API client: requests slides
- Application router → Authentication: provides session
- Authentication → Supabase client: authenticates
- Customer → Cart: adds products
- Cart → Checkout: supplies cart
- Checkout → API client: submits order
- API client → API application: sends API request
- API application → Order endpoints: dispatches orders
- Order endpoints → Delivery calculation: checks delivery
- Order endpoints → Supabase access: validates and stores
- Supabase access → Supabase PostgreSQL: reads and writes
- API client → Orders and tracking: returns order data
- Application router → Custom cake requests: opens request flow
- Custom cake requests → API client: submits request
- API application → Custom-order endpoints: dispatches requests
- Custom-order endpoints → Supabase access: stores requests
- Owner → Owner dashboard: manages bakery
- Owner dashboard → API client: requests operations
- API application → Owner endpoints: dispatches owner APIs
- Owner endpoints → Supabase access: manages business data
- Customer → Chat interface: asks question
- Chat interface → API client: sends chat
- API application → Chat endpoint: dispatches chat
- Chat endpoint → Knowledge retrieval: builds context
- Knowledge retrieval → Gemini AI: embeds query
- Knowledge retrieval → Supabase access: retrieves knowledge and products
- Knowledge retrieval → Chat endpoint: returns context
- Chat endpoint → Gemini AI: generates answer
