# youssefjbeniani/chicc-commerce architecture

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

- Interactive diagram: https://gitdiagram.com/youssefjbeniani/chicc-commerce
- Repository: https://github.com/youssefjbeniani/chicc-commerce

## Overview

CHICC is a two-site commerce system: customers browse a multilingual catalog and submit website orders; staff authenticate, manage catalog and team access, and process orders through assignment and delivery updates. Both apps use a shared Supabase project, with guest orders routed through a server-side Edge Function. The README also documents manual WhatsApp order intake, image uploads, and optional stock tracking. Several backend and route implementations were not sampled, so those documented connections are cited to the README rather than inferred from filenames.

Main entry points: [`apps/staff/src/app/(workspace)/staff-dashboard.tsx`](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/staff-dashboard.tsx) (Staff dashboard), [`packages/types/src/index.ts`](https://github.com/youssefjbeniani/chicc-commerce/blob/main/packages/types/src/index.ts) (Shared contracts), [`apps/staff/src/app/(workspace)/catalog/page.tsx`](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/page.tsx) (Catalog administration), [`apps/staff/src/app/(workspace)/orders/page.tsx`](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/page.tsx) (Order queue)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_customer["Customer storefront"]
  node_storefront["Storefront routes"]
  node_catalog_view["Catalog browsing"]
  node_product_view["Product details"]
  node_basket["Basket and checkout"]
  node_basket_state["Basket state<br/>[store-basket.ts]"]
  node_order_client["Order submission<br/>[store-order.ts]"]
end

subgraph group_staff["Staff workspace"]
  node_staff_login["Staff sign-in<br/>[actions.ts]"]
  node_access_guard["Role access checks"]
  node_dashboard["Staff dashboard"]
  node_catalog_page["Catalog administration<br/>[page.tsx]"]
  node_catalog_manager["Catalog editor"]
  node_catalog_actions["Catalog operations<br/>[actions.ts]"]
  node_orders_page["Order queue<br/>[page.tsx]"]
  node_orders_board["Order workflow<br/>[orders-board.tsx]"]
  node_order_actions["Order operations<br/>[actions.ts]"]
  node_team_page["Team administration<br/>[page.tsx]"]
  node_team_manager["Team editor<br/>[team-manager.tsx]"]
  node_team_actions["Team operations<br/>[actions.ts]"]
end

subgraph group_backend["Commerce backend"]
  node_edge_order["Guest order function<br/>[index.ts]"]
  node_supabase[("Supabase project")]
end

subgraph group_shared["Shared contracts"]
  node_shared_types["Shared contracts<br/>[index.ts]"]
  node_validation["Input validation<br/>[index.ts]"]
end

node_customer(("Customer"))
node_staff_user(("Staff user"))

node_customer -->|"browses"| node_storefront
node_storefront -.->|"renders catalog"| node_catalog_view
node_storefront -->|"renders product"| node_product_view
node_customer -.->|"submits order"| node_basket
node_catalog_view -->|"adds products"| node_basket
node_basket -.->|"uses state"| node_basket_state
node_basket -.->|"places order"| node_order_client
node_order_client -->|"forwards request"| node_edge_order
node_edge_order -->|"creates order"| node_supabase
node_staff_user -->|"signs in"| node_staff_login
node_staff_login -->|"authenticates"| node_supabase
node_staff_login -->|"validates credentials"| node_validation
node_dashboard -->|"requires identity"| node_access_guard
node_dashboard -->|"links catalog"| node_catalog_page
node_dashboard -->|"links orders"| node_orders_page
node_dashboard -->|"links team"| node_team_page
node_catalog_page -->|"checks role"| node_access_guard
node_catalog_page -->|"reads catalog"| node_supabase
node_catalog_page -->|"renders editor"| node_catalog_manager
node_catalog_manager -->|"invokes edits"| node_catalog_actions
node_catalog_actions -->|"updates catalog"| node_supabase
node_orders_page -->|"checks role"| node_access_guard
node_orders_page -->|"loads orders"| node_supabase
node_orders_page -->|"renders queue"| node_orders_board
node_orders_board -->|"invokes updates"| node_order_actions
node_order_actions -->|"updates status"| node_supabase
node_team_page -->|"renders team"| node_team_manager
node_team_manager -->|"invokes changes"| node_team_actions
node_team_actions -->|"manages accounts"| node_supabase
node_supabase -.->|"reserves stock"| node_edge_order
node_supabase -.->|"stores images"| node_catalog_actions
node_shared_types -.->|"defines contracts"| node_catalog_manager
node_shared_types -.->|"defines contracts"| node_orders_board
node_shared_types -.->|"defines contracts"| node_team_manager
node_shared_types -.->|"defines contracts"| node_catalog_view

click node_storefront "https://github.com/youssefjbeniani/chicc-commerce/tree/main/apps/storefront/src/app"
click node_catalog_view "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/components/storefront-catalog.tsx"
click node_product_view "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/components/storefront-product-page.tsx"
click node_basket "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/components/storefront-basket.tsx"
click node_basket_state "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/lib/store-basket.ts"
click node_order_client "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/lib/store-order.ts"
click node_staff_login "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/actions.ts"
click node_access_guard "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/lib/require-internal-user.ts"
click node_dashboard "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/staff-dashboard.tsx"
click node_catalog_page "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/page.tsx"
click node_catalog_manager "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/catalog-manager.tsx"
click node_catalog_actions "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/actions.ts"
click node_orders_page "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/page.tsx"
click node_orders_board "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/orders-board.tsx"
click node_order_actions "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/actions.ts"
click node_team_page "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/team/page.tsx"
click node_team_manager "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/team/team-manager.tsx"
click node_team_actions "https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/team/actions.ts"
click node_edge_order "https://github.com/youssefjbeniani/chicc-commerce/blob/main/supabase/functions/place-website-order/index.ts"
click node_shared_types "https://github.com/youssefjbeniani/chicc-commerce/blob/main/packages/types/src/index.ts"
click node_validation "https://github.com/youssefjbeniani/chicc-commerce/blob/main/packages/validation/src/index.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_storefront,node_catalog_view,node_product_view,node_basket,node_basket_state,node_order_client,node_staff_user toneBlue
class node_staff_login,node_access_guard,node_dashboard,node_catalog_page,node_catalog_manager,node_catalog_actions,node_orders_page,node_orders_board,node_order_actions,node_team_page,node_team_manager,node_team_actions toneAmber
class node_edge_order,node_supabase toneMint
class node_shared_types,node_validation toneRose
class node_customer toneIndigo
```

## Components

### Customer storefront

- [Storefront routes](https://github.com/youssefjbeniani/chicc-commerce/tree/main/apps/storefront/src/app): `apps/storefront/src/app`
- [Catalog browsing](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/components/storefront-catalog.tsx): `apps/storefront/src/components/storefront-catalog.tsx`
- [Product details](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/components/storefront-product-page.tsx): `apps/storefront/src/components/storefront-product-page.tsx`
- [Basket and checkout](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/components/storefront-basket.tsx): `apps/storefront/src/components/storefront-basket.tsx`
- [Basket state](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/lib/store-basket.ts): `apps/storefront/src/lib/store-basket.ts`
- [Order submission](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/storefront/src/lib/store-order.ts): `apps/storefront/src/lib/store-order.ts`

### Staff workspace

- [Staff sign-in](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/actions.ts): `apps/staff/src/app/actions.ts`
- [Role access checks](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/lib/require-internal-user.ts): `apps/staff/src/lib/require-internal-user.ts`
- [Staff dashboard](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/staff-dashboard.tsx): `apps/staff/src/app/(workspace)/staff-dashboard.tsx`
- [Catalog administration](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/page.tsx): `apps/staff/src/app/(workspace)/catalog/page.tsx`
- [Catalog editor](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/catalog-manager.tsx): `apps/staff/src/app/(workspace)/catalog/catalog-manager.tsx`
- [Catalog operations](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/catalog/actions.ts): `apps/staff/src/app/(workspace)/catalog/actions.ts`
- [Order queue](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/page.tsx): `apps/staff/src/app/(workspace)/orders/page.tsx`
- [Order workflow](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/orders-board.tsx): `apps/staff/src/app/(workspace)/orders/orders-board.tsx`
- [Order operations](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/orders/actions.ts): `apps/staff/src/app/(workspace)/orders/actions.ts`
- [Team administration](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/team/page.tsx): `apps/staff/src/app/(workspace)/team/page.tsx`
- [Team editor](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/team/team-manager.tsx): `apps/staff/src/app/(workspace)/team/team-manager.tsx`
- [Team operations](https://github.com/youssefjbeniani/chicc-commerce/blob/main/apps/staff/src/app/(workspace)/team/actions.ts): `apps/staff/src/app/(workspace)/team/actions.ts`

### Commerce backend

- [Guest order function](https://github.com/youssefjbeniani/chicc-commerce/blob/main/supabase/functions/place-website-order/index.ts): `supabase/functions/place-website-order/index.ts`
- **Supabase project**

### Shared contracts

- [Shared contracts](https://github.com/youssefjbeniani/chicc-commerce/blob/main/packages/types/src/index.ts): `packages/types/src/index.ts`
- [Input validation](https://github.com/youssefjbeniani/chicc-commerce/blob/main/packages/validation/src/index.ts): `packages/validation/src/index.ts`

### Other components

- **Customer**
- **Staff user**

## Connections

- Customer → Storefront routes: browses
- Storefront routes → Catalog browsing: renders catalog
- Storefront routes → Product details: renders product (evidence: `apps/storefront/src/app/products/[slug]/page.tsx`)
- Customer → Basket and checkout: submits order
- Catalog browsing → Basket and checkout: adds products (evidence: `apps/storefront/src/components/storefront-catalog.tsx`)
- Basket and checkout → Basket state: uses state
- Basket and checkout → Order submission: places order
- Order submission → Guest order function: forwards request
- Guest order function → Supabase project: creates order
- Staff user → Staff sign-in: signs in
- Staff sign-in → Supabase project: authenticates (evidence: `apps/staff/src/app/actions.ts`)
- Staff sign-in → Input validation: validates credentials (evidence: `apps/staff/src/app/actions.ts`)
- Staff dashboard → Role access checks: requires identity
- Staff dashboard → Catalog administration: links catalog (evidence: `apps/staff/src/app/(workspace)/staff-dashboard.tsx`)
- Staff dashboard → Order queue: links orders (evidence: `apps/staff/src/app/(workspace)/staff-dashboard.tsx`)
- Staff dashboard → Team administration: links team (evidence: `apps/staff/src/app/(workspace)/staff-dashboard.tsx`)
- Catalog administration → Role access checks: checks role (evidence: `apps/staff/src/app/(workspace)/catalog/page.tsx`)
- Catalog administration → Supabase project: reads catalog (evidence: `apps/staff/src/app/(workspace)/catalog/page.tsx`)
- Catalog administration → Catalog editor: renders editor (evidence: `apps/staff/src/app/(workspace)/catalog/page.tsx`)
- Catalog editor → Catalog operations: invokes edits (evidence: `apps/staff/src/app/(workspace)/catalog/catalog-manager.tsx`)
- Catalog operations → Supabase project: updates catalog
- Order queue → Role access checks: checks role (evidence: `apps/staff/src/app/(workspace)/orders/page.tsx`)
- Order queue → Supabase project: loads orders (evidence: `apps/staff/src/app/(workspace)/orders/page.tsx`)
- Order queue → Order workflow: renders queue (evidence: `apps/staff/src/app/(workspace)/orders/page.tsx`)
- Order workflow → Order operations: invokes updates (evidence: `apps/staff/src/app/(workspace)/orders/actions.ts`)
- Order operations → Supabase project: updates status
- Team administration → Team editor: renders team (evidence: `apps/staff/src/app/(workspace)/team/page.tsx`)
- Team editor → Team operations: invokes changes (evidence: `apps/staff/src/app/(workspace)/team/team-manager.tsx`)
- Team operations → Supabase project: manages accounts
- Supabase project → Guest order function: reserves stock
- Supabase project → Catalog operations: stores images
- Shared contracts → Catalog editor: defines contracts
- Shared contracts → Order workflow: defines contracts
- Shared contracts → Team editor: defines contracts
- Shared contracts → Catalog browsing: defines contracts
