# gumyr/build123d architecture

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

- Interactive diagram: https://gitdiagram.com/gumyr/build123d
- Repository: https://github.com/gumyr/build123d

## Overview

##### Main Components

a. Core Framework Components:
- Builders Layer (build_line.py, build_part.py, build_sketch.py)
- Objects Layer (objects_curve.py, objects_part.py, objects_sketch.py)
- Operations Layer (operations_generic.py, operations_part.py, operations_sketch.py)
- Geometry Engine (geometry.py, topology.py)
- Import/Export System (importers.py, exporters.py, exporters3d.py)

b. Supporting Components:
- Meshing System (mesher.py)
- Joint System (joints.py)
- Persistence Layer (persistence.py)
- Packing Utility (pack.py)
- Drafting System (drafting.py)

**┌─────────────────────────────────────────────────────┐**
- User Interface                      │
- (Python API with Context Managers)           │
- ┤
- Builder Layer                       │
- (BuildLine, BuildPart, BuildSketch)              │
- ┤
- Objects Layer                       │
- (Curve, Part, Sketch Objects)                    │
- ┤
- Operations Layer                      │
- (Generic, Part, Sketch Operations)               │
- ┤
- Core Geometry Engine                    │
- (OpenCascade Integration, Topology, Geometry)     │
- ┘

##### Component Relationships

- Side connections for utilities (Import/Export, Meshing, Joints)

##### Additional Elements

- Testing infrastructure
- Documentation system
- Example repository
- External tool integration

##### Implementation Notes

- The stateful context manager architecture
- The separation between geometric operations and their representation
- The extensible nature of the framework
- The integration with OpenCascade
- The support for both 2D and 3D modeling

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef geometry fill:#4CAF50,stroke:#2E7D32,color:white
    classDef utility fill:#FF9800,stroke:#EF6C00,color:white
    classDef extension fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef interface fill:#607D8B,stroke:#37474F,color:white

    %% User Interface Layer
    subgraph UI["Python API Layer"]
        API["Python API with Context Managers"]:::interface
    end

    %% Builder Layer
    subgraph BL["Builder Layer"]
        BuildLine["BuildLine"]:::core
        BuildPart["BuildPart"]:::core
        BuildSketch["BuildSketch"]:::core
    end

    %% Objects Layer
    subgraph OL["Objects Layer"]
        CurveObj["Curve Objects"]:::core
        PartObj["Part Objects"]:::core
        SketchObj["Sketch Objects"]:::core
    end

    %% Operations Layer
    subgraph OpL["Operations Layer"]
        GenericOps["Generic Operations"]:::core
        PartOps["Part Operations"]:::core
        SketchOps["Sketch Operations"]:::core
    end

    %% Core Geometry Engine
    subgraph GE["Core Geometry Engine"]
        Geometry["Geometry"]:::geometry
        Topology["Topology"]:::geometry
        OpenCascade["OpenCascade Integration"]:::geometry
    end

    %% Utility Components
    subgraph UT["Utility Components"]
        Import["Importers"]:::utility
        Export["Exporters"]:::utility
        Export3D["Exporters3D"]:::utility
        Mesher["Meshing System"]:::utility
        Pack["Packing Utility"]:::utility
        Persistence["Persistence"]:::utility
    end

    %% Extension Components
    subgraph EX["Extension Components"]
        Joints["Joint System"]:::extension
        Drafting["Drafting System"]:::extension
    end

    %% Relationships
    API --> BL
    BL <--> OL
    OL --> OpL
    OpL <--> GE
    UT --> GE
    EX --> GE

    %% Click events
    click BuildLine "https://github.com/gumyr/build123d/blob/dev/src/build123d/build_line.py"
    click BuildPart "https://github.com/gumyr/build123d/blob/dev/src/build123d/build_part.py"
    click BuildSketch "https://github.com/gumyr/build123d/blob/dev/src/build123d/build_sketch.py"
    click CurveObj "https://github.com/gumyr/build123d/blob/dev/src/build123d/objects_curve.py"
    click PartObj "https://github.com/gumyr/build123d/blob/dev/src/build123d/objects_part.py"
    click SketchObj "https://github.com/gumyr/build123d/blob/dev/src/build123d/objects_sketch.py"
    click GenericOps "https://github.com/gumyr/build123d/blob/dev/src/build123d/operations_generic.py"
    click PartOps "https://github.com/gumyr/build123d/blob/dev/src/build123d/operations_part.py"
    click SketchOps "https://github.com/gumyr/build123d/blob/dev/src/build123d/operations_sketch.py"
    click Geometry "https://github.com/gumyr/build123d/blob/dev/src/build123d/geometry.py"
    click Topology "https://github.com/gumyr/build123d/blob/dev/src/build123d/topology.py"
    click Import "https://github.com/gumyr/build123d/blob/dev/src/build123d/importers.py"
    click Export "https://github.com/gumyr/build123d/blob/dev/src/build123d/exporters.py"
    click Export3D "https://github.com/gumyr/build123d/blob/dev/src/build123d/exporters3d.py"
    click Mesher "https://github.com/gumyr/build123d/blob/dev/src/build123d/mesher.py"
    click Joints "https://github.com/gumyr/build123d/blob/dev/src/build123d/joints.py"
    click Persistence "https://github.com/gumyr/build123d/blob/dev/src/build123d/persistence.py"
    click Pack "https://github.com/gumyr/build123d/blob/dev/src/build123d/pack.py"
    click Drafting "https://github.com/gumyr/build123d/blob/dev/src/build123d/drafting.py"

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Geometry Engine"]:::geometry
        L3["Utility Components"]:::utility
        L4["Extension Components"]:::extension
        L5["Interface Layer"]:::interface
    end
```
