# benjaminsauder/edgeflow architecture

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

- Interactive diagram: https://gitdiagram.com/benjaminsauder/edgeflow
- Repository: https://github.com/benjaminsauder/edgeflow

## Overview

##### Project type and purpose
- EdgeFlow is a Blender addon (plugin) written in pure Python.
- It extends Blender’s mesh‐editing UI by registering a set of custom operators that perform curved edge‐loop manipulations.
- Key purpose: provide “Set Flow,” “Set Linear,” “Set Curve,” and “Set Vertex Curve” tools on Blender’s Mesh → Edge/Vertex menus.

##### File structure
- Top‐level files:
- blender_manifest.toml + __init__.py – addon metadata and registration entry point
- README.md, LICENSE, .gitignore – documentation and project metadata
- Operator modules (the core components):
- op_set_edge_flow.py
- op_set_edge_linear.py
- op_set_edge_curve.py
- op_set_vertex_curve.py
- Utility modules (shared logic):
- dijkstra.py – graph search for sorting edge loops
- edgeloop.py – constructs sorted loops from raw selection
- interpolate.py – spline/harmonic interpolation routines
- util.py – helper functions (angle checks, distance metrics, mesh access)
- No external dependencies beyond Blender’s Python API and standard library.

##### README for additional insights
- The README describes each operator’s parameters and UI placement.
- Developer Notes mention a custom edge‐loop sorting and a Hermite spline interpolation implementation.
- There is no reference to a separate service or database—everything runs inside Blender’s process.

a. Main components:
1. Blender Host Application
2. Addon Manager & Registration (blender_manifest.toml + __init__.py)
3. UI/Menu Integration (Mesh→Edge, Mesh→Vertex, Context Menus, Shortcuts)
4. Operator Modules (op_set_* .py files)
5. Core Logic Modules (dijkstra.py, edgeloop.py, interpolate.py, util.py)
6. Blender Mesh Data API (bpy.types.Mesh, BMesh)
b. Relationships & data flow:
- User triggers menu/shortcut → Blender dispatches to EdgeFlow operator
- Operator module reads current mesh via bpy and BMesh API
- Operator calls edgeloop.py to sort selected elements into loops
- Operator calls interpolate.py (with control points from edgeloop and dijkstra)
- util.py provides angle checks, tension blending, and assigns new vertex positions
- Resulting mesh is pushed back to Blender viewport
c. Architectural patterns & principles:
- Modular separation: each operator lives in its own file
- Shared services (graph search, interpolation) factored into utility modules
- Event-driven: UI event → operator invocation → mesh mutation
d. Technologies/frameworks:
- Python 3.x (Blender’s embedded Python)
- Blender Python API (bpy, bmesh modules)
- Hermite spline interpolation (self‐contained code ported from Paul Bourke’s algorithm)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Blender Host Layer
    subgraph "Blender Host" 
        direction TB
        BlenderApp["Blender Application"]:::external
        BMeshAPI["BMesh Data API\n(bpy.types.Mesh, BMesh)"]:::api
    end

    %% Addon Layer
    subgraph "EdgeFlow Addon" 
        direction TB
        subgraph "Addon Registration" 
            direction TB
            Manifest["blender_manifest.toml"]:::registration
            InitReg["__init__.py"]:::registration
        end
        UI["UI / Menus / Shortcuts"]:::ui

        subgraph "Operators" 
            direction TB
            SetFlow["Operator: Set Flow"]:::operator
            SetLinear["Operator: Set Linear"]:::operator
            SetCurve["Operator: Set Curve"]:::operator
            SetVertex["Operator: Set Vertex Curve"]:::operator
        end

        subgraph "Core Logic Modules" 
            direction TB
            Dijkstra["Module: dijkstra.py"]:::logic
            Edgeloop["Module: edgeloop.py"]:::logic
            Interpolate["Module: interpolate.py"]:::logic
            Util["Module: util.py"]:::logic
        end
    end

    %% Relationships
    BlenderApp -->|"on enable"| Manifest
    BlenderApp -->|"on enable"| InitReg
    InitReg -->|"register menus & operators"| UI

    UI -->|"invoke execute() callback"| SetFlow
    UI -->|"invoke execute() callback"| SetLinear
    UI -->|"invoke execute() callback"| SetCurve
    UI -->|"invoke execute() callback"| SetVertex

    SetFlow -->|"calls loop construction"| Edgeloop
    SetLinear -->|"calls loop construction"| Edgeloop
    SetCurve -->|"calls loop construction"| Edgeloop
    SetVertex -->|"calls loop construction"| Edgeloop

    SetFlow -->|"calls graph search"| Dijkstra
    SetLinear -->|"calls graph search"| Dijkstra
    SetCurve -->|"calls graph search"| Dijkstra
    SetVertex -->|"calls graph search"| Dijkstra

    SetFlow -->|"calls spline interpolation"| Interpolate
    SetLinear -->|"calls spline interpolation"| Interpolate
    SetCurve -->|"calls spline interpolation"| Interpolate
    SetVertex -->|"calls spline interpolation"| Interpolate

    SetFlow -->|"uses helpers"| Util
    SetLinear -->|"uses helpers"| Util
    SetCurve -->|"uses helpers"| Util
    SetVertex -->|"uses helpers"| Util

    Dijkstra -->|"reads mesh data"| BMeshAPI
    Edgeloop -->|"reads mesh data"| BMeshAPI
    Interpolate -->|"reads control points"| BMeshAPI
    Util -->|"writes new vertex positions"| BMeshAPI

    BMeshAPI -->|"mesh data returned"| SetFlow
    BMeshAPI -->|"mesh data returned"| SetLinear
    BMeshAPI -->|"mesh data returned"| SetCurve
    BMeshAPI -->|"mesh data returned"| SetVertex

    %% Click Events
    click Manifest "https://github.com/benjaminsauder/edgeflow/blob/master/blender_manifest.toml"
    click InitReg "https://github.com/benjaminsauder/edgeflow/blob/master/__init__.py"
    click UI "https://github.com/benjaminsauder/edgeflow/blob/master/__init__.py"
    click SetFlow "https://github.com/benjaminsauder/edgeflow/blob/master/op_set_edge_flow.py"
    click SetLinear "https://github.com/benjaminsauder/edgeflow/blob/master/op_set_edge_linear.py"
    click SetCurve "https://github.com/benjaminsauder/edgeflow/blob/master/op_set_edge_curve.py"
    click SetVertex "https://github.com/benjaminsauder/edgeflow/blob/master/op_set_vertex_curve.py"
    click Dijkstra "https://github.com/benjaminsauder/edgeflow/blob/master/dijkstra.py"
    click Edgeloop "https://github.com/benjaminsauder/edgeflow/blob/master/edgeloop.py"
    click Interpolate "https://github.com/benjaminsauder/edgeflow/blob/master/interpolate.py"
    click Util "https://github.com/benjaminsauder/edgeflow/blob/master/util.py"

    %% Styles
    classDef external fill:#B3E5FC,stroke:#0D47A1,color:#0D47A1,stroke-width:1px;
    classDef registration fill:#FFE0B2,stroke:#E65100,color:#E65100,stroke-width:1px;
    classDef ui fill:#C8E6C9,stroke:#2E7D32,color:#2E7D32,stroke-width:1px;
    classDef operator fill:#D1C4E9,stroke:#4A148C,color:#4A148C,stroke-width:1px;
    classDef logic fill:#FFCDD2,stroke:#B71C1C,color:#B71C1C,stroke-width:1px;
    classDef api fill:#CFD8DC,stroke:#455A64,color:#455A64,stroke-width:1px;
```
