# andrupavlov/pathsolver architecture

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

- Interactive diagram: https://gitdiagram.com/andrupavlov/pathsolver
- Repository: https://github.com/andrupavlov/pathsolver

## Overview

##### Project Type and Purpose
- This is an algorithmic art tool built as a Grasshopper definition (.gh) for Rhinoceros 7, with core logic implemented in a standalone Python module (PathSolver.py).
- Its purpose is to simulate point-behavior on a 3D surface and output curves/paths for artistic use in Rhino.

##### File-Structure Analysis
- Top-level:
- Example/PathSolver_ex.gh – the Grasshopper definition you open in Rhino+GH.
- PathSolver_PY/PathSolver.py – the Python‐only solver logic.
- README.md, LICENSE, .gitignore.
- No separate “frontend” or “backend” folders; instead we have:
- Host environment: Rhino + Grasshopper
- GH definition: user interface & component graph
- External script: the pure‐Python algorithm

##### Key Insights from README
- Requires Rhinoceros 7 and Grasshopper.
- GH file contains a Python node that either auto-loads PathSolver.py or refers to a manually-set filesystem path.
- Two solver variants available in the example GH file (switchable within Grasshopper).

##### Main Components
a. Rhino 7 Environment
b. Grasshopper Plugin (GH Canvas)
c. PathSolver_ex.gh Definition
d. Python Script Component (in GH)
e. External PathSolver_PY/PathSolver.py Module
f. Input Geometry & Parameters (user inputs on GH sliders, surfaces)
g. Output Geometry (points/curves rendered in Rhino viewport)

##### Relationships and Data Flow
1) User opens Rhino → Grasshopper → loads PathSolver_ex.gh
2) GH definition exposes input sliders & surface geometry
3) GH Python Component loads PathSolver.py (auto or manual path)
4) Inputs passed into PathSolver.py’s solve() function
5) Algorithm computes point trajectories/paths
6) Results returned to GH component
7) GH outputs curves/points, Rhino renders them

##### Architectural Patterns & Principles
- Separation of concerns: UI and parameter wiring live in GH, core logic lives in an external Python module.
- Modularity: PathSolver.py can be versioned/tested independently of the GH file.
- Runtime plugin loading: Python component dynamically imports the module at script‐execution time.

##### Technologies & Dependencies
- RhinoCommon API (available in Grasshopper’s Python script component)
- Grasshopper 3D visual scripting environment
- Python 3.x (as bridged by GH’s IronPython/Python scripting node)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Environment Layer
    subgraph "Rhino 7 Environment"
        style RhinoEnv fill:#e8f1f2,stroke:#333,stroke-width:2px
        RhinoEnv["Rhino 7"]:::environment
        RhinoEnv --> Grasshopper
    end

    Grasshopper["Grasshopper Plugin"]:::environment

    %% Grasshopper Definition Layer
    subgraph "Grasshopper Definition (UI & Component Graph)"
        style GHDefContainer fill:#f7e8f2,stroke:#333,stroke-width:2px
        GHDef["PathSolver_ex.gh"]:::gh
        click GHDef "https://github.com/andrupavlov/pathsolver/blob/main/Example/PathSolver_ex.gh"
        GHDef --> UserInputs
        UserInputs["User Inputs<br/>(sliders,surfaces)"]:::ui
        GHDef --> PythonNode
        PythonNode["Python Script Component"]:::gh
        click PythonNode "https://github.com/andrupavlov/pathsolver/blob/main/Example/PathSolver_ex.gh"
        noteVariant["Two solver variants selectable"]:::annotation
        PythonNode -->|loads module| PathSolverModule
        PythonNode -->|PassesGeometry&Params| PathSolverModule
        PathSolverModule -->|ReturnsPaths| PythonNode
    end

    %% External Algorithm Module
    PathSolverModule["PathSolver Module<br/>(PathSolver.py)"]:::algorithm
    click PathSolverModule "https://github.com/andrupavlov/pathsolver/blob/main/PathSolver_PY/PathSolver.py"

    %% Output Layer
    PythonNode --> VisualOutput
    VisualOutput["Visual Output<br/>(curves/points)"]:::data

    %% Documentation Layer
    subgraph "Project Documentation"
        style Docs fill:#f2f2e8,stroke:#333,stroke-width:2px
        Readme["README.md"]:::docs
        click Readme "https://github.com/andrupavlov/pathsolver/blob/main/README.md"
        License["LICENSE"]:::docs
        click License "https://github.com/andrupavlov/pathsolver/tree/main/LICENSE"
        Gitignore[".gitignore"]:::docs
        click Gitignore "https://github.com/andrupavlov/pathsolver/blob/main/.gitignore"
    end

    %% Styles
    classDef environment fill:#e0f7fa,stroke:#006064,color:#000;
    classDef gh fill:#f3e5f5,stroke:#4a148c,color:#000;
    classDef ui fill:#fff3e0,stroke:#e65100,color:#000;
    classDef algorithm fill:#e8f5e9,stroke:#1b5e20,color:#000;
    classDef data fill:#e1f5fe,stroke:#01579b,color:#000;
    classDef docs fill:#fafafa,stroke:#9e9e9e,color:#000;
    classDef annotation fill:#ffffff,stroke:#000000,stroke-dasharray: 5 5;color:#000;
```
