# ashutoshpatraa/cafe-theory architecture

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

- Interactive diagram: https://gitdiagram.com/ashutoshpatraa/cafe-theory
- Repository: https://github.com/ashutoshpatraa/cafe-theory

## Overview

Cup Theory is a café ordering portal with a customer storefront and an admin BI/operations portal. Customers authenticate, browse products and offers, maintain a persistent cart, check out, and track or reorder purchases; administrators manage orders and menu data and review analytics and inventory. The graph separates the client, HTTP API, domain services, and persistence. Some route wiring and unsampled page implementations are not shown, so those links are omitted or marked unverified.

Main entry points: [`client/src/App.tsx`](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/App.tsx) (Route Shell), [`client/src/services/api.ts`](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/services/api.ts) (API Client), [`server/src/utils/prisma.ts`](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/utils/prisma.ts) (SQLite via Prisma), [`client/src/pages/Home.tsx`](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Home.tsx) (Home Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer and Admin Client"]
  node_app["Route Shell<br/>[App.tsx]"]
  node_home["Home Dashboard<br/>[Home.tsx]"]
  node_menu["Explore Menu<br/>[ExploreMenu.tsx]"]
  node_auth["Auth State<br/>[authStore.ts]"]
  node_cart["Cart State<br/>[cartStore.ts]"]
  node_checkout["Checkout<br/>[Checkout.tsx]"]
  node_orders["Order History<br/>[Orders.tsx]"]
  node_profile["Profile<br/>[Profile.tsx]"]
  node_adminui["Admin Portal<br/>[AdminLayout.tsx]"]
  node_adminpages["Admin Operations"]
  node_admininventory["Inventory UI<br/>[AdminInventory.tsx]"]
  node_clientapi["API Client<br/>[api.ts]"]
  node_adminapi["Admin API Client<br/>[adminApi.ts]"]
end

subgraph group_api["HTTP API"]
  node_authctl["Auth Controller<br/>[authController.ts]"]
  node_cartctl["Cart Controller<br/>[cartController.ts]"]
  node_orderctl["Order Controller<br/>[orderController.ts]"]
  node_productctl["Product Controller"]
  node_adminctl["Admin Controller<br/>[adminController.ts]"]
  node_authmw["Cookie Authentication<br/>[auth.ts]"]
end

subgraph group_domain["Domain Services"]
  node_authsvc["Authentication<br/>[authService.ts]"]
  node_cartsvc["Cart Management<br/>[cartService.ts]"]
  node_ordersvc["Order Processing<br/>[orderService.ts]"]
  node_productsvc["Menu and Offers<br/>[productService.ts]"]
  node_adminsvc["Admin BI and Management"]
end

subgraph group_persistence["Persistence"]
  node_database[("SQLite via Prisma<br/>[prisma.ts]")]
end

node_customer(("Customer"))
node_admin(("Café Admin"))

node_customer -->|"uses portal"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_menu
node_app -->|"routes to"| node_checkout
node_app -->|"routes to"| node_orders
node_app -->|"routes to"| node_profile
node_app -->|"checks session"| node_auth
node_home -->|"loads featured and offers"| node_clientapi
node_home -->|"adds products"| node_cart
node_auth -->|"calls auth API"| node_clientapi
node_cart -->|"calls cart API"| node_clientapi
node_checkout -->|"creates order"| node_clientapi
node_admin -->|"uses portal"| node_adminui
node_app -->|"routes to"| node_adminui
node_adminui -->|"hosts views"| node_adminpages
node_admininventory -->|"loads inventory"| node_adminapi
node_adminpages -.->|"requests admin data"| node_adminapi
node_clientapi -.->|"sends HTTP requests"| node_authctl
node_clientapi -.->|"sends HTTP requests"| node_cartctl
node_clientapi -.->|"sends HTTP requests"| node_orderctl
node_clientapi -.->|"sends HTTP requests"| node_productctl
node_adminapi -.->|"sends HTTP requests"| node_adminctl
node_authctl -->|"delegates auth"| node_authsvc
node_cartctl -->|"delegates cart"| node_cartsvc
node_orderctl -->|"delegates orders"| node_ordersvc
node_productctl -->|"delegates products"| node_productsvc
node_adminctl -->|"delegates admin work"| node_adminsvc
node_authctl -->|"uses request identity"| node_authmw
node_authsvc -->|"reads and writes"| node_database
node_cartsvc -->|"reads and writes"| node_database
node_ordersvc -->|"reads and writes"| node_database
node_adminsvc -->|"queries and updates"| node_database

click node_app "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/App.tsx"
click node_home "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Home.tsx"
click node_menu "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/ExploreMenu.tsx"
click node_auth "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/store/authStore.ts"
click node_cart "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/store/cartStore.ts"
click node_checkout "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Checkout.tsx"
click node_orders "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Orders.tsx"
click node_profile "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Profile.tsx"
click node_adminui "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/components/admin/AdminLayout.tsx"
click node_adminpages "https://github.com/ashutoshpatraa/cafe-theory/tree/main/client/src/pages/admin"
click node_admininventory "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/admin/AdminInventory.tsx"
click node_clientapi "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/services/api.ts"
click node_adminapi "https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/services/adminApi.ts"
click node_authctl "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/authController.ts"
click node_cartctl "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/cartController.ts"
click node_orderctl "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/orderController.ts"
click node_productctl "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/productController.ts"
click node_adminctl "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/adminController.ts"
click node_authsvc "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/authService.ts"
click node_cartsvc "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/cartService.ts"
click node_ordersvc "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/orderService.ts"
click node_productsvc "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/productService.ts"
click node_adminsvc "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/adminDashboardService.ts"
click node_authmw "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/middleware/auth.ts"
click node_database "https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/utils/prisma.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_home,node_menu,node_auth,node_cart,node_checkout,node_orders,node_profile,node_adminui,node_adminpages,node_admininventory,node_clientapi,node_adminapi toneBlue
class node_authctl,node_cartctl,node_orderctl,node_productctl,node_adminctl,node_authmw toneAmber
class node_authsvc,node_cartsvc,node_ordersvc,node_productsvc,node_adminsvc toneMint
class node_database toneRose
class node_customer,node_admin toneIndigo
```

## Components

### Customer and Admin Client

- [Route Shell](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Home Dashboard](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Home.tsx): `client/src/pages/Home.tsx`
- [Explore Menu](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/ExploreMenu.tsx): `client/src/pages/ExploreMenu.tsx`
- [Auth State](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/store/authStore.ts): `client/src/store/authStore.ts`
- [Cart State](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/store/cartStore.ts): `client/src/store/cartStore.ts`
- [Checkout](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Checkout.tsx): `client/src/pages/Checkout.tsx`
- [Order History](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Orders.tsx): `client/src/pages/Orders.tsx`
- [Profile](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/Profile.tsx): `client/src/pages/Profile.tsx`
- [Admin Portal](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/components/admin/AdminLayout.tsx): `client/src/components/admin/AdminLayout.tsx`
- [Admin Operations](https://github.com/ashutoshpatraa/cafe-theory/tree/main/client/src/pages/admin): `client/src/pages/admin`
- [Inventory UI](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/pages/admin/AdminInventory.tsx): `client/src/pages/admin/AdminInventory.tsx`
- [API Client](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/services/api.ts): `client/src/services/api.ts`
- [Admin API Client](https://github.com/ashutoshpatraa/cafe-theory/blob/main/client/src/services/adminApi.ts): `client/src/services/adminApi.ts`

### HTTP API

- [Auth Controller](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/authController.ts): `server/src/controllers/authController.ts`
- [Cart Controller](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/cartController.ts): `server/src/controllers/cartController.ts`
- [Order Controller](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/orderController.ts): `server/src/controllers/orderController.ts`
- [Product Controller](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/productController.ts): `server/src/controllers/productController.ts`
- [Admin Controller](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/controllers/adminController.ts): `server/src/controllers/adminController.ts`
- [Cookie Authentication](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/middleware/auth.ts): `server/src/middleware/auth.ts`

### Domain Services

- [Authentication](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/authService.ts): `server/src/services/authService.ts`
- [Cart Management](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/cartService.ts): `server/src/services/cartService.ts`
- [Order Processing](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/orderService.ts): `server/src/services/orderService.ts`
- [Menu and Offers](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/productService.ts): `server/src/services/productService.ts`
- [Admin BI and Management](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/services/adminDashboardService.ts): `server/src/services/adminDashboardService.ts`

### Persistence

- [SQLite via Prisma](https://github.com/ashutoshpatraa/cafe-theory/blob/main/server/src/utils/prisma.ts): `server/src/utils/prisma.ts`

### Other components

- **Customer**
- **Café Admin**

## Connections

- Customer → Route Shell: uses portal (evidence: `README.md`)
- Route Shell → Home Dashboard: routes to (evidence: `client/src/App.tsx`)
- Route Shell → Explore Menu: routes to (evidence: `client/src/App.tsx`)
- Route Shell → Checkout: routes to (evidence: `client/src/App.tsx`)
- Route Shell → Order History: routes to (evidence: `client/src/App.tsx`)
- Route Shell → Profile: routes to (evidence: `client/src/App.tsx`)
- Route Shell → Auth State: checks session (evidence: `client/src/App.tsx`)
- Home Dashboard → API Client: loads featured and offers (evidence: `client/src/pages/Home.tsx`)
- Home Dashboard → Cart State: adds products (evidence: `client/src/pages/Home.tsx`)
- Auth State → API Client: calls auth API (evidence: `client/src/store/authStore.ts`)
- Cart State → API Client: calls cart API (evidence: `client/src/store/cartStore.ts`)
- Checkout → API Client: creates order (evidence: `client/src/pages/Checkout.tsx`)
- Café Admin → Admin Portal: uses portal (evidence: `README.md`)
- Route Shell → Admin Portal: routes to (evidence: `client/src/App.tsx`)
- Admin Portal → Admin Operations: hosts views (evidence: `client/src/App.tsx`)
- Inventory UI → Admin API Client: loads inventory (evidence: `client/src/pages/admin/AdminInventory.tsx`)
- Admin Operations → Admin API Client: requests admin data (evidence: `client/src/pages/admin/AdminInventory.tsx`)
- API Client → Auth Controller: sends HTTP requests
- API Client → Cart Controller: sends HTTP requests
- API Client → Order Controller: sends HTTP requests
- API Client → Product Controller: sends HTTP requests
- Admin API Client → Admin Controller: sends HTTP requests
- Auth Controller → Authentication: delegates auth (evidence: `server/src/controllers/authController.ts`)
- Cart Controller → Cart Management: delegates cart (evidence: `server/src/controllers/cartController.ts`)
- Order Controller → Order Processing: delegates orders (evidence: `server/src/controllers/orderController.ts`)
- Product Controller → Menu and Offers: delegates products (evidence: `server/src/controllers/productController.ts`)
- Admin Controller → Admin BI and Management: delegates admin work (evidence: `server/src/controllers/adminController.ts`)
- Auth Controller → Cookie Authentication: uses request identity (evidence: `server/src/controllers/authController.ts`)
- Authentication → SQLite via Prisma: reads and writes (evidence: `server/src/services/authService.ts`)
- Cart Management → SQLite via Prisma: reads and writes (evidence: `server/src/services/cartService.ts`)
- Order Processing → SQLite via Prisma: reads and writes (evidence: `server/src/services/orderService.ts`)
- Admin BI and Management → SQLite via Prisma: queries and updates (evidence: `server/src/services/adminDashboardService.ts`)
