# benbean303/fabra-demo architecture

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

- Interactive diagram: https://gitdiagram.com/benbean303/fabra-demo
- Repository: https://github.com/benbean303/fabra-demo

## Overview

Fabra Demo is a hoodie-colour customizer with OAuth sign-in and saved designs. The main workflow is to select hoodie meshes, apply fabric colours, and save or reload a design through the account UI and API. The 3D scene is split into rendering, picking, selection feedback, and camera control; shared state and material definitions support editing. The README documents Auth0 and PostgreSQL. The save helper’s endpoint wiring is not shown in the excerpts, so that link is marked unverified.

Main entry points: [`components/3D/Scene.tsx`](https://github.com/benbean303/fabra-demo/blob/main/components/3D/Scene.tsx) (Editor Scene), [`stores/app-store.tsx`](https://github.com/benbean303/fabra-demo/blob/main/stores/app-store.tsx) (Editor State), [`components/UI/Account.tsx`](https://github.com/benbean303/fabra-demo/blob/main/components/UI/Account.tsx) (Account UI), [`static/constants.ts`](https://github.com/benbean303/fabra-demo/blob/main/static/constants.ts) (Material Catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_editor["3D Editor"]
  node_scene["Editor Scene<br/>[Scene.tsx]"]
  node_hoodie["Hoodie Model<br/>[Hoodie.tsx]"]
  node_picker["Mesh Picker<br/>[MeshPicker.tsx]"]
  node_outline["Selection Outline"]
  node_camera["Camera Controller"]
  node_lights["Scene Lights<br/>[Lights.tsx]"]
  node_selector["Material Selector"]
  node_modelasset["Hoodie GLB"]
end

subgraph group_materials["Materials And State"]
  node_store["Editor State<br/>[app-store.tsx]"]
  node_catalog["Material Catalog<br/>[constants.ts]"]
  node_white["White Material<br/>[White.tsx]"]
  node_grey["Grey Material<br/>[Grey.tsx]"]
  node_black["Black Material<br/>[Black.tsx]"]
end

subgraph group_accounts["Accounts And Designs"]
  node_account["Account UI<br/>[Account.tsx]"]
  node_authroute["Auth Routes<br/>[route.ts]"]
  node_savehelper["Design API Client<br/>[api.ts]"]
end

subgraph group_persistence["Persistence"]
  node_save["Save Design API<br/>[route.ts]"]
  node_designs["Fetch Designs API<br/>[route.ts]"]
  node_colour["Random Colour Helper<br/>[colour.ts]"]
  node_prisma["Prisma Client<br/>[prisma.ts]"]
  node_database[("PostgreSQL<br/>[schema.prisma]")]
end

node_user(("User"))
node_auth0["Auth0"]

node_user -->|"customizes"| node_scene
node_scene -->|"renders"| node_hoodie
node_scene -->|"mounts"| node_picker
node_scene -->|"mounts"| node_outline
node_scene -->|"mounts"| node_camera
node_scene -->|"mounts"| node_lights
node_scene -->|"mounts"| node_selector
node_scene -->|"mounts"| node_account
node_hoodie -->|"reads design"| node_store
node_hoodie -->|"uses materials"| node_catalog
node_hoodie -->|"loads model"| node_modelasset
node_picker -->|"updates selection"| node_store
node_outline -->|"reads selection"| node_store
node_camera -->|"reads selection"| node_store
node_selector -->|"sets material"| node_store
node_store -->|"uses defaults"| node_catalog
node_catalog -->|"imports"| node_white
node_catalog -->|"imports"| node_grey
node_catalog -->|"imports"| node_black
node_account -->|"loads design"| node_store
node_account -->|"fetches designs"| node_designs
node_account -->|"saves design"| node_savehelper
node_account -->|"links login"| node_authroute
node_authroute -.->|"OAuth flow"| node_auth0
node_savehelper -.->|"posts design"| node_save
node_save -->|"generates colour"| node_colour
node_save -->|"writes design"| node_prisma
node_designs -->|"reads designs"| node_prisma
node_prisma -->|"stores records"| node_database

click node_scene "https://github.com/benbean303/fabra-demo/blob/main/components/3D/Scene.tsx"
click node_hoodie "https://github.com/benbean303/fabra-demo/blob/main/models/Hoodie.tsx"
click node_picker "https://github.com/benbean303/fabra-demo/blob/main/components/3D/MeshPicker.tsx"
click node_outline "https://github.com/benbean303/fabra-demo/blob/main/components/3D/SelectedOutline.tsx"
click node_camera "https://github.com/benbean303/fabra-demo/blob/main/components/3D/CameraController.tsx"
click node_lights "https://github.com/benbean303/fabra-demo/blob/main/components/3D/Lights.tsx"
click node_selector "https://github.com/benbean303/fabra-demo/blob/main/components/UI/MaterialSelector.tsx"
click node_store "https://github.com/benbean303/fabra-demo/blob/main/stores/app-store.tsx"
click node_catalog "https://github.com/benbean303/fabra-demo/blob/main/static/constants.ts"
click node_white "https://github.com/benbean303/fabra-demo/blob/main/materials/White.tsx"
click node_grey "https://github.com/benbean303/fabra-demo/blob/main/materials/Grey.tsx"
click node_black "https://github.com/benbean303/fabra-demo/blob/main/materials/Black.tsx"
click node_account "https://github.com/benbean303/fabra-demo/blob/main/components/UI/Account.tsx"
click node_authroute "https://github.com/benbean303/fabra-demo/blob/main/app/api/auth/%5Bauth0%5D/route.ts"
click node_savehelper "https://github.com/benbean303/fabra-demo/blob/main/utils/api.ts"
click node_save "https://github.com/benbean303/fabra-demo/blob/main/app/api/save/route.ts"
click node_designs "https://github.com/benbean303/fabra-demo/blob/main/app/api/designs/route.ts"
click node_colour "https://github.com/benbean303/fabra-demo/blob/main/utils/colour.ts"
click node_prisma "https://github.com/benbean303/fabra-demo/blob/main/lib/prisma.ts"
click node_database "https://github.com/benbean303/fabra-demo/blob/main/prisma/schema.prisma"
click node_modelasset "https://github.com/benbean303/fabra-demo/blob/main/public/models/hoodie-single-material-c.glb"

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_scene,node_hoodie,node_picker,node_outline,node_camera,node_lights,node_selector,node_modelasset,node_user toneBlue
class node_store,node_catalog,node_white,node_grey,node_black toneAmber
class node_account,node_authroute,node_savehelper toneMint
class node_save,node_designs,node_colour,node_prisma,node_database toneRose
class node_auth0 toneIndigo
```

## Components

### 3D Editor

- [Editor Scene](https://github.com/benbean303/fabra-demo/blob/main/components/3D/Scene.tsx): `components/3D/Scene.tsx`
- [Hoodie Model](https://github.com/benbean303/fabra-demo/blob/main/models/Hoodie.tsx): `models/Hoodie.tsx`
- [Mesh Picker](https://github.com/benbean303/fabra-demo/blob/main/components/3D/MeshPicker.tsx): `components/3D/MeshPicker.tsx`
- [Selection Outline](https://github.com/benbean303/fabra-demo/blob/main/components/3D/SelectedOutline.tsx): `components/3D/SelectedOutline.tsx`
- [Camera Controller](https://github.com/benbean303/fabra-demo/blob/main/components/3D/CameraController.tsx): `components/3D/CameraController.tsx`
- [Scene Lights](https://github.com/benbean303/fabra-demo/blob/main/components/3D/Lights.tsx): `components/3D/Lights.tsx`
- [Material Selector](https://github.com/benbean303/fabra-demo/blob/main/components/UI/MaterialSelector.tsx): `components/UI/MaterialSelector.tsx`
- [Hoodie GLB](https://github.com/benbean303/fabra-demo/blob/main/public/models/hoodie-single-material-c.glb): `public/models/hoodie-single-material-c.glb`

### Materials And State

- [Editor State](https://github.com/benbean303/fabra-demo/blob/main/stores/app-store.tsx): `stores/app-store.tsx`
- [Material Catalog](https://github.com/benbean303/fabra-demo/blob/main/static/constants.ts): `static/constants.ts`
- [White Material](https://github.com/benbean303/fabra-demo/blob/main/materials/White.tsx): `materials/White.tsx`
- [Grey Material](https://github.com/benbean303/fabra-demo/blob/main/materials/Grey.tsx): `materials/Grey.tsx`
- [Black Material](https://github.com/benbean303/fabra-demo/blob/main/materials/Black.tsx): `materials/Black.tsx`

### Accounts And Designs

- [Account UI](https://github.com/benbean303/fabra-demo/blob/main/components/UI/Account.tsx): `components/UI/Account.tsx`
- [Auth Routes](https://github.com/benbean303/fabra-demo/blob/main/app/api/auth/%5Bauth0%5D/route.ts): `app/api/auth/[auth0]/route.ts`
- [Design API Client](https://github.com/benbean303/fabra-demo/blob/main/utils/api.ts): `utils/api.ts`

### Persistence

- [Save Design API](https://github.com/benbean303/fabra-demo/blob/main/app/api/save/route.ts): `app/api/save/route.ts`
- [Fetch Designs API](https://github.com/benbean303/fabra-demo/blob/main/app/api/designs/route.ts): `app/api/designs/route.ts`
- [Random Colour Helper](https://github.com/benbean303/fabra-demo/blob/main/utils/colour.ts): `utils/colour.ts`
- [Prisma Client](https://github.com/benbean303/fabra-demo/blob/main/lib/prisma.ts): `lib/prisma.ts`
- [PostgreSQL](https://github.com/benbean303/fabra-demo/blob/main/prisma/schema.prisma): `prisma/schema.prisma`

### Other components

- **User**
- **Auth0**

## Connections

- User → Editor Scene: customizes (evidence: `README.md`)
- Editor Scene → Hoodie Model: renders (evidence: `components/3D/Scene.tsx`)
- Editor Scene → Mesh Picker: mounts (evidence: `components/3D/Scene.tsx`)
- Editor Scene → Selection Outline: mounts (evidence: `components/3D/Scene.tsx`)
- Editor Scene → Camera Controller: mounts (evidence: `components/3D/Scene.tsx`)
- Editor Scene → Scene Lights: mounts (evidence: `components/3D/Scene.tsx`)
- Editor Scene → Material Selector: mounts (evidence: `components/3D/Scene.tsx`)
- Editor Scene → Account UI: mounts (evidence: `components/3D/Scene.tsx`)
- Hoodie Model → Editor State: reads design (evidence: `models/Hoodie.tsx`)
- Hoodie Model → Material Catalog: uses materials (evidence: `models/Hoodie.tsx`)
- Hoodie Model → Hoodie GLB: loads model (evidence: `models/Hoodie.tsx`)
- Mesh Picker → Editor State: updates selection (evidence: `components/3D/MeshPicker.tsx`)
- Selection Outline → Editor State: reads selection (evidence: `components/3D/SelectedOutline.tsx`)
- Camera Controller → Editor State: reads selection (evidence: `components/3D/CameraController.tsx`)
- Material Selector → Editor State: sets material (evidence: `components/UI/MaterialSelector.tsx`)
- Editor State → Material Catalog: uses defaults (evidence: `stores/app-store.tsx`)
- Material Catalog → White Material: imports (evidence: `static/constants.ts`)
- Material Catalog → Grey Material: imports (evidence: `static/constants.ts`)
- Material Catalog → Black Material: imports (evidence: `static/constants.ts`)
- Account UI → Editor State: loads design (evidence: `components/UI/Account.tsx`)
- Account UI → Fetch Designs API: fetches designs (evidence: `components/UI/Account.tsx`)
- Account UI → Design API Client: saves design (evidence: `components/UI/Account.tsx`)
- Account UI → Auth Routes: links login (evidence: `components/UI/Account.tsx`)
- Auth Routes → Auth0: OAuth flow (evidence: `README.md`)
- Design API Client → Save Design API: posts design
- Save Design API → Random Colour Helper: generates colour (evidence: `app/api/save/route.ts`)
- Save Design API → Prisma Client: writes design (evidence: `app/api/save/route.ts`)
- Fetch Designs API → Prisma Client: reads designs (evidence: `app/api/designs/route.ts`)
- Prisma Client → PostgreSQL: stores records (evidence: `README.md`)
