# imdansable/sim architecture

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

- Interactive diagram: https://gitdiagram.com/imdansable/sim
- Repository: https://github.com/imdansable/sim

## Overview

##### Main Components

a) Core Module System:
- Plugin.cpp and plugin.hpp as the entry point
- Shared components (Shared.cpp/hpp) as a common utilities layer

b) Module Categories (Group these visually):
##### Expandables
- Via (voltage buffer)
- Arr (voltage buffer)
- Bank (gates buffer)
- Phi (voltage sequencer)
- Spike (gates sequencer)

##### Expanders
- ReX (buffer manipulation)
- InX (input processing)
- OutX (output processing)
- GaitX (sequencer control)
- ModX (modulation)

##### Standalone Modules
- Tie (legato processor)
- Coerce (voltage quantizer)

##### Component Relationships

**[VCV Rack Plugin Interface]**
- ↓
**[Plugin Core (plugin.cpp)]**
- ↓
**[Shared Components]**
- ↙    ↓    ↘
**[Expandables] [Expanders] [Standalone]**

b) Data flow between components:

##### Important Architectural Elements

a) Component System:
- Displays, knobs, lights, ports, and switches

b) Helper System:
- Helpers/ directory components as a utility layer
- ModuleIterator and SliderQuantity

c) Biexpander System:
- Connection management and state handling

##### Technical Details

a) Buffer Types:
- Voltage Buffers (float values)
- Gate Buffers (boolean values)

b) Data Flow Patterns:
- Transformation chain for expanders
- Input → processing → output flow

##### Additional Elements

a) Resource Management:
- Res/ directory structure for assets
- Relationship to different themes (dark/light/vapor)

b) Build System:
- Build workflow from .github/workflows
- Relationship to plugin.json configuration

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core System
    subgraph Core
        Plugin["Plugin Interface"]:::core
        PluginCore["Plugin Core"]:::core
        Shared["Shared Components"]:::core
    end
    click PluginCore "https://github.com/imDanSable/SIM/blob/master/src/plugin.cpp"
    click Shared "https://github.com/imDanSable/SIM/blob/master/src/Shared.cpp"

    %% Component System
    subgraph Components
        CompSystem["Component System"]:::component
        Displays["Displays"]:::component
        Knobs["Knobs"]:::component
        Lights["Lights"]:::component
        Ports["Ports"]:::component
        Switches["Switches"]:::component
    end
    click CompSystem "https://github.com/imDanSable/SIM/tree/master/src/comp"
    click Displays "https://github.com/imDanSable/SIM/blob/master/src/comp/displays.hpp"
    click Knobs "https://github.com/imDanSable/SIM/blob/master/src/comp/knobs.hpp"
    click Lights "https://github.com/imDanSable/SIM/blob/master/src/comp/lights.hpp"
    click Ports "https://github.com/imDanSable/SIM/blob/master/src/comp/ports.hpp"
    click Switches "https://github.com/imDanSable/SIM/blob/master/src/comp/switches.hpp"

    %% Helper System
    subgraph Helpers
        HelperSystem["Helper System"]:::helper
        ModuleIterator["Module Iterator"]:::helper
        SliderQuantity["Slider Quantity"]:::helper
    end
    click HelperSystem "https://github.com/imDanSable/SIM/tree/master/src/helpers"
    click ModuleIterator "https://github.com/imDanSable/SIM/blob/master/src/helpers/ModuleIterator.hpp"
    click SliderQuantity "https://github.com/imDanSable/SIM/blob/master/src/helpers/SliderQuantity.hpp"

    %% Biexpander System
    subgraph Biexpander
        BiexpCore["Biexpander Core"]:::biexp
        CacheState["Cache State"]:::biexp
        ConnLights["Connection Lights"]:::biexp
        ModInstMenu["Module Instantiation"]:::biexp
    end
    click BiexpCore "https://github.com/imDanSable/SIM/blob/master/src/biexpander/biexpander.hpp"
    click CacheState "https://github.com/imDanSable/SIM/blob/master/src/biexpander/CacheState.hpp"
    click ConnLights "https://github.com/imDanSable/SIM/blob/master/src/biexpander/ConnectionLights.hpp"
    click ModInstMenu "https://github.com/imDanSable/SIM/blob/master/src/biexpander/ModuleInstantiationMenu.hpp"

    %% Expandables
    subgraph Expandables
        Via["Via<br>(Voltage Buffer)"]:::expandable
        Arr["Arr<br>(Voltage Buffer)"]:::expandable
        Bank["Bank<br>(Gates Buffer)"]:::expandable
        Phi["Phi<br>(Voltage Sequencer)"]:::expandable
        Spike["Spike<br>(Gates Sequencer)"]:::expandable
    end
    click Via "https://github.com/imDanSable/SIM/blob/master/src/Via.cpp"
    click Arr "https://github.com/imDanSable/SIM/blob/master/src/Arr.cpp"
    click Bank "https://github.com/imDanSable/SIM/blob/master/src/Bank.cpp"
    click Phi "https://github.com/imDanSable/SIM/blob/master/src/Phi.cpp"
    click Spike "https://github.com/imDanSable/SIM/blob/master/src/Spike.cpp"

    %% Expanders
    subgraph Expanders
        ReX["ReX<br>(Buffer Manipulation)"]:::expander
        InX["InX<br>(Input Processing)"]:::expander
        OutX["OutX<br>(Output Processing)"]:::expander
        GaitX["GaitX<br>(Sequencer Control)"]:::expander
        ModX["ModX<br>(Modulation)"]:::expander
    end
    click ReX "https://github.com/imDanSable/SIM/blob/master/src/ReX.cpp"
    click InX "https://github.com/imDanSable/SIM/blob/master/src/InX.cpp"
    click OutX "https://github.com/imDanSable/SIM/blob/master/src/OutX.cpp"
    click GaitX "https://github.com/imDanSable/SIM/blob/master/src/GaitX.cpp"
    click ModX "https://github.com/imDanSable/SIM/blob/master/src/ModX.cpp"

    %% Standalone Modules
    subgraph Standalone
        Tie["Tie<br>(Legato Processor)"]:::standalone
        Coerce["Coerce<br>(Voltage Quantizer)"]:::standalone
    end
    click Tie "https://github.com/imDanSable/SIM/blob/master/src/Tie.cpp"
    click Coerce "https://github.com/imDanSable/SIM/blob/master/src/Coerce.cpp"

    %% Resource Management
    subgraph Resources
        ResSystem["Resource Management"]:::resource
        Components["Components"]:::resource
        Panels["Panels"]:::resource
        Fonts["Fonts"]:::resource
    end
    click ResSystem "https://github.com/imDanSable/SIM/tree/master/res"
    click Components "https://github.com/imDanSable/SIM/tree/master/res/components"
    click Panels "https://github.com/imDanSable/SIM/tree/master/res/panels"
    click Fonts "https://github.com/imDanSable/SIM/tree/master/res/fonts"

    %% Build System
    Build["Build System"]:::build
    click Build "https://github.com/imDanSable/SIM/blob/master/.github/workflows/build-plugin.yml"

    %% Relationships
    Plugin --> PluginCore
    PluginCore --> Shared
    Shared --> CompSystem
    Shared --> HelperSystem
    Shared --> BiexpCore
    BiexpCore --> Expandables
    BiexpCore --> Expanders
    CompSystem --> Expandables
    CompSystem --> Expanders
    CompSystem --> Standalone

    %% Styles
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef component fill:#2ecc71,stroke:#27ae60,color:white
    classDef helper fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef biexp fill:#e74c3c,stroke:#c0392b,color:white
    classDef expandable fill:#1abc9c,stroke:#16a085,color:white
    classDef expander fill:#f1c40f,stroke:#f39c12,color:white
    classDef standalone fill:#9b59b6,stroke:#8e44ad,color:white
    classDef resource fill:#34495e,stroke:#2c3e50,color:white
    classDef build fill:#e67e22,stroke:#d35400,color:white
```
