# stitchfoundry/laserfoundry architecture

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

- Interactive diagram: https://gitdiagram.com/stitchfoundry/laserfoundry
- Repository: https://github.com/stitchfoundry/laserfoundry

## Overview

LaserFoundry is a laser-layout and cutting application. The main workflow is to create or import artwork, edit and configure cut layers, preview a planned toolpath, then generate G-code and stream it to a controller or simulator. Desktop, browser, and CLI entry points share the command-driven engine; MCP exposes those commands to agents. The graph also retains documented AI and MakerFoundry capabilities. Some implementation paths are inferred only from the tree and README, so those relationships are shown as documented or unverified rather than implying inspected source.

Main entry points: [`crates/engine/src/cmd/mod.rs`](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/cmd/mod.rs) (Design commands), [`crates/engine/src/session.rs`](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/session.rs) (Command session), [`crates/engine/src/cmd/file.rs`](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/cmd/file.rs) (File import), [`crates/toolpath/src/lib.rs`](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/toolpath/src/lib.rs) (Toolpath planner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User interfaces"]
  node_desktop["Desktop app<br/>[main.rs]"]
  node_web["Browser app<br/>[lib.rs]"]
  node_cli["CLI<br/>[main.rs]"]
  node_ui["Egui interface<br/>[lib.rs]"]
  node_mcp["MCP tools<br/>[lib.rs]"]
end

subgraph group_design["Design and editing"]
  node_engine["Command session<br/>[session.rs]"]
  node_commands["Design commands<br/>[mod.rs]"]
  node_import["File import<br/>[file.rs]"]
  node_svg["SVG parsing<br/>[lib.rs]"]
  node_dxf["DXF parsing<br/>[lib.rs]"]
  node_geometry["Geometry<br/>[lib.rs]"]
  node_nesting["Nesting<br/>[lib.rs]"]
end

subgraph group_job["Job generation"]
  node_planner["Toolpath planner<br/>[lib.rs]"]
  node_timeline["Preview timeline<br/>[timeline.rs]"]
  node_gcode["G-code generation<br/>[lib.rs]"]
end

subgraph group_machine["Machine control"]
  node_device["Controller link<br/>[link.rs]"]
  node_stream["Job streaming<br/>[stream.rs]"]
  node_sim["Controller simulator<br/>[sim.rs]"]
end

subgraph group_services["Connected services"]
  node_ai["AI features<br/>[lib.rs]"]
  node_maker["MakerFoundry sharing<br/>[maker.rs]"]
end

node_user(("Designer"))
node_controller(("Laser controller"))
node_account(("Foundry Account"))
node_maker_service(("MakerFoundry service"))

node_user -->|"uses"| node_desktop
node_user -->|"uses"| node_web
node_user -->|"runs"| node_cli
node_desktop -->|"hosts"| node_ui
node_ui -->|"executes commands"| node_engine
node_cli -.->|"runs scripts"| node_engine
node_mcp -->|"executes commands"| node_engine
node_engine -->|"dispatches"| node_commands
node_commands -->|"registers"| node_import
node_import -.->|"imports SVG"| node_svg
node_import -.->|"imports DXF"| node_dxf
node_commands -.->|"edits shapes"| node_geometry
node_commands -.->|"arranges parts"| node_nesting
node_commands -.->|"offers AI actions"| node_ai
node_ai -.->|"requests credits"| node_account
node_commands -.->|"publishes drafts"| node_maker
node_maker -.->|"sends designs"| node_maker_service
node_engine -.->|"plans job"| node_planner
node_planner -.->|"previews moves"| node_timeline
node_planner -.->|"generates program"| node_gcode
node_gcode -.->|"supplies job"| node_stream
node_stream -.->|"streams commands"| node_device
node_device -.->|"controls"| node_controller
node_device -.->|"uses simulator"| node_sim

click node_desktop "https://github.com/stitchfoundry/laserfoundry/blob/main/apps/laserfoundry/src/main.rs"
click node_web "https://github.com/stitchfoundry/laserfoundry/blob/main/apps/laserfoundry-web/src/lib.rs"
click node_cli "https://github.com/stitchfoundry/laserfoundry/blob/main/apps/laserfoundry-cli/src/main.rs"
click node_ui "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/ui-egui/src/lib.rs"
click node_engine "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/session.rs"
click node_commands "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/cmd/mod.rs"
click node_import "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/cmd/file.rs"
click node_svg "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/svg/src/lib.rs"
click node_dxf "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/dxf/src/lib.rs"
click node_geometry "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/geom/src/lib.rs"
click node_nesting "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/nest/src/lib.rs"
click node_ai "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/ai/src/lib.rs"
click node_maker "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/ai/src/maker.rs"
click node_planner "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/toolpath/src/lib.rs"
click node_timeline "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/toolpath/src/timeline.rs"
click node_gcode "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/gcode/src/lib.rs"
click node_device "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/device/src/link.rs"
click node_stream "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/device/src/stream.rs"
click node_sim "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/device/src/sim.rs"
click node_mcp "https://github.com/stitchfoundry/laserfoundry/blob/main/crates/mcp/src/lib.rs"

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_desktop,node_web,node_cli,node_ui,node_mcp toneBlue
class node_engine,node_commands,node_import,node_svg,node_dxf,node_geometry,node_nesting toneAmber
class node_planner,node_timeline,node_gcode toneMint
class node_device,node_stream,node_sim toneRose
class node_ai,node_maker,node_user,node_controller,node_account,node_maker_service toneIndigo
```

## Components

### User interfaces

- [Desktop app](https://github.com/stitchfoundry/laserfoundry/blob/main/apps/laserfoundry/src/main.rs): `apps/laserfoundry/src/main.rs`
- [Browser app](https://github.com/stitchfoundry/laserfoundry/blob/main/apps/laserfoundry-web/src/lib.rs): `apps/laserfoundry-web/src/lib.rs`
- [CLI](https://github.com/stitchfoundry/laserfoundry/blob/main/apps/laserfoundry-cli/src/main.rs): `apps/laserfoundry-cli/src/main.rs`
- [Egui interface](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/ui-egui/src/lib.rs): `crates/ui-egui/src/lib.rs`
- [MCP tools](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/mcp/src/lib.rs): `crates/mcp/src/lib.rs`

### Design and editing

- [Command session](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/session.rs): `crates/engine/src/session.rs`
- [Design commands](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/cmd/mod.rs): `crates/engine/src/cmd/mod.rs`
- [File import](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/engine/src/cmd/file.rs): `crates/engine/src/cmd/file.rs`
- [SVG parsing](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/svg/src/lib.rs): `crates/svg/src/lib.rs`
- [DXF parsing](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/dxf/src/lib.rs): `crates/dxf/src/lib.rs`
- [Geometry](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/geom/src/lib.rs): `crates/geom/src/lib.rs`
- [Nesting](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/nest/src/lib.rs): `crates/nest/src/lib.rs`

### Job generation

- [Toolpath planner](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/toolpath/src/lib.rs): `crates/toolpath/src/lib.rs`
- [Preview timeline](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/toolpath/src/timeline.rs): `crates/toolpath/src/timeline.rs`
- [G-code generation](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/gcode/src/lib.rs): `crates/gcode/src/lib.rs`

### Machine control

- [Controller link](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/device/src/link.rs): `crates/device/src/link.rs`
- [Job streaming](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/device/src/stream.rs): `crates/device/src/stream.rs`
- [Controller simulator](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/device/src/sim.rs): `crates/device/src/sim.rs`

### Connected services

- [AI features](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/ai/src/lib.rs): `crates/ai/src/lib.rs`
- [MakerFoundry sharing](https://github.com/stitchfoundry/laserfoundry/blob/main/crates/ai/src/maker.rs): `crates/ai/src/maker.rs`

### Other components

- **Designer**
- **Laser controller**
- **Foundry Account**
- **MakerFoundry service**

## Connections

- Designer → Desktop app: uses (evidence: `README.md`)
- Designer → Browser app: uses (evidence: `README.md`)
- Designer → CLI: runs (evidence: `README.md`)
- Desktop app → Egui interface: hosts (evidence: `apps/laserfoundry/src/main.rs`)
- Egui interface → Command session: executes commands (evidence: `crates/ui-egui/src/lib.rs`)
- CLI → Command session: runs scripts (evidence: `README.md`)
- MCP tools → Command session: executes commands (evidence: `crates/mcp/src/lib.rs`)
- Command session → Design commands: dispatches (evidence: `crates/engine/src/session.rs`)
- Design commands → File import: registers (evidence: `crates/engine/src/cmd/mod.rs`)
- File import → SVG parsing: imports SVG (evidence: `README.md`)
- File import → DXF parsing: imports DXF (evidence: `README.md`)
- Design commands → Geometry: edits shapes (evidence: `README.md`)
- Design commands → Nesting: arranges parts (evidence: `README.md`)
- Design commands → AI features: offers AI actions (evidence: `README.md`)
- AI features → Foundry Account: requests credits (evidence: `README.md`)
- Design commands → MakerFoundry sharing: publishes drafts (evidence: `README.md`)
- MakerFoundry sharing → MakerFoundry service: sends designs (evidence: `README.md`)
- Command session → Toolpath planner: plans job (evidence: `README.md`)
- Toolpath planner → Preview timeline: previews moves (evidence: `README.md`)
- Toolpath planner → G-code generation: generates program (evidence: `README.md`)
- G-code generation → Job streaming: supplies job (evidence: `README.md`)
- Job streaming → Controller link: streams commands (evidence: `README.md`)
- Controller link → Laser controller: controls (evidence: `README.md`)
- Controller link → Controller simulator: uses simulator (evidence: `README.md`)
