# david-feldt/breptile architecture

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

- Interactive diagram: https://gitdiagram.com/david-feldt/breptile
- Repository: https://github.com/david-feldt/breptile

## Overview

breptile turns mesh files or dimensioned drawings into editable STEP BREP models, with verification and visualization as companion workflows. Mesh conversion is exposed through the main CLI; drawing conversion has a staged CLI and pipeline, including a deliberate review handoff for raster inputs. The graph includes the documented mesh reconstruction stages and drawing capabilities, but sampled source excerpts are partial, so some internal mesh-stage wiring is omitted rather than inferred.

Main entry points: [`breptile/drawing/pipeline.py`](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/pipeline.py) (Drawing Orchestration), [`breptile/pipeline.py`](https://github.com/david-feldt/breptile/blob/master/breptile/pipeline.py) (Mesh Pipeline), [`breptile/drawing/verify.py`](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/verify.py) (Drawing Verification), [`breptile/drawing/ir.py`](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/ir.py) (Drawing IR)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mesh["Mesh Conversion"]
  node_mesh_pipeline["Mesh Pipeline<br/>[pipeline.py]"]
  node_mesh_input["Mesh Loading<br/>[mesh.py]"]
  node_segmentation["Region Fitting<br/>[segment.py]"]
  node_brep["BREP Geometry<br/>[brep.py]"]
  node_step_export["STEP Export<br/>[export.py]"]
end

subgraph group_drawing["Drawing to CAD"]
  node_drawing_pipeline["Drawing Orchestration<br/>[pipeline.py]"]
  node_extract["Drawing Extraction<br/>[extract.py]"]
  node_drawing_ir["Drawing IR<br/>[ir.py]"]
  node_reconstruct["Recipe Reconstruction<br/>[reconstruct.py]"]
  node_recipe["Parametric Recipe<br/>[recipe.py]"]
  node_execute["Recipe Execution<br/>[execute.py]"]
  node_drawing_verify["Drawing Verification<br/>[verify.py]"]
  node_oracle["Projection and Measures<br/>[oracle.py]"]
  node_synth["IR Synthesis<br/>[synth.py]"]
end

subgraph group_inspection["Verification and Viewing"]
  node_mesh_verify["Mesh Verification<br/>[verify.py]"]
  node_visualize["Static Visualization<br/>[visualize.py]"]
  node_browser["Browser CAD Viewer<br/>[browser_view.py]"]
end

subgraph group_interfaces["User Interfaces"]
  node_cli["Main CLI<br/>[cli.py]"]
  node_draw_cli["Drawing CLI<br/>[cli.py]"]
end

node_user(("Engineer"))
node_step_file["STEP Model"]
node_mesh_file["Mesh File"]
node_drawing_file["Drawing File"]
node_agent(("Human or Agent Review"))

node_user -->|"runs command"| node_cli
node_cli -->|"converts mesh"| node_mesh_pipeline
node_mesh_pipeline -->|"loads mesh"| node_mesh_input
node_mesh_pipeline -->|"fits regions"| node_segmentation
node_mesh_pipeline -->|"builds geometry"| node_brep
node_mesh_pipeline -->|"writes STEP"| node_step_export
node_mesh_pipeline -.->|"optionally verifies"| node_mesh_verify
node_mesh_input -->|"reads"| node_mesh_file
node_step_export -->|"writes"| node_step_file
node_user -->|"runs draw command"| node_draw_cli
node_draw_cli -->|"dispatches stages"| node_drawing_pipeline
node_drawing_pipeline -->|"extracts drawing"| node_extract
node_drawing_pipeline -->|"loads or saves"| node_drawing_ir
node_extract -->|"reads"| node_drawing_file
node_extract -->|"produces IR"| node_drawing_ir
node_drawing_pipeline -->|"reconstructs recipe"| node_reconstruct
node_reconstruct -->|"reads"| node_drawing_ir
node_reconstruct -->|"produces recipe"| node_recipe
node_drawing_pipeline -->|"builds model"| node_execute
node_execute -->|"executes operations"| node_recipe
node_drawing_pipeline -->|"writes STEP"| node_step_file
node_drawing_pipeline -->|"verifies result"| node_drawing_verify
node_drawing_verify -->|"projects and measures"| node_oracle
node_drawing_verify -->|"reads model"| node_step_file
node_drawing_verify -->|"compares evidence"| node_drawing_ir
node_drawing_verify -->|"checks dimensions"| node_recipe
node_drawing_pipeline -.->|"requests raster review"| node_agent
node_user -->|"requests synthesis"| node_synth
node_synth -->|"builds source model"| node_execute
node_synth -->|"projects views"| node_oracle
node_synth -->|"generates IR"| node_drawing_ir
node_user -->|"requests preview"| node_visualize
node_user -->|"opens viewer"| node_browser
node_visualize -->|"loads mesh"| node_mesh_file
node_visualize -->|"loads STEP"| node_step_file
node_browser -->|"serves model view"| node_step_file

click node_cli "https://github.com/david-feldt/breptile/blob/master/breptile/cli.py"
click node_draw_cli "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/cli.py"
click node_mesh_pipeline "https://github.com/david-feldt/breptile/blob/master/breptile/pipeline.py"
click node_mesh_input "https://github.com/david-feldt/breptile/blob/master/breptile/mesh.py"
click node_segmentation "https://github.com/david-feldt/breptile/blob/master/breptile/segment.py"
click node_brep "https://github.com/david-feldt/breptile/blob/master/breptile/brep.py"
click node_step_export "https://github.com/david-feldt/breptile/blob/master/breptile/export.py"
click node_mesh_verify "https://github.com/david-feldt/breptile/blob/master/breptile/verify.py"
click node_drawing_pipeline "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/pipeline.py"
click node_extract "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/extract.py"
click node_drawing_ir "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/ir.py"
click node_reconstruct "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/reconstruct.py"
click node_recipe "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/recipe.py"
click node_execute "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/execute.py"
click node_drawing_verify "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/verify.py"
click node_oracle "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/oracle.py"
click node_synth "https://github.com/david-feldt/breptile/blob/master/breptile/drawing/synth.py"
click node_visualize "https://github.com/david-feldt/breptile/blob/master/breptile/visualize.py"
click node_browser "https://github.com/david-feldt/breptile/blob/master/breptile/browser_view.py"

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_mesh_pipeline,node_mesh_input,node_segmentation,node_brep,node_step_export,node_agent toneBlue
class node_drawing_pipeline,node_extract,node_drawing_ir,node_reconstruct,node_recipe,node_execute,node_drawing_verify,node_oracle,node_synth toneAmber
class node_mesh_verify,node_visualize,node_browser toneMint
class node_cli,node_draw_cli toneRose
class node_user,node_step_file,node_mesh_file,node_drawing_file toneIndigo
```

## Components

### Mesh Conversion

- [Mesh Pipeline](https://github.com/david-feldt/breptile/blob/master/breptile/pipeline.py): `breptile/pipeline.py`
- [Mesh Loading](https://github.com/david-feldt/breptile/blob/master/breptile/mesh.py): `breptile/mesh.py`
- [Region Fitting](https://github.com/david-feldt/breptile/blob/master/breptile/segment.py): `breptile/segment.py`
- [BREP Geometry](https://github.com/david-feldt/breptile/blob/master/breptile/brep.py): `breptile/brep.py`
- [STEP Export](https://github.com/david-feldt/breptile/blob/master/breptile/export.py): `breptile/export.py`

### Drawing to CAD

- [Drawing Orchestration](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/pipeline.py): `breptile/drawing/pipeline.py`
- [Drawing Extraction](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/extract.py): `breptile/drawing/extract.py`
- [Drawing IR](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/ir.py): `breptile/drawing/ir.py`
- [Recipe Reconstruction](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/reconstruct.py): `breptile/drawing/reconstruct.py`
- [Parametric Recipe](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/recipe.py): `breptile/drawing/recipe.py`
- [Recipe Execution](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/execute.py): `breptile/drawing/execute.py`
- [Drawing Verification](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/verify.py): `breptile/drawing/verify.py`
- [Projection and Measures](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/oracle.py): `breptile/drawing/oracle.py`
- [IR Synthesis](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/synth.py): `breptile/drawing/synth.py`

### Verification and Viewing

- [Mesh Verification](https://github.com/david-feldt/breptile/blob/master/breptile/verify.py): `breptile/verify.py`
- [Static Visualization](https://github.com/david-feldt/breptile/blob/master/breptile/visualize.py): `breptile/visualize.py`
- [Browser CAD Viewer](https://github.com/david-feldt/breptile/blob/master/breptile/browser_view.py): `breptile/browser_view.py`

### User Interfaces

- [Main CLI](https://github.com/david-feldt/breptile/blob/master/breptile/cli.py): `breptile/cli.py`
- [Drawing CLI](https://github.com/david-feldt/breptile/blob/master/breptile/drawing/cli.py): `breptile/drawing/cli.py`

### Other components

- **Engineer**
- **STEP Model**
- **Mesh File**
- **Drawing File**
- **Human or Agent Review**

## Connections

- Engineer → Main CLI: runs command
- Main CLI → Mesh Pipeline: converts mesh
- Mesh Pipeline → Mesh Loading: loads mesh
- Mesh Pipeline → Region Fitting: fits regions
- Mesh Pipeline → BREP Geometry: builds geometry
- Mesh Pipeline → STEP Export: writes STEP
- Mesh Pipeline → Mesh Verification: optionally verifies
- Mesh Loading → Mesh File: reads
- STEP Export → STEP Model: writes
- Engineer → Drawing CLI: runs draw command
- Drawing CLI → Drawing Orchestration: dispatches stages
- Drawing Orchestration → Drawing Extraction: extracts drawing
- Drawing Orchestration → Drawing IR: loads or saves
- Drawing Extraction → Drawing File: reads
- Drawing Extraction → Drawing IR: produces IR
- Drawing Orchestration → Recipe Reconstruction: reconstructs recipe
- Recipe Reconstruction → Drawing IR: reads
- Recipe Reconstruction → Parametric Recipe: produces recipe
- Drawing Orchestration → Recipe Execution: builds model
- Recipe Execution → Parametric Recipe: executes operations
- Drawing Orchestration → STEP Model: writes STEP
- Drawing Orchestration → Drawing Verification: verifies result
- Drawing Verification → Projection and Measures: projects and measures
- Drawing Verification → STEP Model: reads model
- Drawing Verification → Drawing IR: compares evidence
- Drawing Verification → Parametric Recipe: checks dimensions
- Drawing Orchestration → Human or Agent Review: requests raster review
- Engineer → IR Synthesis: requests synthesis
- IR Synthesis → Recipe Execution: builds source model
- IR Synthesis → Projection and Measures: projects views
- IR Synthesis → Drawing IR: generates IR
- Engineer → Static Visualization: requests preview
- Engineer → Browser CAD Viewer: opens viewer
- Static Visualization → Mesh File: loads mesh
- Static Visualization → STEP Model: loads STEP
- Browser CAD Viewer → STEP Model: serves model view
