# soyersoyer/sysex-controls architecture

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

- Interactive diagram: https://gitdiagram.com/soyersoyer/sysex-controls
- Repository: https://github.com/soyersoyer/sysex-controls

## Overview

##### Main Components
- Application Core: At the center of the system is the main application (see main.c and sc-application files) that initializes the application, creates the primary window (sc-window), and handles application-wide configuration.
- UI Layer: Built with GTK4/Libadwaita, this consists of a set of UI templates and widgets. Notice the many “.ui” files in each module (for example, in the beatstep, keylab, minilab directories) that define controller pages and various interactive components. This layer handles user interaction, rendering, and layout.
- MIDI Communication Component: Files like sc-midi.c/h suggest a dedicated MIDI interface component that handles the reading and writing of SysEx messages. This layer is responsible for bridging the application with the underlying ALSA/MIDI system.
- Build & Localization Infrastructure: The Meson build files (meson.build) at the project root and in subdirectories, plus the “po” directory for translations, indicate that the project uses a carefully organized build and localization process. Although not runtime components, these are essential for understanding development workflows.

##### Relationships and Interactions
- The Application Core initiates the UI Layer, which in turn loads the appropriate device-specific modules based on user action (when a device is selected).
- UI components (like pages and row widgets) are tied to their corresponding C backends (e.g., pages for controller settings, ar-preset, bs-pad, etc.). Each module is loosely coupled but adheres to a common widget-based or MVC-like pattern.
- The MIDI Communication module interacts with device-specific logic to read device state and send updated controls back.

##### Architectural Patterns and Technologies
- Modular design with a separation of concerns: core application, device-specific handlers, and the UI are all distinct.
- Use of GTK4/Libadwaita for the graphical interface which employs UI definition files (.ui) and associated C code for signal handling.
- Meson build system ties everything together along with gettext for internationalization.
- Directed data flow: User events trigger updates in the UI, which then invoke device logic; this module communicates with the MIDI layer to perform real-world device configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    Core["Application Core\n(Initializes app and config)"]:::core
    UI["UI Layer\n(GTK4/Libadwaita)"]:::ui
    MIDI["MIDI Communication\n(ALSA/MIDI)"]:::midi
    Resources["Resource & Data\n(Static Assets)"]:::resources
    Build["Build & Localization\n(Meson, gettext)"]:::build

    %% Device Modules Subgraph
    subgraph "Device Modules"
        direction TB
        Akai["Akai Devices"]:::device
        Arturia["Arturia Devices"]:::device
        Beatstep["Beatstep Devices"]:::device
        Beatsteppro["Beatsteppro Devices"]:::device
        Drumbrute["Drumbrute Devices"]:::device
        DrumbruteImpact["Drumbrute Impact Devices"]:::device
        Keylab["Keylab Devices"]:::device
        Keystep["Keystep Devices"]:::device
        Microlab["Microlab Devices"]:::device
        Minibrute["Minibrute Devices"]:::device
        Minilab["Minilab Devices"]:::device
        MPKmini["MPKmini Devices"]:::device
        Additional["Additional Modules"]:::device
    end

    %% Relationships
    Core -->|"initUI"| UI
    Core -->|"loadResources"| Resources
    Core -->|"buildConfig"| Build
    UI -->|"deviceSelect"| Akai
    UI -->|"deviceSelect"| Arturia
    UI -->|"deviceSelect"| Beatstep
    UI -->|"deviceSelect"| Beatsteppro
    UI -->|"deviceSelect"| Drumbrute
    UI -->|"deviceSelect"| DrumbruteImpact
    UI -->|"deviceSelect"| Keylab
    UI -->|"deviceSelect"| Keystep
    UI -->|"deviceSelect"| Microlab
    UI -->|"deviceSelect"| Minibrute
    UI -->|"deviceSelect"| Minilab
    UI -->|"deviceSelect"| MPKmini
    UI -->|"deviceSelect"| Additional
    %% Device modules interact with MIDI
    Additional -->|"sendSysEx"| MIDI
    MIDI -->|"updateUI"| UI
    UI -->|"loadAssets"| Resources

    %% Click Events for Application Core
    click Core "https://github.com/soyersoyer/sysex-controls/blob/main/src/main.c"
    click Core "https://github.com/soyersoyer/sysex-controls/blob/main/src/sc-application.c"
    click Core "https://github.com/soyersoyer/sysex-controls/blob/main/src/sc-application.h"

    %% Click Events for UI Layer
    click UI "https://github.com/soyersoyer/sysex-controls/blob/main/src/sc-window.ui"
    click UI "https://github.com/soyersoyer/sysex-controls/blob/main/src/sc-action-row.ui"
    click UI "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-preset-chooser-page.ui"
    click UI "https://github.com/soyersoyer/sysex-controls/blob/main/src/beatstep/bs-controller-page.ui"

    %% Click Events for Akai Devices
    click Akai "https://github.com/soyersoyer/sysex-controls/blob/main/src/ak-book.c"
    click Akai "https://github.com/soyersoyer/sysex-controls/blob/main/src/ak-control.c"
    click Akai "https://github.com/soyersoyer/sysex-controls/blob/main/src/ak-program-page.c"
    click Akai "https://github.com/soyersoyer/sysex-controls/blob/main/src/ak-program-select.c"
    click Akai "https://github.com/soyersoyer/sysex-controls/blob/main/src/ak-program-select.ui"

    %% Click Events for Arturia Devices
    click Arturia "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-book.c"
    click Arturia "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-control.c"
    click Arturia "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-preset-chooser-page.c"
    click Arturia "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-preset-chooser-page.ui"
    click Arturia "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-preset-page.c"
    click Arturia "https://github.com/soyersoyer/sysex-controls/blob/main/src/ar-preset-page.ui"

    %% Click Events for Beatstep Devices
    click Beatstep "https://github.com/soyersoyer/sysex-controls/tree/main/src/beatstep"

    %% Click Events for Beatsteppro Devices
    click Beatsteppro "https://github.com/soyersoyer/sysex-controls/tree/main/src/beatsteppro"

    %% Click Events for Drumbrute Devices
    click Drumbrute "https://github.com/soyersoyer/sysex-controls/tree/main/src/drumbrute"

    %% Click Events for Drumbrute Impact Devices
    click DrumbruteImpact "https://github.com/soyersoyer/sysex-controls/tree/main/src/drumbruteimpact"

    %% Click Events for Keylab Devices
    click Keylab "https://github.com/soyersoyer/sysex-controls/tree/main/src/keylab"
    click Keylab "https://github.com/soyersoyer/sysex-controls/tree/main/src/keylab2"
    click Keylab "https://github.com/soyersoyer/sysex-controls/tree/main/src/keylab3"
    click Keylab "https://github.com/soyersoyer/sysex-controls/tree/main/src/keylab88"
    click Keylab "https://github.com/soyersoyer/sysex-controls/tree/main/src/keylabes"
    click Keylab "https://github.com/soyersoyer/sysex-controls/tree/main/src/keylabes3"

    %% Click Events for Keystep Devices
    click Keystep "https://github.com/soyersoyer/sysex-controls/tree/main/src/keystep32"
    click Keystep "https://github.com/soyersoyer/sysex-controls/tree/main/src/keystep37"
    click Keystep "https://github.com/soyersoyer/sysex-controls/tree/main/src/keysteppro"

    %% Click Events for Microlab Devices
    click Microlab "https://github.com/soyersoyer/sysex-controls/tree/main/src/microlab"

    %% Click Events for Minibrute Devices
    click Minibrute "https://github.com/soyersoyer/sysex-controls/tree/main/src/minibrute2"
    click Minibrute "https://github.com/soyersoyer/sysex-controls/tree/main/src/minibrute2s"

    %% Click Events for Minilab Devices
    click Minilab "https://github.com/soyersoyer/sysex-controls/tree/main/src/minilab"
    click Minilab "https://github.com/soyersoyer/sysex-controls/tree/main/src/minilab2"
    click Minilab "https://github.com/soyersoyer/sysex-controls/tree/main/src/minilab3"

    %% Click Events for MPKmini Devices
    click MPKmini "https://github.com/soyersoyer/sysex-controls/tree/main/src/mpkmini2"
    click MPKmini "https://github.com/soyersoyer/sysex-controls/tree/main/src/mpkmini3"

    %% Click Events for Additional Modules
    click Additional "https://github.com/soyersoyer/sysex-controls/tree/main/src/sparkle"
    click Additional "https://github.com/soyersoyer/sysex-controls/tree/main/src/thelaboratory"

    %% Click Events for MIDI Communication
    click MIDI "https://github.com/soyersoyer/sysex-controls/blob/main/src/sc-midi.c"
    click MIDI "https://github.com/soyersoyer/sysex-controls/blob/main/src/sc-midi.h"

    %% Click Events for Resource & Data Layer
    click Resources "https://github.com/soyersoyer/sysex-controls/blob/main/data/hu.irl.sysex-controls.desktop.in"
    click Resources "https://github.com/soyersoyer/sysex-controls/blob/main/data/hu.irl.sysex-controls.metainfo.xml.in"
    click Resources "https://github.com/soyersoyer/sysex-controls/tree/main/data/icons"
    click Resources "https://github.com/soyersoyer/sysex-controls/tree/main/data/screenshots"

    %% Click Events for Build & Localization Infrastructure
    click Build "https://github.com/soyersoyer/sysex-controls/blob/main/meson.build"
    click Build "https://github.com/soyersoyer/sysex-controls/blob/main/src/meson.build"
    click Build "https://github.com/soyersoyer/sysex-controls/blob/main/data/meson.build"
    click Build "https://github.com/soyersoyer/sysex-controls/blob/main/po/meson.build"
    click Build "https://github.com/soyersoyer/sysex-controls/tree/main/po"

    %% Styles
    classDef core fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef ui fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef device fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef midi fill:#ffb6c1,stroke:#000,stroke-width:2px;
    classDef resources fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef build fill:#ffff99,stroke:#000,stroke-width:2px;
```
