# thekaushikls/catsule architecture

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

- Interactive diagram: https://gitdiagram.com/thekaushikls/catsule
- Repository: https://github.com/thekaushikls/catsule

## Overview

##### Project Type and Purpose
- Catsule is a desktop plugin (written in C#/.NET) for the Rhino 3D modeling environment with Grasshopper integration. It also ships with a static website (in “Web”) and documentation (in “docs”). Its core functionality lives in the “Source” folder as a Rhino/Grasshopper command library.

##### High-Level File Structure Analysis
- Source/Catsule.sln & .csproj: the Visual Studio solution and project defining the plugin assembly.
- Source/Commands: C# classes implementing Rhino commands (GhReloadCommand, GhSettingsCommand, GhReloadCommand).
- Source/DocumentHandler.cs: central logic that hooks into Rhino document events (.3dm open).
- Source/EmbeddedResources & Properties: resources and assembly metadata.
- Web/*: static site assets (Mobirise-generated) for the public homepage/demos.
- docs/*: standalone documentation site with its own assets.
- Scripts/update_version.py & .github/workflows/release_ci.yml: automation for version bumping and CI/CD.

##### Core Components
- Rhino Host (RhinoCommon API)
- Grasshopper Host (Grasshopper API)
- Catsule Plugin Assembly
- DocumentHandler (hooks Rhino events)
- GhAutoload module (auto-opens matching .gh)
- GhSettings module (toggles autoload feature, persists settings)
- GhReload module (re-initializes open Grasshopper files)
- File System (.3dm and .gh files)
- Configuration store (local file or registry, manipulated by GhSettings)
- CI/CD Pipeline (GitHub Actions → build → package → publish to Rhino PackageManager / Food4Rhino)
- Web/UI & Documentation sites (static assets served separately)

##### Component Relationships and Data Flows
- On Rhino “New/Open .3dm” event → DocumentHandler intercepts → if GhAutoload enabled → GhAutoload reads .3dm path → instructs Grasshopper Host to open corresponding .gh.
- User invokes “GhSettings” in Rhino → GhSettings module toggles flag → writes to configuration store → DocumentHandler picks up new setting on next document event.
- User invokes “GhReload” in Rhino → GhReload module signals Grasshopper Host to reload current Grasshopper definition(s).
- CI Pipeline monitors source repo → on push or release tag → invokes build script → outputs plugin package → pushes to GitHub Releases and Rhino PackageManager.

##### Architectural Patterns and Design Principles
- Plugin/Extension pattern: Catsule assembly loaded at Rhino startup.
- Command pattern: each feature exposed as a distinct Rhino command class.
- Event-driven: DocumentHandler subscribes to Rhino document events.
- Separation of concerns: core logic (Source) is distinct from static web assets (Web/docs) and from CI scripts.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Rhino Host"
        RC["RhinoCommon API"]:::host
        GH["Grasshopper API"]:::host
    end

    subgraph "Catsule Plugin Assembly"
        SLN["Catsule.sln & .csproj"]:::plugin
        Entry["Catsule.cs"]:::plugin
        DocH["DocumentHandler"]:::plugin
        Auto["GhAutoload"]:::plugin
        Settings["GhSettings"]:::plugin
        Reload["GhReload"]:::plugin
        subgraph "Embedded Resources & Metadata"
            ResDir["EmbeddedResources"]:::plugin
            AssInfo["AssemblyInfo.cs"]:::plugin
        end
    end

    FS["File System (.3dm/.gh)"]:::storage
    Config["Configuration Store"]:::storage

    subgraph "CI/CD Pipeline"
        CIconfig[".github/workflows/release_ci.yml"]:::external
        UpdateScript["Scripts/update_version.py"]:::external
        CICDbox["Build & Package"]:::process
        Publish["Publish"]:::process
    end

    PKGMGR["Rhino PackageManager / GitHub Releases"]:::external

    Web["Web Static Site"]:::external
    Docs["docs Static Site"]:::external

    %% Runtime interactions
    RC -->|"open document"| DocH
    DocH -->|"if enabled"| Auto
    Auto -->|"open .gh"| GH
    DocH -.->|"reads .3dm"| FS
    RC -->|"invoke command"| Settings
    Settings -->|"writes setting"| Config
    RC -->|"invoke command"| Reload
    Reload -->|"reload definitions"| GH

    %% CI/CD flow
    SLN -->|"ci trigger"| CIconfig
    CIconfig -->|"runs"| UpdateScript
    UpdateScript --> CICDbox
    CICDbox -.-> Publish
    Publish --> PKGMGR

    %% Static sites
    Web
    Docs

    %% Click Events
    click SLN "https://github.com/thekaushikls/catsule/blob/main/Source/Catsule.sln"
    click SLN "https://github.com/thekaushikls/catsule/blob/main/Source/Catsule.csproj"
    click Entry "https://github.com/thekaushikls/catsule/blob/main/Source/Catsule.cs"
    click DocH "https://github.com/thekaushikls/catsule/blob/main/Source/DocumentHandler.cs"
    click Settings "https://github.com/thekaushikls/catsule/blob/main/Source/Commands/GhSettingsCommand.cs"
    click Reload "https://github.com/thekaushikls/catsule/blob/main/Source/Commands/GhReloadCommand.cs"
    click ResDir "https://github.com/thekaushikls/catsule/tree/main/Source/EmbeddedResources"
    click AssInfo "https://github.com/thekaushikls/catsule/blob/main/Source/Properties/AssemblyInfo.cs"
    click CIconfig "https://github.com/thekaushikls/catsule/blob/main/.github/workflows/release_ci.yml"
    click UpdateScript "https://github.com/thekaushikls/catsule/blob/main/Scripts/update_version.py"
    click Web "https://github.com/thekaushikls/catsule/tree/main/Web/"
    click Docs "https://github.com/thekaushikls/catsule/tree/main/docs/"

    %% Styles
    classDef host fill:#c8f7c5,stroke:#2ecc71,stroke-width:2px
    classDef plugin fill:#d0e6ff,stroke:#3498db,stroke-width:2px
    classDef storage fill:#f2f2f2,stroke:#7f8c8d,stroke-width:2px,stroke-dasharray: 5 5
    classDef external fill:#ede7f6,stroke:#8e44ad,stroke-width:2px
    classDef process fill:#ffe6cc,stroke:#e67e22,stroke-width:2px
```
