# toubkalcad/toubkalcad architecture

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

- Interactive diagram: https://gitdiagram.com/toubkalcad/toubkalcad
- Repository: https://github.com/toubkalcad/toubkalcad

## Overview

ToubkalCAD is a browser-based parametric CAD application. Users create constrained sketches, turn profiles into solid or surface features, and edit the feature history to recompute downstream geometry; they can also assemble parts and exchange STEP/IGES files. The graph follows the documented React UI, interaction hooks, OpenCascade services, feature recomputation, and Zustand state architecture. Several capabilities are documented but their implementation was not sampled, so those subsystems use supported directory paths and unverified links are omitted.

Main entry points: [`src/store/cadStore.ts`](https://github.com/toubkalcad/toubkalcad/blob/main/src/store/cadStore.ts) (CAD scene and history), [`src/hooks/useCADSketchTool.ts`](https://github.com/toubkalcad/toubkalcad/blob/main/src/hooks/useCADSketchTool.ts) (Sketch tools), [`src/services/RecomputeEngine.live.ts`](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/RecomputeEngine.live.ts) (Live recompute host), [`src/services/CADGeometryRegistry.ts`](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/CADGeometryRegistry.ts) (Shape registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["CAD interface"]
  node_app["App bootstrap<br/>[index.tsx]"]
  node_layout["CAD workspace<br/>[CADLayout.tsx]"]
  node_ribbon["Tool ribbon<br/>[Ribbon.tsx]"]
  node_operations["Feature panels<br/>[Op3DPanel.tsx]"]
  node_viewport["3D viewport<br/>[Viewport3D.tsx]"]
end

subgraph group_sketch["Sketching"]
  node_sketchtools["Sketch tools"]
  node_sketchops["Sketch geometry"]
  node_sketchedit["Sketch editing<br/>[SketchEdit2D.ts]"]
  node_solver["Constraint solving"]
  node_regions["Profile regions<br/>[SketchRegions.ts]"]
  node_profile["Profile resolution<br/>[sketchProfile.ts]"]
end

subgraph group_model["Modeling and history"]
  node_occ["Modeling operations"]
  node_featuregraph["Feature dependencies<br/>[FeatureGraph.ts]"]
  node_recompute["Feature recomputation<br/>[RecomputeEngine.ts]"]
  node_live["Live recompute host"]
end

subgraph group_assembly["Assemblies and exchange"]
  node_assemblies["Assembly services"]
  node_assemblyrefs["Assembly references"]
  node_exchange["STEP and IGES exchange"]
end

subgraph group_runtime["Runtime state and geometry"]
  node_store["CAD scene and history<br/>[cadStore.ts]"]
  node_registry[("Shape registry")]
  node_solveradapters["Solver adapters"]
end

node_user(("CAD user"))

node_user -->|"opens app"| node_app
node_app -->|"mounts workspace"| node_layout
node_ribbon -->|"updates state"| node_store
node_ribbon -->|"invokes operations"| node_occ
node_operations -->|"reads and updates"| node_store
node_operations -->|"invokes operations"| node_occ
node_sketchtools -->|"updates sketch state"| node_store
node_sketchtools -->|"creates geometry"| node_sketchops
node_sketchtools -->|"edits geometry"| node_sketchedit
node_solver -->|"uses adapters"| node_solveradapters
node_sketchtools -->|"finds profile regions"| node_regions
node_profile -->|"builds profiles"| node_regions
node_featuregraph -->|"reads feature nodes"| node_store
node_live -->|"builds dependency graph"| node_featuregraph
node_live -->|"runs recomputation"| node_recompute
node_recompute -->|"evaluates graph order"| node_featuregraph
node_live -->|"registers shapes"| node_registry
node_live -->|"reads and writes state"| node_store
node_store -->|"tracks shape lifetime"| node_registry
node_store -->|"uses assembly services"| node_assemblies
node_assemblyrefs -->|"reads component shapes"| node_registry
node_assemblyrefs -->|"reads scene nodes"| node_store
node_store -->|"exports geometry"| node_exchange
node_app -->|"initializes registry"| node_registry
node_layout -.->|"hosts viewport"| node_viewport

click node_app "https://github.com/toubkalcad/toubkalcad/blob/main/src/index.tsx"
click node_layout "https://github.com/toubkalcad/toubkalcad/blob/main/src/components/CADLayout.tsx"
click node_ribbon "https://github.com/toubkalcad/toubkalcad/blob/main/src/components/Ribbon.tsx"
click node_operations "https://github.com/toubkalcad/toubkalcad/blob/main/src/components/Op3DPanel.tsx"
click node_viewport "https://github.com/toubkalcad/toubkalcad/blob/main/src/components/Viewport3D.tsx"
click node_sketchtools "https://github.com/toubkalcad/toubkalcad/blob/main/src/hooks/useCADSketchTool.ts"
click node_sketchops "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/OccSketchService.ts"
click node_sketchedit "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/SketchEdit2D.ts"
click node_solver "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/SketchConstraintSolver.ts"
click node_regions "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/SketchRegions.ts"
click node_profile "https://github.com/toubkalcad/toubkalcad/blob/main/src/utils/sketchProfile.ts"
click node_occ "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/OccExtrusionService.ts"
click node_featuregraph "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/FeatureGraph.ts"
click node_recompute "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/RecomputeEngine.ts"
click node_live "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/RecomputeEngine.live.ts"
click node_assemblies "https://github.com/toubkalcad/toubkalcad/tree/main/src/assembly"
click node_assemblyrefs "https://github.com/toubkalcad/toubkalcad/blob/main/src/assembly/AssemblyReferenceService.ts"
click node_exchange "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/OccExchangeService.ts"
click node_store "https://github.com/toubkalcad/toubkalcad/blob/main/src/store/cadStore.ts"
click node_registry "https://github.com/toubkalcad/toubkalcad/blob/main/src/services/CADGeometryRegistry.ts"
click node_solveradapters "https://github.com/toubkalcad/toubkalcad/tree/main/src/services/solver"

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_layout,node_ribbon,node_operations,node_viewport,node_user toneBlue
class node_sketchtools,node_sketchops,node_sketchedit,node_solver,node_regions,node_profile toneAmber
class node_occ,node_featuregraph,node_recompute,node_live toneMint
class node_assemblies,node_assemblyrefs,node_exchange toneRose
class node_store,node_registry,node_solveradapters toneIndigo
```

## Components

### CAD interface

- [App bootstrap](https://github.com/toubkalcad/toubkalcad/blob/main/src/index.tsx): `src/index.tsx`
- [CAD workspace](https://github.com/toubkalcad/toubkalcad/blob/main/src/components/CADLayout.tsx): `src/components/CADLayout.tsx`
- [Tool ribbon](https://github.com/toubkalcad/toubkalcad/blob/main/src/components/Ribbon.tsx): `src/components/Ribbon.tsx`
- [Feature panels](https://github.com/toubkalcad/toubkalcad/blob/main/src/components/Op3DPanel.tsx): `src/components/Op3DPanel.tsx`
- [3D viewport](https://github.com/toubkalcad/toubkalcad/blob/main/src/components/Viewport3D.tsx): `src/components/Viewport3D.tsx`

### Sketching

- [Sketch tools](https://github.com/toubkalcad/toubkalcad/blob/main/src/hooks/useCADSketchTool.ts): `src/hooks/useCADSketchTool.ts`
- [Sketch geometry](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/OccSketchService.ts): `src/services/OccSketchService.ts`
- [Sketch editing](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/SketchEdit2D.ts): `src/services/SketchEdit2D.ts`
- [Constraint solving](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/SketchConstraintSolver.ts): `src/services/SketchConstraintSolver.ts`
- [Profile regions](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/SketchRegions.ts): `src/services/SketchRegions.ts`
- [Profile resolution](https://github.com/toubkalcad/toubkalcad/blob/main/src/utils/sketchProfile.ts): `src/utils/sketchProfile.ts`

### Modeling and history

- [Modeling operations](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/OccExtrusionService.ts): `src/services/OccExtrusionService.ts`
- [Feature dependencies](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/FeatureGraph.ts): `src/services/FeatureGraph.ts`
- [Feature recomputation](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/RecomputeEngine.ts): `src/services/RecomputeEngine.ts`
- [Live recompute host](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/RecomputeEngine.live.ts): `src/services/RecomputeEngine.live.ts`

### Assemblies and exchange

- [Assembly services](https://github.com/toubkalcad/toubkalcad/tree/main/src/assembly): `src/assembly`
- [Assembly references](https://github.com/toubkalcad/toubkalcad/blob/main/src/assembly/AssemblyReferenceService.ts): `src/assembly/AssemblyReferenceService.ts`
- [STEP and IGES exchange](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/OccExchangeService.ts): `src/services/OccExchangeService.ts`

### Runtime state and geometry

- [CAD scene and history](https://github.com/toubkalcad/toubkalcad/blob/main/src/store/cadStore.ts): `src/store/cadStore.ts`
- [Shape registry](https://github.com/toubkalcad/toubkalcad/blob/main/src/services/CADGeometryRegistry.ts): `src/services/CADGeometryRegistry.ts`
- [Solver adapters](https://github.com/toubkalcad/toubkalcad/tree/main/src/services/solver): `src/services/solver`

### Other components

- **CAD user**

## Connections

- CAD user → App bootstrap: opens app (evidence: `README.md`)
- App bootstrap → CAD workspace: mounts workspace (evidence: `src/index.tsx`)
- Tool ribbon → CAD scene and history: updates state (evidence: `src/components/Ribbon.tsx`)
- Tool ribbon → Modeling operations: invokes operations (evidence: `src/components/Ribbon.tsx`)
- Feature panels → CAD scene and history: reads and updates (evidence: `src/components/Op3DPanel.tsx`)
- Feature panels → Modeling operations: invokes operations (evidence: `src/components/Op3DPanel.tsx`)
- Sketch tools → CAD scene and history: updates sketch state (evidence: `src/hooks/useCADSketchTool.ts`)
- Sketch tools → Sketch geometry: creates geometry (evidence: `src/hooks/useCADSketchTool.ts`)
- Sketch tools → Sketch editing: edits geometry
- Constraint solving → Solver adapters: uses adapters (evidence: `src/services/SketchDragController.ts`)
- Sketch tools → Profile regions: finds profile regions
- Profile resolution → Profile regions: builds profiles (evidence: `src/utils/sketchProfile.ts`)
- Feature dependencies → CAD scene and history: reads feature nodes (evidence: `src/services/FeatureGraph.ts`)
- Live recompute host → Feature dependencies: builds dependency graph (evidence: `src/services/RecomputeEngine.live.ts`)
- Live recompute host → Feature recomputation: runs recomputation (evidence: `src/services/RecomputeEngine.live.ts`)
- Feature recomputation → Feature dependencies: evaluates graph order (evidence: `src/services/RecomputeEngine.ts`)
- Live recompute host → Shape registry: registers shapes (evidence: `src/services/RecomputeEngine.live.ts`)
- Live recompute host → CAD scene and history: reads and writes state (evidence: `src/services/RecomputeEngine.live.ts`)
- CAD scene and history → Shape registry: tracks shape lifetime (evidence: `src/services/CADGeometryRegistry.ts`)
- CAD scene and history → Assembly services: uses assembly services (evidence: `src/store/cadStore.ts`)
- Assembly references → Shape registry: reads component shapes (evidence: `src/assembly/AssemblyReferenceService.ts`)
- Assembly references → CAD scene and history: reads scene nodes (evidence: `src/assembly/AssemblyReferenceService.ts`)
- CAD scene and history → STEP and IGES exchange: exports geometry (evidence: `src/store/cadStore.ts`)
- App bootstrap → Shape registry: initializes registry (evidence: `src/index.tsx`)
- CAD workspace → 3D viewport: hosts viewport
