# valgrow-labs/ceyloncrunch architecture

> Architecture diagram of the GitHub repository valgrow-labs/ceyloncrunch, 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/valgrow-labs/ceyloncrunch
- Repository: https://github.com/valgrow-labs/ceyloncrunch

## Overview

Ceylon Crunch is a storefront and admin system for selling products, managing orders, and configuring the shop. The customer flow runs from the storefront and product selection through a persistent cart and checkout, where the orders API creates the order and can prepare PayHere checkout. Admin capabilities include product and order management, store settings, team administration, and newsletter management. Evidence is limited to the supplied excerpts and source index; unsampled pages and routes are shown only where their role is clear from the file tree.

Main entry points: [`lib/supabase-server.js`](https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/supabase-server.js) (Server client), [`app/(store)/page.jsx`](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/(store)/page.jsx) (Homepage), [`app/api/orders/route.js`](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/route.js) (Orders API), [`components/storefront/ProductDetailClient.jsx`](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/ProductDetailClient.jsx) (Product detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Homepage<br/>[page.jsx]"]
  node_catalog["Shop catalog<br/>[page.jsx]"]
  node_product["Product detail"]
  node_product_card["Product card<br/>[ProductCard.jsx]"]
  node_newsletter["Newsletter form<br/>[NewsletterForm.jsx]"]
  node_stars["Rating display<br/>[Stars.jsx]"]
  node_icons["Store icons<br/>[Icons.jsx]"]
end

subgraph group_commerce["Commerce"]
  node_cart["Cart state<br/>[CartContext.jsx]"]
  node_checkout["Checkout<br/>[CheckoutClient.jsx]"]
  node_orders_api["Orders API<br/>[route.js]"]
  node_order_followup["Order follow-up<br/>[route.js]"]
  node_order_tracking["Order tracking<br/>[route.js]"]
  node_payment_webhook["Payment webhook<br/>[route.js]"]
  node_payhere["PayHere integration<br/>[payhere.js]"]
end

subgraph group_admin["Store administration"]
  node_admin["Admin workspace<br/>[layout.jsx]"]
  node_admin_products["Product management"]
  node_admin_orders["Order management"]
  node_admin_settings["Store settings"]
  node_admin_team["Team management<br/>[TeamClient.jsx]"]
  node_newsletter_api["Newsletter API<br/>[route.js]"]
  node_team_api["Team API<br/>[route.js]"]
  node_status_badge["Status badge<br/>[StatusBadge.jsx]"]
  node_image_uploader["Image uploader<br/>[ImageUploader.jsx]"]
  node_save_button["Save button<br/>[SaveButton.jsx]"]
end

subgraph group_platform["Platform services"]
  node_products_api["Products API<br/>[route.js]"]
  node_settings_api["Settings API<br/>[route.js]"]
  node_settings_reader["Settings reader<br/>[settings.js]"]
  node_supabase_server["Server client<br/>[supabase-server.js]"]
  node_database[("Supabase data store")]
  node_variants["Variant normalization<br/>[variants.js]"]
end

node_customer(("Shopper"))
node_payment_provider(("PayHere"))

node_customer -->|"browses"| node_home
node_home -->|"loads settings"| node_settings_reader
node_home -->|"renders"| node_product_card
node_home -->|"renders"| node_newsletter
node_home -->|"renders"| node_stars
node_product_card -->|"adds items"| node_cart
node_product_card -->|"renders"| node_stars
node_product_card -->|"normalizes variants"| node_variants
node_product -->|"adds items"| node_cart
node_product -->|"normalizes variants"| node_variants
node_product -->|"renders"| node_stars
node_product -->|"renders"| node_icons
node_checkout -->|"reads cart"| node_cart
node_checkout -->|"submits order"| node_orders_api
node_checkout -->|"renders"| node_icons
node_orders_api -->|"creates order"| node_database
node_orders_api -->|"loads payment settings"| node_settings_reader
node_orders_api -->|"builds payment payload"| node_payhere
node_payhere -.->|"prepares checkout"| node_payment_provider
node_payment_webhook -->|"updates orders"| node_database
node_payment_webhook -->|"verifies notification"| node_payhere
node_admin_products -->|"renders"| node_status_badge
node_admin_orders -->|"renders"| node_status_badge
node_admin_team -->|"manages members"| node_team_api
node_admin_team -->|"renders"| node_status_badge
node_team_api -->|"reads and updates"| node_database
node_products_api -->|"reads products"| node_database
node_settings_api -->|"reads and writes"| node_database
node_settings_reader -->|"reads settings"| node_supabase_server
node_orders_api -->|"creates clients"| node_supabase_server
node_team_api -->|"creates clients"| node_supabase_server
node_products_api -->|"creates client"| node_supabase_server
node_settings_api -->|"creates client"| node_supabase_server
node_newsletter_api -->|"creates client"| node_supabase_server
node_admin_settings -.->|"uses"| node_image_uploader
node_admin_settings -.->|"uses"| node_save_button

click node_home "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/(store)/page.jsx"
click node_catalog "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/(store)/shop/page.jsx"
click node_product "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/ProductDetailClient.jsx"
click node_product_card "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/ProductCard.jsx"
click node_newsletter "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/NewsletterForm.jsx"
click node_cart "https://github.com/valgrow-labs/ceyloncrunch/blob/main/contexts/CartContext.jsx"
click node_checkout "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/CheckoutClient.jsx"
click node_orders_api "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/route.js"
click node_order_followup "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/%5Bid%5D/route.js"
click node_order_tracking "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/track/route.js"
click node_payment_webhook "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/webhook/route.js"
click node_payhere "https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/payhere.js"
click node_admin "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/layout.jsx"
click node_admin_products "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/products/AdminProductsClient.jsx"
click node_admin_orders "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/orders/AdminOrdersClient.jsx"
click node_admin_settings "https://github.com/valgrow-labs/ceyloncrunch/tree/main/app/admin/settings"
click node_admin_team "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/team/TeamClient.jsx"
click node_newsletter_api "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/newsletter/route.js"
click node_team_api "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/team/route.js"
click node_products_api "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/products/route.js"
click node_settings_api "https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/settings/route.js"
click node_settings_reader "https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/settings.js"
click node_supabase_server "https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/supabase-server.js"
click node_variants "https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/variants.js"
click node_stars "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/Stars.jsx"
click node_icons "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/Icons.jsx"
click node_status_badge "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/admin/StatusBadge.jsx"
click node_image_uploader "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/admin/ImageUploader.jsx"
click node_save_button "https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/admin/SaveButton.jsx"

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_catalog,node_product,node_product_card,node_newsletter,node_stars,node_icons toneBlue
class node_cart,node_checkout,node_orders_api,node_order_followup,node_order_tracking,node_payment_webhook,node_payhere toneAmber
class node_admin,node_admin_products,node_admin_orders,node_admin_settings,node_admin_team,node_newsletter_api,node_team_api,node_status_badge,node_image_uploader,node_save_button toneMint
class node_products_api,node_settings_api,node_settings_reader,node_supabase_server,node_database,node_variants toneRose
class node_customer,node_payment_provider toneIndigo
```

## Components

### Storefront

- [Homepage](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/(store)/page.jsx): `app/(store)/page.jsx`
- [Shop catalog](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/(store)/shop/page.jsx): `app/(store)/shop/page.jsx`
- [Product detail](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/ProductDetailClient.jsx): `components/storefront/ProductDetailClient.jsx`
- [Product card](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/ProductCard.jsx): `components/storefront/ProductCard.jsx`
- [Newsletter form](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/NewsletterForm.jsx): `components/storefront/NewsletterForm.jsx`
- [Rating display](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/Stars.jsx): `components/storefront/Stars.jsx`
- [Store icons](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/Icons.jsx): `components/storefront/Icons.jsx`

### Commerce

- [Cart state](https://github.com/valgrow-labs/ceyloncrunch/blob/main/contexts/CartContext.jsx): `contexts/CartContext.jsx`
- [Checkout](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/storefront/CheckoutClient.jsx): `components/storefront/CheckoutClient.jsx`
- [Orders API](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/route.js): `app/api/orders/route.js`
- [Order follow-up](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/%5Bid%5D/route.js): `app/api/orders/[id]/route.js`
- [Order tracking](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/track/route.js): `app/api/orders/track/route.js`
- [Payment webhook](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/orders/webhook/route.js): `app/api/orders/webhook/route.js`
- [PayHere integration](https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/payhere.js): `lib/payhere.js`

### Store administration

- [Admin workspace](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/layout.jsx): `app/admin/layout.jsx`
- [Product management](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/products/AdminProductsClient.jsx): `app/admin/products/AdminProductsClient.jsx`
- [Order management](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/orders/AdminOrdersClient.jsx): `app/admin/orders/AdminOrdersClient.jsx`
- [Store settings](https://github.com/valgrow-labs/ceyloncrunch/tree/main/app/admin/settings): `app/admin/settings`
- [Team management](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/admin/team/TeamClient.jsx): `app/admin/team/TeamClient.jsx`
- [Newsletter API](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/newsletter/route.js): `app/api/newsletter/route.js`
- [Team API](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/team/route.js): `app/api/team/route.js`
- [Status badge](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/admin/StatusBadge.jsx): `components/admin/StatusBadge.jsx`
- [Image uploader](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/admin/ImageUploader.jsx): `components/admin/ImageUploader.jsx`
- [Save button](https://github.com/valgrow-labs/ceyloncrunch/blob/main/components/admin/SaveButton.jsx): `components/admin/SaveButton.jsx`

### Platform services

- [Products API](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/products/route.js): `app/api/products/route.js`
- [Settings API](https://github.com/valgrow-labs/ceyloncrunch/blob/main/app/api/settings/route.js): `app/api/settings/route.js`
- [Settings reader](https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/settings.js): `lib/settings.js`
- [Server client](https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/supabase-server.js): `lib/supabase-server.js`
- **Supabase data store**
- [Variant normalization](https://github.com/valgrow-labs/ceyloncrunch/blob/main/lib/variants.js): `lib/variants.js`

### Other components

- **Shopper**
- **PayHere**

## Connections

- Shopper → Homepage: browses
- Homepage → Settings reader: loads settings (evidence: `app/(store)/page.jsx`)
- Homepage → Product card: renders (evidence: `app/(store)/page.jsx`)
- Homepage → Newsletter form: renders (evidence: `app/(store)/page.jsx`)
- Homepage → Rating display: renders (evidence: `app/(store)/page.jsx`)
- Product card → Cart state: adds items (evidence: `components/storefront/ProductCard.jsx`)
- Product card → Rating display: renders (evidence: `components/storefront/ProductCard.jsx`)
- Product card → Variant normalization: normalizes variants (evidence: `components/storefront/ProductCard.jsx`)
- Product detail → Cart state: adds items (evidence: `components/storefront/ProductDetailClient.jsx`)
- Product detail → Variant normalization: normalizes variants (evidence: `components/storefront/ProductDetailClient.jsx`)
- Product detail → Rating display: renders (evidence: `components/storefront/ProductDetailClient.jsx`)
- Product detail → Store icons: renders (evidence: `components/storefront/ProductDetailClient.jsx`)
- Checkout → Cart state: reads cart (evidence: `components/storefront/CheckoutClient.jsx`)
- Checkout → Orders API: submits order (evidence: `components/storefront/CheckoutClient.jsx`)
- Checkout → Store icons: renders (evidence: `components/storefront/CheckoutClient.jsx`)
- Orders API → Supabase data store: creates order (evidence: `app/api/orders/route.js`)
- Orders API → Settings reader: loads payment settings (evidence: `app/api/orders/route.js`)
- Orders API → PayHere integration: builds payment payload (evidence: `app/api/orders/route.js`)
- PayHere integration → PayHere: prepares checkout
- Payment webhook → Supabase data store: updates orders (evidence: `app/api/orders/webhook/route.js`)
- Payment webhook → PayHere integration: verifies notification (evidence: `app/api/orders/webhook/route.js`)
- Product management → Status badge: renders (evidence: `app/admin/products/AdminProductsClient.jsx`)
- Order management → Status badge: renders (evidence: `app/admin/orders/AdminOrdersClient.jsx`)
- Team management → Team API: manages members (evidence: `app/admin/team/TeamClient.jsx`)
- Team management → Status badge: renders (evidence: `app/admin/team/TeamClient.jsx`)
- Team API → Supabase data store: reads and updates (evidence: `app/api/team/route.js`)
- Products API → Supabase data store: reads products (evidence: `app/api/products/route.js`)
- Settings API → Supabase data store: reads and writes (evidence: `app/api/settings/route.js`)
- Settings reader → Server client: reads settings (evidence: `lib/settings.js`)
- Orders API → Server client: creates clients (evidence: `app/api/orders/route.js`)
- Team API → Server client: creates clients (evidence: `app/api/team/route.js`)
- Products API → Server client: creates client (evidence: `app/api/products/route.js`)
- Settings API → Server client: creates client (evidence: `app/api/settings/route.js`)
- Newsletter API → Server client: creates client (evidence: `app/api/newsletter/route.js`)
- Store settings → Image uploader: uses (evidence: `app/admin/settings/homepage/HomepageClient.jsx`)
- Store settings → Save button: uses (evidence: `app/admin/settings/homepage/HomepageClient.jsx`)
