# mrjoy/sparkle_motion architecture

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

- Interactive diagram: https://gitdiagram.com/mrjoy/sparkle_motion
- Repository: https://github.com/mrjoy/sparkle_motion

## Overview

##### Main System Components

a) Input Layer
- Novation Launchpad (Control Surface)
- Numark Orbit (Secondary Control)
- Audio Input Systems (experimental)
- Configuration Files

b) Core Processing Layer
- Simulation Engine
- Node Graph System
- Launch Pad Widget System
- Task Management System

c) Output Layer
- Philips Hue Bridge Interface
- Light Management System

##### Key Architectural Patterns to Highlight

- Blue Rectangles: Core Components
- Green Rectangles: Input Devices
- Yellow Diamonds: Processing Nodes
- Red Rectangles: Output Devices
- Purple Rectangles: Configuration Systems

##### Component Relationships

**Input Devices → Launch Pad Widget System → Node Graph System → Light Management → Hue Bridges → Physical Lights**

##### Detailed Component Breakdown

a) Node Graph System (Central Component):
- Generators (Perlin, Wave, Const)
- Transforms (Contrast, Range, Spotlight)
- As a hierarchical tree

b) Task Management Layer:
- ManagedTask
- UnmanagedTask
- Simulation Tasks (RenderTask, SweepTask, etc.)
- As parallel processing units

##### Data Flow Indicators

- Control signals (from input devices)
- Processing flow (through node graph)
- Output commands (to bridges)
- Configuration loading

##### Technical Details

Annotations for:
- Ruby-based implementation
- MIDI interface requirements
- Network protocols (SSDP, HTTP)
- Real-time processing requirements

##### Subsystem Details

Create insets for:
- Launch Pad Widget System
- Audio Processing Pipeline
- Bridge Communication Protocol

##### The separation between input processing, simulation, and output handling

Use a hierarchical layout with:
- Top: Input devices and configuration
- Middle: Core processing and node system
- Bottom: Output handling and physical devices

- Node types and their purposes
- Communication protocols
- Control flow patterns
- Task management system

This will create a comprehensive visualization that captures both the high-level architecture and the important implementation details of this real-time lighting control system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        LP[Novation Launchpad]:::input
        NO[Numark Orbit]:::input
        AI["Audio Input System"]:::input
        CF["Configuration Files"]:::input
    end

    subgraph Core
        LPWS["Launch Pad Widget System"]:::core
        NGS["Node Graph System"]:::core
        SE["Simulation Engine"]:::core
        TMS["Task Management"]:::core

        subgraph "Node Types"
            GEN["Generators"]:::node
            TRANS["Transforms"]:::node
        end

        subgraph "Task Types"
            MT["Managed Tasks"]:::task
            UT["Unmanaged Tasks"]:::task
            RT["Render Tasks"]:::task
            ST["Sweep Tasks"]:::task
        end
    end

    subgraph Output
        HB["Hue Bridge Interface"]:::output
        LMS["Light Management"]:::output
        PL["Physical Lights"]:::output
    end

    %% Connections
    LP --> LPWS
    NO --> LPWS
    AI --> NGS
    CF --> NGS

    LPWS --> NGS
    NGS --> GEN
    NGS --> TRANS
    GEN --> SE
    TRANS --> SE

    SE --> TMS
    TMS --> MT
    TMS --> UT
    TMS --> RT
    TMS --> ST

    SE --> LMS
    LMS --> HB
    HB --> PL

    %% Click Events
    click LPWS "https://github.com/MrJoy/sparkle_motion/tree/master/lib/sparkle_motion/launch_pad/"
    click AI "https://github.com/MrJoy/sparkle_motion/tree/master/experimental/lib/sparkle_motion/audio/"
    click CF "https://github.com/MrJoy/sparkle_motion/blob/master/lib/sparkle_motion/config.rb"
    click NGS "https://github.com/MrJoy/sparkle_motion/tree/master/lib/sparkle_motion/nodes/"
    click GEN "https://github.com/MrJoy/sparkle_motion/tree/master/lib/sparkle_motion/nodes/generators/"
    click TRANS "https://github.com/MrJoy/sparkle_motion/tree/master/lib/sparkle_motion/nodes/transforms/"
    click MT "https://github.com/MrJoy/sparkle_motion/blob/master/lib/sparkle_motion/managed_task.rb"
    click UT "https://github.com/MrJoy/sparkle_motion/blob/master/lib/sparkle_motion/unmanaged_task.rb"
    click RT "https://github.com/MrJoy/sparkle_motion/blob/master/lib/sparkle_motion/simulation/render_task.rb"
    click ST "https://github.com/MrJoy/sparkle_motion/blob/master/lib/sparkle_motion/simulation/sweeper_task.rb"
    click SE "https://github.com/MrJoy/sparkle_motion/tree/master/lib/sparkle_motion/simulation/"
    click HB "https://github.com/MrJoy/sparkle_motion/tree/master/lib/sparkle_motion/hue/"

    %% Styles
    classDef input fill:#90EE90
    classDef core fill:#87CEEB
    classDef node fill:#FFD700
    classDef task fill:#DDA0DD
    classDef output fill:#FF6B6B
    
    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Core Components]:::core
        L3[Node Components]:::node
        L4[Task Components]:::task
        L5[Output Components]:::output
    end
```
