# faraaz777/regal-horeca architecture

> Architecture diagram of the GitHub repository faraaz777/regal-horeca, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/faraaz777/regal-horeca
- Repository: https://github.com/faraaz777/regal-horeca

## Overview

Regal HoReCa Catalog is a Next.js storefront and operations application for browsing HoReCa products and managing catalog data. A shopper searches and filters the catalog, opens a product detail, and can save favorites or send an enquiry; administrators authenticate and maintain products and taxonomy. The repository also includes substantial inventory-location and sales-request workflows. The graph preserves these documented and tree-visible subsystems, but many links among their unsampled routes and services cannot be verified from the excerpts, so those connections are omitted or marked unverified.

Main entry points: [`app/(main)`](https://github.com/faraaz777/regal-horeca/tree/main/app/(main)) (Storefront Pages), [`app/admin/products/page.js`](https://github.com/faraaz777/regal-horeca/blob/main/app/admin/products/page.js) (Product Admin), [`app/api/products/route.js`](https://github.com/faraaz777/regal-horeca/blob/main/app/api/products/route.js) (Product API), [`lib/server/products/queryProducts.js`](https://github.com/faraaz777/regal-horeca/blob/main/lib/server/products/queryProducts.js) (Catalog Queries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_storefront["Storefront Pages"]
  node_catalog_ui["Catalog Browser"]
  node_product_card["Product Card<br/>[ProductCard.jsx]"]
  node_product_detail["Product Detail"]
  node_customer_enquiry["Customer Enquiries<br/>[route.js]"]
end

subgraph group_catalog["Catalog Management"]
  node_product_api["Product API<br/>[route.js]"]
  node_product_query["Catalog Queries<br/>[queryProducts.js]"]
  node_product_model[("Product Records<br/>[Product.js]")]
  node_taxonomy_api["Taxonomy API<br/>[route.js]"]
  node_category_model[("Category Tree<br/>[Category.js]")]
  node_product_admin["Product Admin<br/>[page.js]"]
end

subgraph group_operations["Inventory Operations"]
  node_inventory_admin["Inventory Management"]
  node_inventory_api["Inventory APIs"]
  node_inventory_services["Inventory Services"]
end

subgraph group_sales["Sales Workflow"]
  node_sales_workspace["Sales Workspace<br/>[SalesWorkspace.jsx]"]
  node_sales_api["Sales APIs"]
  node_sales_sessions["Sales Sessions<br/>[sessionService.js]"]
  node_sales_records[("Sales Records<br/>[SalesBucket.js]")]
end

subgraph group_platform["Shared Platform"]
  node_admin_auth["Admin Authentication<br/>[requireAuth.js]"]
  node_database_connection[("MongoDB Connection<br/>[connect.js]")]
  node_app_state["Shared App State<br/>[AppContext.jsx]"]
  node_cloud_storage[("Cloudflare R2")]
end

node_shopper(("Shopper"))
node_admin(("Administrator"))

node_shopper -->|"browses"| node_storefront
node_storefront -.->|"offers catalog"| node_catalog_ui
node_catalog_ui -->|"renders"| node_product_card
node_product_card -->|"uses context"| node_app_state
node_storefront -.->|"opens product"| node_product_detail
node_shopper -->|"submits enquiry"| node_customer_enquiry
node_product_api -->|"queries products"| node_product_query
node_product_api -->|"creates records"| node_product_model
node_product_query -->|"searches"| node_product_model
node_taxonomy_api -->|"reads categories"| node_category_model
node_product_admin -.->|"manages products"| node_product_api
node_admin -->|"authenticates"| node_admin_auth
node_admin -->|"maintains catalog"| node_product_admin
node_inventory_admin -.->|"requests operations"| node_inventory_api
node_inventory_api -.->|"delegates"| node_inventory_services
node_sales_workspace -.->|"uses endpoints"| node_sales_api
node_sales_api -.->|"handles sessions"| node_sales_sessions
node_sales_sessions -->|"reads and writes"| node_sales_records
node_database_connection -->|"connects database"| node_product_query
node_database_connection -->|"connects database"| node_admin_auth
node_admin -.->|"manages stock"| node_inventory_admin
node_admin -.->|"manages sales"| node_sales_workspace
node_product_admin -.->|"uploads images"| node_cloud_storage

click node_storefront "https://github.com/faraaz777/regal-horeca/tree/main/app/(main)"
click node_catalog_ui "https://github.com/faraaz777/regal-horeca/blob/main/components/catalog/CatalogPageClient.jsx"
click node_product_card "https://github.com/faraaz777/regal-horeca/blob/main/components/ProductCard.jsx"
click node_product_detail "https://github.com/faraaz777/regal-horeca/blob/main/components/product-detail/ProductDetailClient.jsx"
click node_customer_enquiry "https://github.com/faraaz777/regal-horeca/blob/main/app/api/enquiries/route.js"
click node_product_api "https://github.com/faraaz777/regal-horeca/blob/main/app/api/products/route.js"
click node_product_query "https://github.com/faraaz777/regal-horeca/blob/main/lib/server/products/queryProducts.js"
click node_product_model "https://github.com/faraaz777/regal-horeca/blob/main/lib/models/Product.js"
click node_taxonomy_api "https://github.com/faraaz777/regal-horeca/blob/main/app/api/categories/route.js"
click node_category_model "https://github.com/faraaz777/regal-horeca/blob/main/lib/models/Category.js"
click node_product_admin "https://github.com/faraaz777/regal-horeca/blob/main/app/admin/products/page.js"
click node_admin_auth "https://github.com/faraaz777/regal-horeca/blob/main/lib/server/auth/requireAuth.js"
click node_inventory_admin "https://github.com/faraaz777/regal-horeca/tree/main/app/admin/inventory"
click node_inventory_api "https://github.com/faraaz777/regal-horeca/tree/main/app/api/admin/inventory"
click node_inventory_services "https://github.com/faraaz777/regal-horeca/tree/main/lib/server/inventory"
click node_sales_workspace "https://github.com/faraaz777/regal-horeca/blob/main/components/sales/SalesWorkspace.jsx"
click node_sales_api "https://github.com/faraaz777/regal-horeca/tree/main/app/api/sales"
click node_sales_sessions "https://github.com/faraaz777/regal-horeca/blob/main/lib/server/sales/sessionService.js"
click node_sales_records "https://github.com/faraaz777/regal-horeca/blob/main/lib/models/SalesBucket.js"
click node_database_connection "https://github.com/faraaz777/regal-horeca/blob/main/lib/db/connect.js"
click node_app_state "https://github.com/faraaz777/regal-horeca/blob/main/context/AppContext.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_storefront,node_catalog_ui,node_product_card,node_product_detail,node_customer_enquiry toneBlue
class node_product_api,node_product_query,node_product_model,node_taxonomy_api,node_category_model,node_product_admin toneAmber
class node_inventory_admin,node_inventory_api,node_inventory_services toneMint
class node_sales_workspace,node_sales_api,node_sales_sessions,node_sales_records toneRose
class node_admin_auth,node_database_connection,node_app_state,node_cloud_storage,node_shopper,node_admin toneIndigo
```

## Components

### Storefront

- [Storefront Pages](https://github.com/faraaz777/regal-horeca/tree/main/app/(main)): `app/(main)`
- [Catalog Browser](https://github.com/faraaz777/regal-horeca/blob/main/components/catalog/CatalogPageClient.jsx): `components/catalog/CatalogPageClient.jsx`
- [Product Card](https://github.com/faraaz777/regal-horeca/blob/main/components/ProductCard.jsx): `components/ProductCard.jsx`
- [Product Detail](https://github.com/faraaz777/regal-horeca/blob/main/components/product-detail/ProductDetailClient.jsx): `components/product-detail/ProductDetailClient.jsx`
- [Customer Enquiries](https://github.com/faraaz777/regal-horeca/blob/main/app/api/enquiries/route.js): `app/api/enquiries/route.js`

### Catalog Management

- [Product API](https://github.com/faraaz777/regal-horeca/blob/main/app/api/products/route.js): `app/api/products/route.js`
- [Catalog Queries](https://github.com/faraaz777/regal-horeca/blob/main/lib/server/products/queryProducts.js): `lib/server/products/queryProducts.js`
- [Product Records](https://github.com/faraaz777/regal-horeca/blob/main/lib/models/Product.js): `lib/models/Product.js`
- [Taxonomy API](https://github.com/faraaz777/regal-horeca/blob/main/app/api/categories/route.js): `app/api/categories/route.js`
- [Category Tree](https://github.com/faraaz777/regal-horeca/blob/main/lib/models/Category.js): `lib/models/Category.js`
- [Product Admin](https://github.com/faraaz777/regal-horeca/blob/main/app/admin/products/page.js): `app/admin/products/page.js`

### Inventory Operations

- [Inventory Management](https://github.com/faraaz777/regal-horeca/tree/main/app/admin/inventory): `app/admin/inventory`
- [Inventory APIs](https://github.com/faraaz777/regal-horeca/tree/main/app/api/admin/inventory): `app/api/admin/inventory`
- [Inventory Services](https://github.com/faraaz777/regal-horeca/tree/main/lib/server/inventory): `lib/server/inventory`

### Sales Workflow

- [Sales Workspace](https://github.com/faraaz777/regal-horeca/blob/main/components/sales/SalesWorkspace.jsx): `components/sales/SalesWorkspace.jsx`
- [Sales APIs](https://github.com/faraaz777/regal-horeca/tree/main/app/api/sales): `app/api/sales`
- [Sales Sessions](https://github.com/faraaz777/regal-horeca/blob/main/lib/server/sales/sessionService.js): `lib/server/sales/sessionService.js`
- [Sales Records](https://github.com/faraaz777/regal-horeca/blob/main/lib/models/SalesBucket.js): `lib/models/SalesBucket.js`

### Shared Platform

- [Admin Authentication](https://github.com/faraaz777/regal-horeca/blob/main/lib/server/auth/requireAuth.js): `lib/server/auth/requireAuth.js`
- [MongoDB Connection](https://github.com/faraaz777/regal-horeca/blob/main/lib/db/connect.js): `lib/db/connect.js`
- [Shared App State](https://github.com/faraaz777/regal-horeca/blob/main/context/AppContext.jsx): `context/AppContext.jsx`
- **Cloudflare R2**

### Other components

- **Shopper**
- **Administrator**

## Connections

- Shopper → Storefront Pages: browses (evidence: `README.md`)
- Storefront Pages → Catalog Browser: offers catalog
- Catalog Browser → Product Card: renders (evidence: `components/catalog/CatalogPageClient.jsx`)
- Product Card → Shared App State: uses context (evidence: `components/ProductCard.jsx`)
- Storefront Pages → Product Detail: opens product
- Shopper → Customer Enquiries: submits enquiry (evidence: `app/api/enquiries/route.js`)
- Product API → Catalog Queries: queries products (evidence: `app/api/products/route.js`)
- Product API → Product Records: creates records (evidence: `app/api/products/route.js`)
- Catalog Queries → Product Records: searches (evidence: `lib/server/products/queryProducts.js`)
- Taxonomy API → Category Tree: reads categories (evidence: `app/api/categories/route.js`)
- Product Admin → Product API: manages products
- Administrator → Admin Authentication: authenticates (evidence: `README.md`)
- Administrator → Product Admin: maintains catalog (evidence: `README.md`)
- Inventory Management → Inventory APIs: requests operations
- Inventory APIs → Inventory Services: delegates
- Sales Workspace → Sales APIs: uses endpoints
- Sales APIs → Sales Sessions: handles sessions
- Sales Sessions → Sales Records: reads and writes (evidence: `lib/server/sales/sessionService.js`)
- MongoDB Connection → Catalog Queries: connects database (evidence: `lib/server/products/queryProducts.js`)
- MongoDB Connection → Admin Authentication: connects database (evidence: `lib/server/auth/requireAuth.js`)
- Administrator → Inventory Management: manages stock
- Administrator → Sales Workspace: manages sales
- Product Admin → Cloudflare R2: uploads images
