# sharpwill24/flair-project architecture

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

- Interactive diagram: https://gitdiagram.com/sharpwill24/flair-project
- Repository: https://github.com/sharpwill24/flair-project

## Overview

This repository is a Shopify-backed storefront for customizable products, with customer-facing browsing, product design and cart operations, plus an administrative area for users and product management. The central customer workflow is browsing products, configuring a product in the interactive preview, then validating and adding the customization to a cart. The graph also preserves the preview-generation and admin/API branches. Source excerpts show several customizer and cart calls; other links are limited to relationships explicitly listed in the source index, so unsampled routes are not connected speculatively.

Main entry points: [`src/components/products/customizer/hooks/useCartOperations.ts`](https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/hooks/useCartOperations.ts) (Cart operations), [`src/components/layout/Header.tsx`](https://github.com/sharpwill24/flair-project/blob/main/src/components/layout/Header.tsx) (Storefront header), [`src/components/products/customizer/PreviewCanvas.tsx`](https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/PreviewCanvas.tsx) (Interactive preview), [`src/lib/shopify/customization-cart.ts`](https://github.com/sharpwill24/flair-project/blob/main/src/lib/shopify/customization-cart.ts) (Shopify customization cart)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home page<br/>[page.tsx]"]
  node_showcase["Product showcase"]
  node_header["Storefront header<br/>[Header.tsx]"]
  node_products["Product pages"]
end

subgraph group_customizer["Product customization"]
  node_product_customizer["Product customizer"]
  node_preview_section["Preview section<br/>[PreviewSection.tsx]"]
  node_preview_canvas["Interactive preview<br/>[PreviewCanvas.tsx]"]
  node_overlay_views["Overlay views"]
  node_design_area["Design area<br/>[DesignArea.tsx]"]
  node_custom_state["Customization state<br/>[customization.ts]"]
  node_cart_operations["Cart operations"]
  node_customization_utils["Customization validation<br/>[utils.ts]"]
end

subgraph group_commerce["Commerce services"]
  node_preview_render["Preview generation<br/>[preview.ts]"]
  node_preview_api["Server preview endpoint<br/>[route.ts]"]
  node_shopify_cart["Shopify customization cart"]
  node_shopify_client["Shopify Storefront client<br/>[client.ts]"]
  node_shopify_store[("Shopify")]
  node_cart_events["Cart count events<br/>[events.ts]"]
  node_orders_api["Orders endpoint<br/>[route.ts]"]
end

subgraph group_admin["Administration"]
  node_auth_routes["Login and logout<br/>[route.ts]"]
  node_user_context["User session context<br/>[UserContext.tsx]"]
  node_admin_pages["Admin pages"]
  node_admin_product_api["Product management APIs"]
end

node_customer(("Shopper"))

node_home -->|"renders"| node_header
node_home -->|"renders"| node_showcase
node_showcase -->|"renders cards"| node_products
node_header -->|"reads session"| node_user_context
node_header -->|"refreshes count"| node_cart_events
node_header -->|"uses cart"| node_shopify_cart
node_product_customizer -->|"renders"| node_preview_section
node_preview_section -->|"renders"| node_preview_canvas
node_preview_canvas -->|"renders overlays"| node_overlay_views
node_preview_canvas -->|"renders design area"| node_design_area
node_cart_operations -->|"validates"| node_customization_utils
node_cart_operations -->|"generates preview"| node_preview_render
node_cart_operations -->|"adds customization"| node_shopify_cart
node_cart_operations -->|"refreshes count"| node_cart_events
node_preview_render -->|"converts coordinates"| node_customization_utils
node_preview_api -->|"converts coordinates"| node_customization_utils
node_shopify_client -.->|"queries products"| node_shopify_store
node_shopify_cart -.->|"manages cart"| node_shopify_store
node_admin_pages -->|"uses session"| node_user_context
node_shopify_client -.->|"fetches catalog"| node_shopify_store

click node_home "https://github.com/sharpwill24/flair-project/blob/main/src/app/page.tsx"
click node_showcase "https://github.com/sharpwill24/flair-project/blob/main/src/components/home/HomeShowcaseSection.tsx"
click node_header "https://github.com/sharpwill24/flair-project/blob/main/src/components/layout/Header.tsx"
click node_products "https://github.com/sharpwill24/flair-project/tree/main/src/app/products"
click node_product_customizer "https://github.com/sharpwill24/flair-project/tree/main/src/components/products/customizer"
click node_preview_section "https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/components/PreviewSection.tsx"
click node_preview_canvas "https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/PreviewCanvas.tsx"
click node_overlay_views "https://github.com/sharpwill24/flair-project/tree/main/src/components/products/customizer/components/overlays"
click node_design_area "https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/components/DesignArea.tsx"
click node_custom_state "https://github.com/sharpwill24/flair-project/blob/main/src/types/customization.ts"
click node_cart_operations "https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/hooks/useCartOperations.ts"
click node_customization_utils "https://github.com/sharpwill24/flair-project/blob/main/src/lib/customization/utils.ts"
click node_preview_render "https://github.com/sharpwill24/flair-project/blob/main/src/lib/customization/preview.ts"
click node_preview_api "https://github.com/sharpwill24/flair-project/blob/main/src/app/api/generate-preview/route.ts"
click node_shopify_cart "https://github.com/sharpwill24/flair-project/blob/main/src/lib/shopify/customization-cart.ts"
click node_shopify_client "https://github.com/sharpwill24/flair-project/blob/main/src/lib/shopify/client.ts"
click node_cart_events "https://github.com/sharpwill24/flair-project/blob/main/src/lib/cart/events.ts"
click node_auth_routes "https://github.com/sharpwill24/flair-project/blob/main/src/app/api/login/route.ts"
click node_user_context "https://github.com/sharpwill24/flair-project/blob/main/src/components/UserContext.tsx"
click node_admin_pages "https://github.com/sharpwill24/flair-project/tree/main/src/app/adminpanel"
click node_admin_product_api "https://github.com/sharpwill24/flair-project/tree/main/src/pages/api"
click node_orders_api "https://github.com/sharpwill24/flair-project/blob/main/src/app/api/orders/route.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_showcase,node_header,node_products toneBlue
class node_product_customizer,node_preview_section,node_preview_canvas,node_overlay_views,node_design_area,node_custom_state,node_cart_operations,node_customization_utils toneAmber
class node_preview_render,node_preview_api,node_shopify_cart,node_shopify_client,node_shopify_store,node_cart_events,node_orders_api toneMint
class node_auth_routes,node_user_context,node_admin_pages,node_admin_product_api toneRose
class node_customer toneIndigo
```

## Components

### Storefront

- [Home page](https://github.com/sharpwill24/flair-project/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Product showcase](https://github.com/sharpwill24/flair-project/blob/main/src/components/home/HomeShowcaseSection.tsx): `src/components/home/HomeShowcaseSection.tsx`
- [Storefront header](https://github.com/sharpwill24/flair-project/blob/main/src/components/layout/Header.tsx): `src/components/layout/Header.tsx`
- [Product pages](https://github.com/sharpwill24/flair-project/tree/main/src/app/products): `src/app/products`

### Product customization

- [Product customizer](https://github.com/sharpwill24/flair-project/tree/main/src/components/products/customizer): `src/components/products/customizer`
- [Preview section](https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/components/PreviewSection.tsx): `src/components/products/customizer/components/PreviewSection.tsx`
- [Interactive preview](https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/PreviewCanvas.tsx): `src/components/products/customizer/PreviewCanvas.tsx`
- [Overlay views](https://github.com/sharpwill24/flair-project/tree/main/src/components/products/customizer/components/overlays): `src/components/products/customizer/components/overlays`
- [Design area](https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/components/DesignArea.tsx): `src/components/products/customizer/components/DesignArea.tsx`
- [Customization state](https://github.com/sharpwill24/flair-project/blob/main/src/types/customization.ts): `src/types/customization.ts`
- [Cart operations](https://github.com/sharpwill24/flair-project/blob/main/src/components/products/customizer/hooks/useCartOperations.ts): `src/components/products/customizer/hooks/useCartOperations.ts`
- [Customization validation](https://github.com/sharpwill24/flair-project/blob/main/src/lib/customization/utils.ts): `src/lib/customization/utils.ts`

### Commerce services

- [Preview generation](https://github.com/sharpwill24/flair-project/blob/main/src/lib/customization/preview.ts): `src/lib/customization/preview.ts`
- [Server preview endpoint](https://github.com/sharpwill24/flair-project/blob/main/src/app/api/generate-preview/route.ts): `src/app/api/generate-preview/route.ts`
- [Shopify customization cart](https://github.com/sharpwill24/flair-project/blob/main/src/lib/shopify/customization-cart.ts): `src/lib/shopify/customization-cart.ts`
- [Shopify Storefront client](https://github.com/sharpwill24/flair-project/blob/main/src/lib/shopify/client.ts): `src/lib/shopify/client.ts`
- **Shopify**
- [Cart count events](https://github.com/sharpwill24/flair-project/blob/main/src/lib/cart/events.ts): `src/lib/cart/events.ts`
- [Orders endpoint](https://github.com/sharpwill24/flair-project/blob/main/src/app/api/orders/route.ts): `src/app/api/orders/route.ts`

### Administration

- [Login and logout](https://github.com/sharpwill24/flair-project/blob/main/src/app/api/login/route.ts): `src/app/api/login/route.ts`
- [User session context](https://github.com/sharpwill24/flair-project/blob/main/src/components/UserContext.tsx): `src/components/UserContext.tsx`
- [Admin pages](https://github.com/sharpwill24/flair-project/tree/main/src/app/adminpanel): `src/app/adminpanel`
- [Product management APIs](https://github.com/sharpwill24/flair-project/tree/main/src/pages/api): `src/pages/api`

### Other components

- **Shopper**

## Connections

- Home page → Storefront header: renders (evidence: `src/app/page.tsx`)
- Home page → Product showcase: renders (evidence: `src/app/page.tsx`)
- Product showcase → Product pages: renders cards (evidence: `src/components/home/HomeShowcaseSection.tsx`)
- Storefront header → User session context: reads session (evidence: `src/components/layout/Header.tsx`)
- Storefront header → Cart count events: refreshes count (evidence: `src/components/layout/Header.tsx`)
- Storefront header → Shopify customization cart: uses cart (evidence: `src/components/layout/Header.tsx`)
- Product customizer → Preview section: renders (evidence: `src/components/products/customizer/components/PreviewSection.tsx`)
- Preview section → Interactive preview: renders (evidence: `src/components/products/customizer/components/PreviewSection.tsx`)
- Interactive preview → Overlay views: renders overlays (evidence: `src/components/products/customizer/PreviewCanvas.tsx`)
- Interactive preview → Design area: renders design area (evidence: `src/components/products/customizer/PreviewCanvas.tsx`)
- Cart operations → Customization validation: validates (evidence: `src/components/products/customizer/hooks/useCartOperations.ts`)
- Cart operations → Preview generation: generates preview (evidence: `src/components/products/customizer/hooks/useCartOperations.ts`)
- Cart operations → Shopify customization cart: adds customization (evidence: `src/components/products/customizer/hooks/useCartOperations.ts`)
- Cart operations → Cart count events: refreshes count (evidence: `src/components/products/customizer/hooks/useCartOperations.ts`)
- Preview generation → Customization validation: converts coordinates (evidence: `src/lib/customization/preview.ts`)
- Server preview endpoint → Customization validation: converts coordinates (evidence: `src/app/api/generate-preview/route.ts`)
- Shopify Storefront client → Shopify: queries products
- Shopify customization cart → Shopify: manages cart
- Admin pages → User session context: uses session (evidence: `src/app/adminpanel/product/[id]/page.tsx`)
- Shopify Storefront client → Shopify: fetches catalog
