# gabrielvioli/moldeon architecture

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

- Interactive diagram: https://gitdiagram.com/gabrielvioli/moldeon
- Repository: https://github.com/gabrielvioli/moldeon

## Overview

Moldeon is a web garment-pattern design workspace. Users create or choose a pattern, adjust body measurements and pattern geometry, configure internal paths and seams, then request a dressed-avatar preview; the editor also supports local autosave and 1:1 SVG export. The graph highlights distinct drafting, editing, assembly, and 3D stages, plus the geometry/engine layer beneath them. Several documented capabilities have dedicated nodes, but their wiring is omitted where the sampled excerpts do not establish it.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/App.tsx) (Workspace app), [`apps/web/src/state/editorStore.ts`](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/state/editorStore.ts) (Editor state), [`apps/web/src/garment3d/SemanticAvatarArrangement.ts`](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/garment3d/SemanticAvatarArrangement.ts) (Semantic 3D arrangement), [`apps/web/src/core/engineRuntime.ts`](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/core/engineRuntime.ts) (Pattern engine runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workspace["Workspace"]
  node_app["Workspace app<br/>[App.tsx]"]
  node_canvas["2D canvas<br/>[PatternCanvas.tsx]"]
  node_context["Context tools<br/>[ContextBar.tsx]"]
end

subgraph group_drafting["Drafting and measurements"]
  node_templates["Template catalog<br/>[templateCatalog.ts]"]
  node_drafting_core["Pattern drafting"]
  node_trouser_drafting["Trouser drafting"]
  node_measurements["Body measurements"]
end

subgraph group_pattern["Pattern editing"]
  node_editor_state["Editor state<br/>[editorStore.ts]"]
  node_path_state["Internal path state"]
  node_pattern_model["Pattern model<br/>[pattern.ts]"]
  node_pattern_ops["Pattern operations"]
  node_sleeves["Sleeve system<br/>[sleeveSystem.ts]"]
end

subgraph group_assembly["Garment assembly"]
  node_assembly_domain["Seam analysis<br/>[assembly.ts]"]
  node_garment_3d["Semantic 3D arrangement"]
  node_avatar["Parametric avatar"]
  node_viewport["3D viewport"]
end

subgraph group_foundation["Geometry and persistence"]
  node_formulas["Formula engine<br/>[formulaEngine.ts]"]
  node_geometry["Polygon geometry<br/>[polygonGeometry.ts]"]
  node_engine_runtime["Pattern engine runtime<br/>[engineRuntime.ts]"]
  node_fallback["TypeScript engine"]
  node_wasm["Rust WASM adapter"]
  node_local_storage[("Local autosave<br/>[opfs.ts]")]
  node_svg["SVG export<br/>[svg.ts]"]
end

node_user(("Designer"))

node_user -->|"uses"| node_app
node_app -->|"initializes"| node_engine_runtime
node_app -->|"loads and saves"| node_local_storage
node_app -->|"reads state"| node_editor_state
node_app -->|"renders"| node_canvas
node_app -->|"renders"| node_context
node_app -.->|"offers templates"| node_templates
node_app -.->|"requests preview"| node_garment_3d
node_app -.->|"exports"| node_svg
node_templates -->|"uses"| node_drafting_core
node_templates -->|"uses"| node_trouser_drafting
node_drafting_core -->|"uses"| node_measurements
node_measurements -->|"evaluates formulas"| node_formulas
node_canvas -->|"edits through"| node_editor_state
node_canvas -->|"samples contours"| node_geometry
node_editor_state -->|"gets engine"| node_engine_runtime
node_editor_state -->|"analyzes seams"| node_assembly_domain
node_editor_state -->|"applies operations"| node_pattern_ops
node_editor_state -->|"updates profile"| node_measurements
node_editor_state -.->|"supports sleeve edits"| node_sleeves
node_path_state -->|"updates state"| node_editor_state
node_path_state -->|"edits paths"| node_pattern_model
node_pattern_ops -->|"uses geometry"| node_geometry
node_fallback -->|"parses patterns"| node_pattern_model
node_fallback -->|"triangulates contours"| node_geometry
node_engine_runtime -->|"defaults to"| node_fallback
node_engine_runtime -->|"loads backend"| node_wasm
node_wasm -->|"selects fallback"| node_fallback
node_garment_3d -->|"resolves anchors"| node_avatar
node_garment_3d -->|"resolves seams"| node_assembly_domain
node_viewport -->|"arranges garment"| node_garment_3d
node_svg -->|"uses geometry"| node_geometry
node_svg -->|"reads pattern"| node_pattern_model

click node_app "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/App.tsx"
click node_canvas "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/editor/PatternCanvas.tsx"
click node_context "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/components/ContextBar.tsx"
click node_templates "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/patterns/templateCatalog.ts"
click node_drafting_core "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/patterns/basePatternDrafting.ts"
click node_trouser_drafting "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/patterns/trouserPatternDrafting.ts"
click node_measurements "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/parametricMeasurements.ts"
click node_formulas "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/formulaEngine.ts"
click node_editor_state "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/state/editorStore.ts"
click node_path_state "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/state/internalPathEditorStore.ts"
click node_pattern_model "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/pattern.ts"
click node_pattern_ops "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/patternOperations.ts"
click node_sleeves "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/sleeveSystem.ts"
click node_assembly_domain "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/assembly.ts"
click node_garment_3d "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/garment3d/SemanticAvatarArrangement.ts"
click node_avatar "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/avatar/AvatarParametricModel.ts"
click node_viewport "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/viewport/GlobalThreeViewport.ts"
click node_geometry "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/polygonGeometry.ts"
click node_engine_runtime "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/core/engineRuntime.ts"
click node_fallback "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/core/fallbackPatternEngine.ts"
click node_wasm "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/wasm/loadPatternEngine.ts"
click node_local_storage "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/storage/opfs.ts"
click node_svg "https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/export/svg.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_app,node_canvas,node_context toneBlue
class node_templates,node_drafting_core,node_trouser_drafting,node_measurements toneAmber
class node_editor_state,node_path_state,node_pattern_model,node_pattern_ops,node_sleeves toneMint
class node_assembly_domain,node_garment_3d,node_avatar,node_viewport toneRose
class node_formulas,node_geometry,node_engine_runtime,node_fallback,node_wasm,node_local_storage,node_svg,node_user toneIndigo
```

## Components

### Workspace

- [Workspace app](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [2D canvas](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/editor/PatternCanvas.tsx): `apps/web/src/editor/PatternCanvas.tsx`
- [Context tools](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/components/ContextBar.tsx): `apps/web/src/components/ContextBar.tsx`

### Drafting and measurements

- [Template catalog](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/patterns/templateCatalog.ts): `apps/web/src/patterns/templateCatalog.ts`
- [Pattern drafting](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/patterns/basePatternDrafting.ts): `apps/web/src/patterns/basePatternDrafting.ts`
- [Trouser drafting](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/patterns/trouserPatternDrafting.ts): `apps/web/src/patterns/trouserPatternDrafting.ts`
- [Body measurements](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/parametricMeasurements.ts): `apps/web/src/domain/parametricMeasurements.ts`

### Pattern editing

- [Editor state](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/state/editorStore.ts): `apps/web/src/state/editorStore.ts`
- [Internal path state](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/state/internalPathEditorStore.ts): `apps/web/src/state/internalPathEditorStore.ts`
- [Pattern model](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/pattern.ts): `apps/web/src/domain/pattern.ts`
- [Pattern operations](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/patternOperations.ts): `apps/web/src/domain/patternOperations.ts`
- [Sleeve system](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/sleeveSystem.ts): `apps/web/src/domain/sleeveSystem.ts`

### Garment assembly

- [Seam analysis](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/assembly.ts): `apps/web/src/domain/assembly.ts`
- [Semantic 3D arrangement](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/garment3d/SemanticAvatarArrangement.ts): `apps/web/src/garment3d/SemanticAvatarArrangement.ts`
- [Parametric avatar](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/avatar/AvatarParametricModel.ts): `apps/web/src/avatar/AvatarParametricModel.ts`
- [3D viewport](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/viewport/GlobalThreeViewport.ts): `apps/web/src/viewport/GlobalThreeViewport.ts`

### Geometry and persistence

- [Formula engine](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/formulaEngine.ts): `apps/web/src/domain/formulaEngine.ts`
- [Polygon geometry](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/domain/polygonGeometry.ts): `apps/web/src/domain/polygonGeometry.ts`
- [Pattern engine runtime](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/core/engineRuntime.ts): `apps/web/src/core/engineRuntime.ts`
- [TypeScript engine](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/core/fallbackPatternEngine.ts): `apps/web/src/core/fallbackPatternEngine.ts`
- [Rust WASM adapter](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/wasm/loadPatternEngine.ts): `apps/web/src/wasm/loadPatternEngine.ts`
- [Local autosave](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/storage/opfs.ts): `apps/web/src/storage/opfs.ts`
- [SVG export](https://github.com/gabrielvioli/moldeon/blob/main/apps/web/src/export/svg.ts): `apps/web/src/export/svg.ts`

### Other components

- **Designer**

## Connections

- Designer → Workspace app: uses (evidence: `apps/web/src/App.tsx`)
- Workspace app → Pattern engine runtime: initializes (evidence: `apps/web/src/App.tsx`)
- Workspace app → Local autosave: loads and saves (evidence: `apps/web/src/App.tsx`)
- Workspace app → Editor state: reads state (evidence: `apps/web/src/App.tsx`)
- Workspace app → 2D canvas: renders (evidence: `apps/web/src/App.tsx`)
- Workspace app → Context tools: renders (evidence: `apps/web/src/App.tsx`)
- Workspace app → Template catalog: offers templates
- Workspace app → Semantic 3D arrangement: requests preview
- Workspace app → SVG export: exports (evidence: `apps/web/src/App.tsx`)
- Template catalog → Pattern drafting: uses (evidence: `apps/web/src/patterns/templateCatalog.ts`)
- Template catalog → Trouser drafting: uses (evidence: `apps/web/src/patterns/templateCatalog.ts`)
- Pattern drafting → Body measurements: uses (evidence: `apps/web/src/patterns/basePatternDrafting.ts`)
- Body measurements → Formula engine: evaluates formulas (evidence: `apps/web/src/domain/parametricMeasurements.ts`)
- 2D canvas → Editor state: edits through (evidence: `apps/web/src/editor/PatternCanvas.tsx`)
- 2D canvas → Polygon geometry: samples contours (evidence: `apps/web/src/editor/PatternCanvas.tsx`)
- Editor state → Pattern engine runtime: gets engine (evidence: `apps/web/src/state/editorStore.ts`)
- Editor state → Seam analysis: analyzes seams (evidence: `apps/web/src/state/editorStore.ts`)
- Editor state → Pattern operations: applies operations (evidence: `apps/web/src/state/editorStore.ts`)
- Editor state → Body measurements: updates profile (evidence: `apps/web/src/state/editorStore.ts`)
- Editor state → Sleeve system: supports sleeve edits (evidence: `apps/web/src/state/editorStore.ts`)
- Internal path state → Editor state: updates state (evidence: `apps/web/src/state/internalPathEditorStore.ts`)
- Internal path state → Pattern model: edits paths (evidence: `apps/web/src/state/internalPathEditorStore.ts`)
- Pattern operations → Polygon geometry: uses geometry (evidence: `apps/web/src/domain/patternOperations.ts`)
- TypeScript engine → Pattern model: parses patterns (evidence: `apps/web/src/core/fallbackPatternEngine.ts`)
- TypeScript engine → Polygon geometry: triangulates contours (evidence: `apps/web/src/core/fallbackPatternEngine.ts`)
- Pattern engine runtime → TypeScript engine: defaults to (evidence: `apps/web/src/core/engineRuntime.ts`)
- Pattern engine runtime → Rust WASM adapter: loads backend (evidence: `apps/web/src/core/engineRuntime.ts`)
- Rust WASM adapter → TypeScript engine: selects fallback (evidence: `apps/web/src/wasm/loadPatternEngine.ts`)
- Semantic 3D arrangement → Parametric avatar: resolves anchors (evidence: `apps/web/src/garment3d/SemanticAvatarArrangement.ts`)
- Semantic 3D arrangement → Seam analysis: resolves seams (evidence: `apps/web/src/garment3d/SemanticAvatarArrangement.ts`)
- 3D viewport → Semantic 3D arrangement: arranges garment (evidence: `apps/web/src/viewport/GlobalThreeViewport.ts`)
- SVG export → Polygon geometry: uses geometry (evidence: `apps/web/src/export/svg.ts`)
- SVG export → Pattern model: reads pattern (evidence: `apps/web/src/export/svg.ts`)
