# calebj0seph/fabra-prototype architecture

> Architecture diagram of the GitHub repository calebj0seph/fabra-prototype, 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/calebj0seph/fabra-prototype
- Repository: https://github.com/calebj0seph/fabra-prototype

## Overview

Fabra is a 3D product-editor prototype for designing a shirt: a user signs in, opens or creates a design file, edits shirt parts and materials in the 3D editor, and saves assignments to that file. Account registration and login, authenticated file browsing, and the editor’s model, camera, lighting, and material-texture layers are distinct product areas. The graph follows relationships shown in the README, SOURCE INDEX, and excerpts; unsampled subsystem details and uncertain links are omitted.

Main entry points: [`src/editor/editor.tsx`](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/editor.tsx) (Editor entry point), [`src/lib/db/queries.ts`](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/queries.ts) (Account and file queries), [`src/lib/files/actions.ts`](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/files/actions.ts) (File actions), [`src/app/files/page.tsx`](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/page.tsx) (Design file listing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Accounts and auth"]
  node_register["Account registration<br/>[route.ts]"]
  node_login["Login form<br/>[login-form.tsx]"]
  node_authapi["Auth endpoint<br/>[route.ts]"]
  node_middleware["Session middleware<br/>[middleware.ts]"]
  node_authutils["User lookup<br/>[utils.ts]"]
  node_authactions["Login actions<br/>[actions.ts]"]
end

subgraph group_files["Design files"]
  node_dbqueries["Account and file queries<br/>[queries.ts]"]
  node_database[("Application database<br/>[setup.ts]")]
  node_filelistpage["Design file listing<br/>[page.tsx]"]
  node_filelist["File list<br/>[files-list.tsx]"]
  node_filecreate["Create file control"]
  node_fileactions["File actions<br/>[actions.ts]"]
  node_filepage["Design editor page<br/>[page.tsx]"]
  node_filecontrols["File controls<br/>[file-controls.tsx]"]
  node_filedata[("Saved file data<br/>[queries.ts]")]
end

subgraph group_editor["3D editor"]
  node_editor["Editor entry point<br/>[editor.tsx]"]
  node_selection["Part and material selection"]
  node_pickers["Selection pickers"]
  node_partpicker["Part picker<br/>[part-picker.tsx]"]
  node_state["Selection state<br/>[state.ts]"]
  node_camera["Camera controls"]
  node_lighting["Scene lighting<br/>[lighting.tsx]"]
end

subgraph group_rendering["Model and materials"]
  node_modelregistry["Model registry<br/>[models.ts]"]
  node_shirt["Shirt model<br/>[shirt.tsx]"]
  node_modeltypes["Model part definitions<br/>[types.ts]"]
  node_materialtextures["Textured materials"]
  node_materialcatalog["Material catalog<br/>[materials.ts]"]
  node_clonematerial["Material cloning"]
end

node_user(("App user"))

node_user -->|"registers"| node_register
node_register -->|"creates account"| node_dbqueries
node_user -->|"submits credentials"| node_login
node_login -->|"invokes"| node_authactions
node_authactions -->|"authenticates"| node_dbqueries
node_authapi -->|"authenticates"| node_dbqueries
node_middleware -.->|"checks session"| node_authapi
node_middleware -.->|"redirects unauthenticated"| node_user
node_filelistpage -->|"gets current user"| node_authutils
node_filelistpage -->|"loads user files"| node_dbqueries
node_filelistpage -->|"renders"| node_filelist
node_filelistpage -->|"renders"| node_filecreate
node_user -.->|"creates design"| node_filecreate
node_filecreate -->|"invokes"| node_fileactions
node_fileactions -->|"gets current user"| node_authutils
node_fileactions -->|"creates or updates file"| node_dbqueries
node_filepage -->|"checks user"| node_authutils
node_filepage -->|"loads file"| node_dbqueries
node_filepage -->|"renders editor"| node_editor
node_filepage -->|"renders controls"| node_filecontrols
node_filecontrols -->|"updates file"| node_fileactions
node_editor -->|"saves assignments"| node_fileactions
node_fileactions -->|"writes file data"| node_filedata
node_dbqueries -->|"queries"| node_database
node_filelistpage -->|"opens saved design"| node_editor
node_editor -->|"renders"| node_camera
node_editor -->|"renders"| node_lighting
node_editor -->|"renders"| node_selection
node_editor -->|"reads selection state"| node_state
node_editor -->|"selects model"| node_modelregistry
node_modelregistry -->|"registers model"| node_shirt
node_editor -->|"renders model"| node_shirt
node_shirt -->|"applies textures"| node_materialtextures
node_materialtextures -->|"gets texture URLs"| node_materialcatalog
node_materialtextures -->|"clones base material"| node_clonematerial
node_selection -->|"renders"| node_pickers
node_selection -->|"renders"| node_partpicker
node_selection -->|"uses part definitions"| node_modeltypes
node_camera -->|"tracks selected part"| node_state
node_camera -->|"uses camera positions"| node_modeltypes
node_shirt -->|"defines model parts"| node_modeltypes

click node_register "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/api/register_account/route.ts"
click node_login "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/login/login-form.tsx"
click node_authapi "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/api/auth/route.ts"
click node_middleware "https://github.com/calebj0seph/fabra-prototype/blob/main/src/middleware.ts"
click node_authutils "https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/auth/utils.ts"
click node_authactions "https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/auth/actions.ts"
click node_dbqueries "https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/queries.ts"
click node_database "https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/setup.ts"
click node_filelistpage "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/page.tsx"
click node_filelist "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/files-list.tsx"
click node_filecreate "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/create-file-button.tsx"
click node_fileactions "https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/files/actions.ts"
click node_filepage "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/%5BfileId%5D/page.tsx"
click node_filecontrols "https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/%5BfileId%5D/file-controls.tsx"
click node_filedata "https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/queries.ts"
click node_editor "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/editor.tsx"
click node_selection "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/selection-editor.tsx"
click node_pickers "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/material-picker.tsx"
click node_partpicker "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/part-picker.tsx"
click node_state "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/state.ts"
click node_camera "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/camera-controls.tsx"
click node_lighting "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/lighting.tsx"
click node_modelregistry "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/models/models.ts"
click node_shirt "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/models/shirt.tsx"
click node_modeltypes "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/models/types.ts"
click node_materialtextures "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/materials/material-with-textures.tsx"
click node_materialcatalog "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/materials/materials.ts"
click node_clonematerial "https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/materials/use-cloned-material.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_register,node_login,node_authapi,node_middleware,node_authutils,node_authactions,node_user toneBlue
class node_dbqueries,node_database,node_filelistpage,node_filelist,node_filecreate,node_fileactions,node_filepage,node_filecontrols,node_filedata toneAmber
class node_editor,node_selection,node_pickers,node_partpicker,node_state,node_camera,node_lighting toneMint
class node_modelregistry,node_shirt,node_modeltypes,node_materialtextures,node_materialcatalog,node_clonematerial toneRose
```

## Components

### Accounts and auth

- [Account registration](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/api/register_account/route.ts): `src/app/api/register_account/route.ts`
- [Login form](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/login/login-form.tsx): `src/app/login/login-form.tsx`
- [Auth endpoint](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/api/auth/route.ts): `src/app/api/auth/route.ts`
- [Session middleware](https://github.com/calebj0seph/fabra-prototype/blob/main/src/middleware.ts): `src/middleware.ts`
- [User lookup](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/auth/utils.ts): `src/lib/auth/utils.ts`
- [Login actions](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/auth/actions.ts): `src/lib/auth/actions.ts`

### Design files

- [Account and file queries](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/queries.ts): `src/lib/db/queries.ts`
- [Application database](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/setup.ts): `src/lib/db/setup.ts`
- [Design file listing](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/page.tsx): `src/app/files/page.tsx`
- [File list](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/files-list.tsx): `src/app/files/files-list.tsx`
- [Create file control](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/create-file-button.tsx): `src/app/files/create-file-button.tsx`
- [File actions](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/files/actions.ts): `src/lib/files/actions.ts`
- [Design editor page](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/%5BfileId%5D/page.tsx): `src/app/files/[fileId]/page.tsx`
- [File controls](https://github.com/calebj0seph/fabra-prototype/blob/main/src/app/files/%5BfileId%5D/file-controls.tsx): `src/app/files/[fileId]/file-controls.tsx`
- [Saved file data](https://github.com/calebj0seph/fabra-prototype/blob/main/src/lib/db/queries.ts): `src/lib/db/queries.ts`

### 3D editor

- [Editor entry point](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/editor.tsx): `src/editor/editor.tsx`
- [Part and material selection](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/selection-editor.tsx): `src/editor/ui/selection-editor.tsx`
- [Selection pickers](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/material-picker.tsx): `src/editor/ui/material-picker.tsx`
- [Part picker](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/part-picker.tsx): `src/editor/ui/part-picker.tsx`
- [Selection state](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/ui/state.ts): `src/editor/ui/state.ts`
- [Camera controls](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/camera-controls.tsx): `src/editor/camera-controls.tsx`
- [Scene lighting](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/lighting.tsx): `src/editor/lighting.tsx`

### Model and materials

- [Model registry](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/models/models.ts): `src/editor/models/models.ts`
- [Shirt model](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/models/shirt.tsx): `src/editor/models/shirt.tsx`
- [Model part definitions](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/models/types.ts): `src/editor/models/types.ts`
- [Textured materials](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/materials/material-with-textures.tsx): `src/editor/materials/material-with-textures.tsx`
- [Material catalog](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/materials/materials.ts): `src/editor/materials/materials.ts`
- [Material cloning](https://github.com/calebj0seph/fabra-prototype/blob/main/src/editor/materials/use-cloned-material.ts): `src/editor/materials/use-cloned-material.ts`

### Other components

- **App user**

## Connections

- App user → Account registration: registers (evidence: `README.md`)
- Account registration → Account and file queries: creates account (evidence: `src/app/api/register_account/route.ts`)
- App user → Login form: submits credentials (evidence: `src/app/login/login-form.tsx`)
- Login form → Login actions: invokes (evidence: `src/app/login/login-form.tsx`)
- Login actions → Account and file queries: authenticates (evidence: `src/lib/auth/actions.ts`)
- Auth endpoint → Account and file queries: authenticates (evidence: `src/app/api/auth/route.ts`)
- Session middleware → Auth endpoint: checks session
- Session middleware → App user: redirects unauthenticated
- Design file listing → User lookup: gets current user (evidence: `src/app/files/page.tsx`)
- Design file listing → Account and file queries: loads user files (evidence: `src/app/files/page.tsx`)
- Design file listing → File list: renders (evidence: `src/app/files/page.tsx`)
- Design file listing → Create file control: renders (evidence: `src/app/files/page.tsx`)
- App user → Create file control: creates design
- Create file control → File actions: invokes (evidence: `src/app/files/create-file-button.tsx`)
- File actions → User lookup: gets current user (evidence: `src/lib/files/actions.ts`)
- File actions → Account and file queries: creates or updates file (evidence: `src/lib/files/actions.ts`)
- Design editor page → User lookup: checks user (evidence: `src/app/files/[fileId]/page.tsx`)
- Design editor page → Account and file queries: loads file (evidence: `src/app/files/[fileId]/page.tsx`)
- Design editor page → Editor entry point: renders editor (evidence: `src/app/files/[fileId]/page.tsx`)
- Design editor page → File controls: renders controls (evidence: `src/app/files/[fileId]/page.tsx`)
- File controls → File actions: updates file (evidence: `src/app/files/[fileId]/file-controls.tsx`)
- Editor entry point → File actions: saves assignments (evidence: `src/editor/editor.tsx`)
- File actions → Saved file data: writes file data (evidence: `src/lib/files/actions.ts`)
- Account and file queries → Application database: queries (evidence: `src/lib/db/queries.ts`)
- Design file listing → Editor entry point: opens saved design
- Editor entry point → Camera controls: renders (evidence: `src/editor/editor.tsx`)
- Editor entry point → Scene lighting: renders (evidence: `src/editor/editor.tsx`)
- Editor entry point → Part and material selection: renders (evidence: `src/editor/editor.tsx`)
- Editor entry point → Selection state: reads selection state (evidence: `src/editor/editor.tsx`)
- Editor entry point → Model registry: selects model (evidence: `src/editor/editor.tsx`)
- Model registry → Shirt model: registers model (evidence: `src/editor/models/models.ts`)
- Editor entry point → Shirt model: renders model (evidence: `src/editor/editor.tsx`)
- Shirt model → Textured materials: applies textures (evidence: `src/editor/models/shirt.tsx`)
- Textured materials → Material catalog: gets texture URLs (evidence: `src/editor/materials/material-with-textures.tsx`)
- Textured materials → Material cloning: clones base material (evidence: `src/editor/materials/material-with-textures.tsx`)
- Part and material selection → Selection pickers: renders (evidence: `src/editor/ui/selection-editor.tsx`)
- Part and material selection → Part picker: renders (evidence: `src/editor/ui/selection-editor.tsx`)
- Part and material selection → Model part definitions: uses part definitions (evidence: `src/editor/ui/selection-editor.tsx`)
- Camera controls → Selection state: tracks selected part (evidence: `src/editor/camera-controls.tsx`)
- Camera controls → Model part definitions: uses camera positions (evidence: `src/editor/camera-controls.tsx`)
- Shirt model → Model part definitions: defines model parts (evidence: `src/editor/models/shirt.tsx`)
