# saadosama10/hattah-store architecture

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

- Interactive diagram: https://gitdiagram.com/saadosama10/hattah-store
- Repository: https://github.com/saadosama10/hattah-store

## Overview

HATTAH is a multilingual catalogue and WhatsApp-order storefront, with a private admin panel for managing products, categories, and inventory. Customers browse localized listings, inspect products and variants, then order directly or build a persisted cart for WhatsApp checkout. The owner signs in to administer the catalogue and inventory. The graph follows documented runtime relationships and indexed source references; unsampled implementation details are omitted where connections cannot be verified.

Main entry points: [`src/lib/supabase/queries.ts`](https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/queries.ts) (Catalogue queries), [`src/lib/admin-auth.ts`](https://github.com/saadosama10/hattah-store/blob/main/src/lib/admin-auth.ts) (Session security), [`src/actions/products.ts`](https://github.com/saadosama10/hattah-store/blob/main/src/actions/products.ts) (Product actions), [`src/actions/inventory.ts`](https://github.com/saadosama10/hattah-store/blob/main/src/actions/inventory.ts) (Inventory actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home page<br/>[page.tsx]"]
  node_shop["Shop page<br/>[page.tsx]"]
  node_shopui["Shop filters<br/>[ShopClient.tsx]"]
  node_productpage["Product page<br/>[page.tsx]"]
  node_offers["Offers page<br/>[page.tsx]"]
end

subgraph group_ordering["Ordering"]
  node_purchase["Purchase actions"]
  node_cart["Cart state<br/>[CartContext.tsx]"]
  node_cartdrawer["Cart drawer<br/>[CartDrawer.tsx]"]
  node_whatsappmsg["Order message<br/>[whatsapp.ts]"]
end

subgraph group_admin["Admin"]
  node_adminlogin["Admin login<br/>[page.tsx]"]
  node_loginform["Login form<br/>[LoginForm.tsx]"]
  node_authaction["Auth actions<br/>[auth.ts]"]
  node_auth["Session security<br/>[admin-auth.ts]"]
  node_productadmin["Product management<br/>[ProductForm.tsx]"]
  node_productactions["Product actions<br/>[products.ts]"]
  node_categoryadmin["Category manager"]
  node_categoryactions["Category actions<br/>[categories.ts]"]
  node_inventorypage["Inventory page<br/>[page.tsx]"]
  node_inventoryui["Inventory ledger<br/>[InventoryLog.tsx]"]
  node_inventoryactions["Inventory actions<br/>[inventory.ts]"]
end

subgraph group_platform["Shared platform"]
  node_middleware["Locale and session routing<br/>[middleware.ts]"]
  node_queries["Catalogue queries<br/>[queries.ts]"]
  node_publicclient["Public data client<br/>[public.ts]"]
  node_serviceclient["Privileged data client<br/>[service.ts]"]
  node_i18n["Locale routing<br/>[routing.ts]"]
end

node_customer(("Customer"))
node_whatsapp["WhatsApp"]
node_owner(("Shop owner"))
node_database[("Supabase database")]
node_storage[("Image storage")]

node_customer -->|"browses"| node_home
node_customer -->|"browses"| node_shop
node_customer -->|"selects variants"| node_productpage
node_home -->|"loads catalogue"| node_queries
node_shop -->|"loads listings"| node_queries
node_shop -->|"renders"| node_shopui
node_shopui -->|"filters results"| node_customer
node_productpage -->|"loads product"| node_queries
node_productpage -->|"renders"| node_purchase
node_purchase -->|"adds item"| node_cart
node_purchase -->|"builds order"| node_whatsappmsg
node_cart -->|"provides state"| node_cartdrawer
node_cartdrawer -->|"builds checkout"| node_whatsappmsg
node_whatsappmsg -->|"opens prefilled chat"| node_whatsapp
node_whatsapp -->|"delivers order"| node_owner
node_offers -->|"loads sale items"| node_queries
node_customer -->|"views offers"| node_offers
node_customer -->|"requests sign-in"| node_adminlogin
node_adminlogin -->|"renders"| node_loginform
node_loginform -->|"submits credentials"| node_authaction
node_authaction -->|"checks credentials"| node_auth
node_middleware -->|"checks session"| node_auth
node_middleware -->|"routes locales"| node_i18n
node_owner -->|"edits catalogue"| node_productadmin
node_productadmin -->|"submits changes"| node_productactions
node_productactions -->|"requires session"| node_auth
node_productactions -->|"writes products"| node_serviceclient
node_productactions -->|"uploads images"| node_storage
node_owner -->|"manages categories"| node_categoryadmin
node_categoryadmin -->|"submits changes"| node_categoryactions
node_categoryactions -->|"requires session"| node_auth
node_categoryactions -->|"writes categories"| node_serviceclient
node_owner -->|"records stock"| node_inventorypage
node_inventorypage -->|"renders ledger"| node_inventoryui
node_inventorypage -->|"supplies actions"| node_inventoryactions
node_inventoryui -->|"updates ledger"| node_inventoryactions
node_inventoryactions -->|"requires session"| node_auth
node_inventoryactions -->|"writes ledger"| node_serviceclient
node_queries -->|"queries through"| node_publicclient
node_publicclient -->|"reads catalogue"| node_database
node_serviceclient -->|"writes admin data"| node_database
node_customer -->|"chooses language"| node_i18n

click node_home "https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/page.tsx"
click node_shop "https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/shop/page.tsx"
click node_shopui "https://github.com/saadosama10/hattah-store/blob/main/src/components/shop/ShopClient.tsx"
click node_productpage "https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/product/%5Bid%5D/page.tsx"
click node_purchase "https://github.com/saadosama10/hattah-store/blob/main/src/components/product/ProductPurchaseActions.tsx"
click node_cart "https://github.com/saadosama10/hattah-store/blob/main/src/contexts/CartContext.tsx"
click node_cartdrawer "https://github.com/saadosama10/hattah-store/blob/main/src/components/cart/CartDrawer.tsx"
click node_whatsappmsg "https://github.com/saadosama10/hattah-store/blob/main/src/lib/whatsapp.ts"
click node_offers "https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/offers/page.tsx"
click node_adminlogin "https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/admin/login/page.tsx"
click node_loginform "https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/LoginForm.tsx"
click node_authaction "https://github.com/saadosama10/hattah-store/blob/main/src/actions/auth.ts"
click node_auth "https://github.com/saadosama10/hattah-store/blob/main/src/lib/admin-auth.ts"
click node_middleware "https://github.com/saadosama10/hattah-store/blob/main/src/middleware.ts"
click node_productadmin "https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/ProductForm.tsx"
click node_productactions "https://github.com/saadosama10/hattah-store/blob/main/src/actions/products.ts"
click node_categoryadmin "https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/CategoryManager.tsx"
click node_categoryactions "https://github.com/saadosama10/hattah-store/blob/main/src/actions/categories.ts"
click node_inventorypage "https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/admin/(protected)/inventory/page.tsx"
click node_inventoryui "https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/InventoryLog.tsx"
click node_inventoryactions "https://github.com/saadosama10/hattah-store/blob/main/src/actions/inventory.ts"
click node_queries "https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/queries.ts"
click node_publicclient "https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/public.ts"
click node_serviceclient "https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/service.ts"
click node_i18n "https://github.com/saadosama10/hattah-store/blob/main/src/i18n/routing.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_home,node_shop,node_shopui,node_productpage,node_offers toneBlue
class node_purchase,node_cart,node_cartdrawer,node_whatsappmsg,node_database,node_storage toneAmber
class node_adminlogin,node_loginform,node_authaction,node_auth,node_productadmin,node_productactions,node_categoryadmin,node_categoryactions,node_inventorypage,node_inventoryui,node_inventoryactions toneMint
class node_middleware,node_queries,node_publicclient,node_serviceclient,node_i18n toneRose
class node_customer,node_whatsapp,node_owner toneIndigo
```

## Components

### Storefront

- [Home page](https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/page.tsx): `src/app/[locale]/(site)/page.tsx`
- [Shop page](https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/shop/page.tsx): `src/app/[locale]/(site)/shop/page.tsx`
- [Shop filters](https://github.com/saadosama10/hattah-store/blob/main/src/components/shop/ShopClient.tsx): `src/components/shop/ShopClient.tsx`
- [Product page](https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/product/%5Bid%5D/page.tsx): `src/app/[locale]/(site)/product/[id]/page.tsx`
- [Offers page](https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/(site)/offers/page.tsx): `src/app/[locale]/(site)/offers/page.tsx`

### Ordering

- [Purchase actions](https://github.com/saadosama10/hattah-store/blob/main/src/components/product/ProductPurchaseActions.tsx): `src/components/product/ProductPurchaseActions.tsx`
- [Cart state](https://github.com/saadosama10/hattah-store/blob/main/src/contexts/CartContext.tsx): `src/contexts/CartContext.tsx`
- [Cart drawer](https://github.com/saadosama10/hattah-store/blob/main/src/components/cart/CartDrawer.tsx): `src/components/cart/CartDrawer.tsx`
- [Order message](https://github.com/saadosama10/hattah-store/blob/main/src/lib/whatsapp.ts): `src/lib/whatsapp.ts`

### Admin

- [Admin login](https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/admin/login/page.tsx): `src/app/[locale]/admin/login/page.tsx`
- [Login form](https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/LoginForm.tsx): `src/components/admin/LoginForm.tsx`
- [Auth actions](https://github.com/saadosama10/hattah-store/blob/main/src/actions/auth.ts): `src/actions/auth.ts`
- [Session security](https://github.com/saadosama10/hattah-store/blob/main/src/lib/admin-auth.ts): `src/lib/admin-auth.ts`
- [Product management](https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/ProductForm.tsx): `src/components/admin/ProductForm.tsx`
- [Product actions](https://github.com/saadosama10/hattah-store/blob/main/src/actions/products.ts): `src/actions/products.ts`
- [Category manager](https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/CategoryManager.tsx): `src/components/admin/CategoryManager.tsx`
- [Category actions](https://github.com/saadosama10/hattah-store/blob/main/src/actions/categories.ts): `src/actions/categories.ts`
- [Inventory page](https://github.com/saadosama10/hattah-store/blob/main/src/app/%5Blocale%5D/admin/(protected)/inventory/page.tsx): `src/app/[locale]/admin/(protected)/inventory/page.tsx`
- [Inventory ledger](https://github.com/saadosama10/hattah-store/blob/main/src/components/admin/InventoryLog.tsx): `src/components/admin/InventoryLog.tsx`
- [Inventory actions](https://github.com/saadosama10/hattah-store/blob/main/src/actions/inventory.ts): `src/actions/inventory.ts`

### Shared platform

- [Locale and session routing](https://github.com/saadosama10/hattah-store/blob/main/src/middleware.ts): `src/middleware.ts`
- [Catalogue queries](https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/queries.ts): `src/lib/supabase/queries.ts`
- [Public data client](https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/public.ts): `src/lib/supabase/public.ts`
- [Privileged data client](https://github.com/saadosama10/hattah-store/blob/main/src/lib/supabase/service.ts): `src/lib/supabase/service.ts`
- [Locale routing](https://github.com/saadosama10/hattah-store/blob/main/src/i18n/routing.ts): `src/i18n/routing.ts`

### Other components

- **Customer**
- **WhatsApp**
- **Shop owner**
- **Supabase database**
- **Image storage**

## Connections

- Customer → Home page: browses (evidence: `README.md`)
- Customer → Shop page: browses (evidence: `README.md`)
- Customer → Product page: selects variants (evidence: `README.md`)
- Home page → Catalogue queries: loads catalogue (evidence: `src/app/[locale]/(site)/page.tsx`)
- Shop page → Catalogue queries: loads listings (evidence: `src/app/[locale]/(site)/shop/page.tsx`)
- Shop page → Shop filters: renders (evidence: `src/app/[locale]/(site)/shop/page.tsx`)
- Shop filters → Customer: filters results (evidence: `README.md`)
- Product page → Catalogue queries: loads product (evidence: `src/app/[locale]/(site)/product/[id]/page.tsx`)
- Product page → Purchase actions: renders (evidence: `src/app/[locale]/(site)/product/[id]/page.tsx`)
- Purchase actions → Cart state: adds item (evidence: `src/components/product/ProductPurchaseActions.tsx`)
- Purchase actions → Order message: builds order (evidence: `src/components/product/ProductPurchaseActions.tsx`)
- Cart state → Cart drawer: provides state (evidence: `src/components/cart/CartDrawer.tsx`)
- Cart drawer → Order message: builds checkout (evidence: `src/components/cart/CartDrawer.tsx`)
- Order message → WhatsApp: opens prefilled chat (evidence: `README.md`)
- WhatsApp → Shop owner: delivers order (evidence: `README.md`)
- Offers page → Catalogue queries: loads sale items (evidence: `src/app/[locale]/(site)/offers/page.tsx`)
- Customer → Offers page: views offers (evidence: `README.md`)
- Customer → Admin login: requests sign-in (evidence: `README.md`)
- Admin login → Login form: renders (evidence: `src/app/[locale]/admin/login/page.tsx`)
- Login form → Auth actions: submits credentials
- Auth actions → Session security: checks credentials (evidence: `src/actions/auth.ts`)
- Locale and session routing → Session security: checks session (evidence: `README.md`)
- Locale and session routing → Locale routing: routes locales (evidence: `src/middleware.ts`)
- Shop owner → Product management: edits catalogue (evidence: `README.md`)
- Product management → Product actions: submits changes (evidence: `README.md`)
- Product actions → Session security: requires session (evidence: `src/actions/products.ts`)
- Product actions → Privileged data client: writes products (evidence: `README.md`)
- Product actions → Image storage: uploads images (evidence: `README.md`)
- Shop owner → Category manager: manages categories (evidence: `README.md`)
- Category manager → Category actions: submits changes (evidence: `src/components/admin/CategoryManager.tsx`)
- Category actions → Session security: requires session (evidence: `src/actions/categories.ts`)
- Category actions → Privileged data client: writes categories (evidence: `README.md`)
- Shop owner → Inventory page: records stock (evidence: `README.md`)
- Inventory page → Inventory ledger: renders ledger (evidence: `src/app/[locale]/admin/(protected)/inventory/page.tsx`)
- Inventory page → Inventory actions: supplies actions (evidence: `src/app/[locale]/admin/(protected)/inventory/page.tsx`)
- Inventory ledger → Inventory actions: updates ledger (evidence: `src/components/admin/InventoryLog.tsx`)
- Inventory actions → Session security: requires session (evidence: `src/actions/inventory.ts`)
- Inventory actions → Privileged data client: writes ledger (evidence: `README.md`)
- Catalogue queries → Public data client: queries through (evidence: `src/lib/supabase/queries.ts`)
- Public data client → Supabase database: reads catalogue (evidence: `README.md`)
- Privileged data client → Supabase database: writes admin data (evidence: `README.md`)
- Customer → Locale routing: chooses language (evidence: `README.md`)
