# hpsanjel/global-handkraft architecture

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

- Interactive diagram: https://gitdiagram.com/hpsanjel/global-handkraft
- Repository: https://github.com/hpsanjel/global-handkraft

## Overview

Global Handcrafts AS is a Next.js storefront and back office for handcrafted goods, custom mandap orders, and international fulfillment. The primary buyer journey is browse products, configure a variant or add-on, add items to cart, select shipping and currency, pay, then receive an order and downloadable documents. Admins manage catalog, fulfillment, custom inquiries, pricing, shipping, and reporting. The graph combines sampled imports/calls with README-documented capabilities; unsampled subsystem links are documented rather than inferred from names.

Main entry points: [`app/api/checkout/route.ts`](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/checkout/route.ts) (Checkout orchestration), [`app/admin/page.tsx`](https://github.com/hpsanjel/global-handkraft/blob/main/app/admin/page.tsx) (Admin dashboard), [`lib/prisma.ts`](https://github.com/hpsanjel/global-handkraft/blob/main/lib/prisma.ts) (PostgreSQL), [`app/api/mandap-inquiries/route.ts`](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/mandap-inquiries/route.ts) (Custom inquiry intake)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_store["Storefront"]
  node_storefront["Store pages<br/>[page.tsx]"]
  node_browse["Product browsing<br/>[shop-client.tsx]"]
  node_product["Product detail<br/>[product-client.tsx]"]
  node_catalog["Product catalog"]
  node_cart["Cart<br/>[cart-client.tsx]"]
  node_account["Customer account<br/>[page.tsx]"]
end

subgraph group_commerce["Commerce and fulfillment"]
  node_checkout["Checkout orchestration<br/>[route.ts]"]
  node_pricing["Checkout pricing"]
  node_shipping["Shipping quotes"]
  node_payment["Payment providers<br/>[stripe.ts]"]
  node_vipps["Vipps integration<br/>[vipps.ts]"]
  node_webhook["Payment webhook<br/>[route.ts]"]
  node_orders["Order fulfillment"]
  node_documents["Order documents"]
  node_currency["Currency rates<br/>[exchange-rates.ts]"]
end

subgraph group_custom["Custom orders"]
  node_custom["Custom inquiry intake<br/>[route.ts]"]
  node_threads["Inquiry messaging<br/>[route.ts]"]
  node_realtime["Live inquiry updates"]
end

subgraph group_admin["Administration and platform"]
  node_db[("PostgreSQL<br/>[prisma.ts]")]
  node_admin["Admin dashboard<br/>[page.tsx]"]
  node_admincatalog["Catalog management<br/>[route.ts]"]
  node_reports["Sales reporting"]
  node_reviews["Reviews and testimonials<br/>[reviews.ts]"]
  node_auth["Authentication and roles<br/>[admin-auth.ts]"]
  node_storage["Supabase Storage<br/>[admin.ts]"]
  node_email["Transactional email<br/>[email.ts]"]
end

node_buyer(("Shopper"))
node_stripe{{"Stripe"}}
node_vippssvc{{"Vipps"}}
node_carriers{{"Bring and PostNord"}}
node_resend{{"Resend"}}

node_buyer -->|"visits"| node_storefront
node_storefront -->|"offers browsing"| node_browse
node_browse -->|"loads catalog"| node_catalog
node_browse -->|"opens product"| node_product
node_product -->|"adds items"| node_cart
node_buyer -->|"starts purchase"| node_checkout
node_cart -.->|"submits cart"| node_checkout
node_checkout -->|"prices items"| node_pricing
node_checkout -->|"gets quotes"| node_shipping
node_checkout -->|"loads rates"| node_currency
node_checkout -->|"creates session"| node_payment
node_payment -->|"charges via"| node_stripe
node_checkout -->|"offers payment"| node_vipps
node_vipps -->|"calls API"| node_vippssvc
node_shipping -->|"quotes rates"| node_carriers
node_stripe -->|"sends events"| node_webhook
node_vippssvc -->|"sends events"| node_webhook
node_webhook -->|"fulfills order"| node_orders
node_orders -->|"writes orders"| node_db
node_orders -->|"sends updates"| node_email
node_account -.->|"reads order history"| node_db
node_account -->|"downloads documents"| node_documents
node_buyer -->|"submits inquiry"| node_custom
node_custom -->|"stores inquiry"| node_db
node_custom -->|"uploads images"| node_storage
node_custom -->|"notifies admin"| node_email
node_custom -->|"broadcasts count"| node_realtime
node_buyer -->|"messages admin"| node_threads
node_admin -->|"replies to inquiry"| node_threads
node_admin -->|"checks role"| node_auth
node_admin -->|"manages products"| node_admincatalog
node_admincatalog -->|"writes catalog"| node_db
node_admincatalog -->|"uploads images"| node_storage
node_admin -->|"views sales reports"| node_reports
node_reports -->|"queries sales"| node_db
node_admin -->|"moderates reviews"| node_reviews
node_admin -.->|"manages records"| node_db
node_email -->|"delivers mail"| node_resend

click node_storefront "https://github.com/hpsanjel/global-handkraft/blob/main/app/page.tsx"
click node_browse "https://github.com/hpsanjel/global-handkraft/blob/main/components/shop-client.tsx"
click node_product "https://github.com/hpsanjel/global-handkraft/blob/main/components/product-client.tsx"
click node_catalog "https://github.com/hpsanjel/global-handkraft/blob/main/lib/products-catalog.ts"
click node_cart "https://github.com/hpsanjel/global-handkraft/blob/main/components/cart-client.tsx"
click node_account "https://github.com/hpsanjel/global-handkraft/blob/main/app/account/page.tsx"
click node_checkout "https://github.com/hpsanjel/global-handkraft/blob/main/app/api/checkout/route.ts"
click node_pricing "https://github.com/hpsanjel/global-handkraft/blob/main/lib/checkout-pricing.ts"
click node_shipping "https://github.com/hpsanjel/global-handkraft/blob/main/lib/checkout-shipping.ts"
click node_payment "https://github.com/hpsanjel/global-handkraft/blob/main/lib/stripe.ts"
click node_vipps "https://github.com/hpsanjel/global-handkraft/blob/main/lib/vipps.ts"
click node_webhook "https://github.com/hpsanjel/global-handkraft/blob/main/app/api/checkout/webhook/route.ts"
click node_orders "https://github.com/hpsanjel/global-handkraft/blob/main/lib/order-fulfillment.ts"
click node_documents "https://github.com/hpsanjel/global-handkraft/blob/main/lib/documents/services/document.service.ts"
click node_db "https://github.com/hpsanjel/global-handkraft/blob/main/lib/prisma.ts"
click node_custom "https://github.com/hpsanjel/global-handkraft/blob/main/app/api/mandap-inquiries/route.ts"
click node_threads "https://github.com/hpsanjel/global-handkraft/blob/main/app/api/account/mandap-inquiries/%5Bid%5D/messages/route.ts"
click node_realtime "https://github.com/hpsanjel/global-handkraft/blob/main/lib/realtime-broadcast.ts"
click node_admin "https://github.com/hpsanjel/global-handkraft/blob/main/app/admin/page.tsx"
click node_admincatalog "https://github.com/hpsanjel/global-handkraft/blob/main/app/api/admin/products/route.ts"
click node_reports "https://github.com/hpsanjel/global-handkraft/blob/main/lib/reports/sales-report.service.ts"
click node_reviews "https://github.com/hpsanjel/global-handkraft/blob/main/lib/reviews.ts"
click node_auth "https://github.com/hpsanjel/global-handkraft/blob/main/lib/admin-auth.ts"
click node_storage "https://github.com/hpsanjel/global-handkraft/blob/main/lib/supabase/admin.ts"
click node_email "https://github.com/hpsanjel/global-handkraft/blob/main/lib/email.ts"
click node_currency "https://github.com/hpsanjel/global-handkraft/blob/main/lib/exchange-rates.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_browse,node_product,node_catalog,node_cart,node_account toneBlue
class node_checkout,node_pricing,node_shipping,node_payment,node_vipps,node_webhook,node_orders,node_documents,node_currency toneAmber
class node_custom,node_threads,node_realtime toneMint
class node_db,node_admin,node_admincatalog,node_reports,node_reviews,node_auth,node_storage,node_email toneRose
class node_buyer,node_stripe,node_vippssvc,node_carriers,node_resend toneIndigo
```

## Components

### Storefront

- [Store pages](https://github.com/hpsanjel/global-handkraft/blob/main/app/page.tsx): `app/page.tsx`
- [Product browsing](https://github.com/hpsanjel/global-handkraft/blob/main/components/shop-client.tsx): `components/shop-client.tsx`
- [Product detail](https://github.com/hpsanjel/global-handkraft/blob/main/components/product-client.tsx): `components/product-client.tsx`
- [Product catalog](https://github.com/hpsanjel/global-handkraft/blob/main/lib/products-catalog.ts): `lib/products-catalog.ts`
- [Cart](https://github.com/hpsanjel/global-handkraft/blob/main/components/cart-client.tsx): `components/cart-client.tsx`
- [Customer account](https://github.com/hpsanjel/global-handkraft/blob/main/app/account/page.tsx): `app/account/page.tsx`

### Commerce and fulfillment

- [Checkout orchestration](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/checkout/route.ts): `app/api/checkout/route.ts`
- [Checkout pricing](https://github.com/hpsanjel/global-handkraft/blob/main/lib/checkout-pricing.ts): `lib/checkout-pricing.ts`
- [Shipping quotes](https://github.com/hpsanjel/global-handkraft/blob/main/lib/checkout-shipping.ts): `lib/checkout-shipping.ts`
- [Payment providers](https://github.com/hpsanjel/global-handkraft/blob/main/lib/stripe.ts): `lib/stripe.ts`
- [Vipps integration](https://github.com/hpsanjel/global-handkraft/blob/main/lib/vipps.ts): `lib/vipps.ts`
- [Payment webhook](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/checkout/webhook/route.ts): `app/api/checkout/webhook/route.ts`
- [Order fulfillment](https://github.com/hpsanjel/global-handkraft/blob/main/lib/order-fulfillment.ts): `lib/order-fulfillment.ts`
- [Order documents](https://github.com/hpsanjel/global-handkraft/blob/main/lib/documents/services/document.service.ts): `lib/documents/services/document.service.ts`
- [Currency rates](https://github.com/hpsanjel/global-handkraft/blob/main/lib/exchange-rates.ts): `lib/exchange-rates.ts`

### Custom orders

- [Custom inquiry intake](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/mandap-inquiries/route.ts): `app/api/mandap-inquiries/route.ts`
- [Inquiry messaging](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/account/mandap-inquiries/%5Bid%5D/messages/route.ts): `app/api/account/mandap-inquiries/[id]/messages/route.ts`
- [Live inquiry updates](https://github.com/hpsanjel/global-handkraft/blob/main/lib/realtime-broadcast.ts): `lib/realtime-broadcast.ts`

### Administration and platform

- [PostgreSQL](https://github.com/hpsanjel/global-handkraft/blob/main/lib/prisma.ts): `lib/prisma.ts`
- [Admin dashboard](https://github.com/hpsanjel/global-handkraft/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [Catalog management](https://github.com/hpsanjel/global-handkraft/blob/main/app/api/admin/products/route.ts): `app/api/admin/products/route.ts`
- [Sales reporting](https://github.com/hpsanjel/global-handkraft/blob/main/lib/reports/sales-report.service.ts): `lib/reports/sales-report.service.ts`
- [Reviews and testimonials](https://github.com/hpsanjel/global-handkraft/blob/main/lib/reviews.ts): `lib/reviews.ts`
- [Authentication and roles](https://github.com/hpsanjel/global-handkraft/blob/main/lib/admin-auth.ts): `lib/admin-auth.ts`
- [Supabase Storage](https://github.com/hpsanjel/global-handkraft/blob/main/lib/supabase/admin.ts): `lib/supabase/admin.ts`
- [Transactional email](https://github.com/hpsanjel/global-handkraft/blob/main/lib/email.ts): `lib/email.ts`

### Other components

- **Shopper**
- **Stripe**
- **Vipps**
- **Bring and PostNord**
- **Resend**

## Connections

- Shopper → Store pages: visits
- Store pages → Product browsing: offers browsing
- Product browsing → Product catalog: loads catalog (evidence: `components/shop-client.tsx`)
- Product browsing → Product detail: opens product
- Product detail → Cart: adds items (evidence: `components/product-client.tsx`)
- Shopper → Checkout orchestration: starts purchase
- Cart → Checkout orchestration: submits cart
- Checkout orchestration → Checkout pricing: prices items (evidence: `app/api/checkout/route.ts`)
- Checkout orchestration → Shipping quotes: gets quotes (evidence: `app/api/checkout/route.ts`)
- Checkout orchestration → Currency rates: loads rates (evidence: `app/api/checkout/route.ts`)
- Checkout orchestration → Payment providers: creates session
- Payment providers → Stripe: charges via
- Checkout orchestration → Vipps integration: offers payment
- Vipps integration → Vipps: calls API
- Shipping quotes → Bring and PostNord: quotes rates
- Stripe → Payment webhook: sends events
- Vipps → Payment webhook: sends events
- Payment webhook → Order fulfillment: fulfills order (evidence: `app/api/checkout/webhook/route.ts`)
- Order fulfillment → PostgreSQL: writes orders (evidence: `app/api/checkout/webhook/route.ts`)
- Order fulfillment → Transactional email: sends updates (evidence: `app/api/checkout/webhook/route.ts`)
- Customer account → PostgreSQL: reads order history
- Customer account → Order documents: downloads documents
- Shopper → Custom inquiry intake: submits inquiry
- Custom inquiry intake → PostgreSQL: stores inquiry (evidence: `app/api/mandap-inquiries/route.ts`)
- Custom inquiry intake → Supabase Storage: uploads images (evidence: `app/api/mandap-inquiries/route.ts`)
- Custom inquiry intake → Transactional email: notifies admin (evidence: `app/api/mandap-inquiries/route.ts`)
- Custom inquiry intake → Live inquiry updates: broadcasts count (evidence: `app/api/mandap-inquiries/route.ts`)
- Shopper → Inquiry messaging: messages admin
- Admin dashboard → Inquiry messaging: replies to inquiry
- Admin dashboard → Authentication and roles: checks role
- Admin dashboard → Catalog management: manages products
- Catalog management → PostgreSQL: writes catalog (evidence: `app/api/admin/products/route.ts`)
- Catalog management → Supabase Storage: uploads images (evidence: `app/api/admin/products/route.ts`)
- Admin dashboard → Sales reporting: views sales reports
- Sales reporting → PostgreSQL: queries sales (evidence: `lib/reports/sales-report.service.ts`)
- Admin dashboard → Reviews and testimonials: moderates reviews
- Admin dashboard → PostgreSQL: manages records
- Transactional email → Resend: delivers mail
