# flarkflarkflark/stemwerk-reaper architecture

> Architecture diagram of the GitHub repository flarkflarkflark/stemwerk-reaper, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flarkflarkflark/stemwerk-reaper
- Repository: https://github.com/flarkflarkflark/stemwerk-reaper

## Overview

STEMwerk is a local-first REAPER stem-separation package. A user selects media items or a time selection, chooses a separation model, stems, device and output mode, then runs processing and reviews the returned tracks or in-place takes. The map includes the normal separation path, DrumSep/Kit Split, and setup/runtime support. Relationship evidence is limited to the README and sampled files; unsampled implementation links are omitted where they cannot be verified.

Main entry points: [`scripts/reaper/_internal/STEMwerk_Workflow.lua`](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Workflow.lua) (Workflow Control), [`scripts/reaper/audio_separator_process.py`](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/audio_separator_process.py) (Stem Separation), [`scripts/reaper/STEMwerk.lua`](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/STEMwerk.lua) (STEMwerk Entry), [`scripts/reaper/_internal/stemwerk_drumsep_process.py`](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/stemwerk_drumsep_process.py) (DrumSep Processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Separation Workflow"]
  node_entry["STEMwerk Entry<br/>[STEMwerk.lua]"]
  node_workflow_ctl["Workflow Control"]
  node_settings["Model and Device Settings"]
  node_progress["Progress UI"]
end

subgraph group_processing["Audio Processing"]
  node_separator["Stem Separation"]
  node_drumsep["DrumSep Processing"]
  node_samplerate["Sample Rate Guard"]
  node_backend["Python Backend"]
end

subgraph group_project["REAPER Integration"]
  node_project_context["Project Context"]
  node_output_modes["Track and Take Output"]
  node_kit_import["Kit Split Import"]
end

subgraph group_runtime["Runtime Support"]
  node_setup["Setup and Repair<br/>[STEMwerk-SETUP.lua]"]
  node_managed_python["Managed Python Runtime"]
end

node_user(("REAPER User"))
node_reaper["REAPER Project"]

node_user -->|"starts workflow"| node_entry
node_entry -.->|"runs workflow"| node_workflow_ctl
node_workflow_ctl -.->|"configures separation"| node_settings
node_workflow_ctl -->|"runs backend"| node_separator
node_separator -->|"uses Python"| node_backend
node_workflow_ctl -.->|"shows progress"| node_progress
node_workflow_ctl -->|"reads selection"| node_project_context
node_workflow_ctl -->|"returns results"| node_output_modes
node_output_modes -->|"creates tracks or takes"| node_reaper
node_workflow_ctl -.->|"runs kit separation"| node_drumsep
node_drumsep -.->|"imports kit stems"| node_kit_import
node_setup -.->|"manages runtime"| node_managed_python
node_separator -.->|"guards audio rate"| node_samplerate

click node_entry "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/STEMwerk.lua"
click node_workflow_ctl "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Workflow.lua"
click node_settings "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Settings.lua"
click node_progress "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Progress_Render.lua"
click node_separator "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/audio_separator_process.py"
click node_drumsep "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/stemwerk_drumsep_process.py"
click node_samplerate "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/stemwerk_samplerate_guard.py"
click node_project_context "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Project_Context.lua"
click node_output_modes "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Workflow.lua"
click node_kit_import "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_DKS_Import.lua"
click node_setup "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/STEMwerk-SETUP.lua"
click node_managed_python "https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Managed_Python.lua"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_workflow_ctl,node_settings,node_progress,node_user toneBlue
class node_separator,node_drumsep,node_samplerate,node_backend toneAmber
class node_project_context,node_output_modes,node_kit_import toneMint
class node_setup,node_managed_python toneRose
class node_reaper toneIndigo
```

## Components

### Separation Workflow

- [STEMwerk Entry](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/STEMwerk.lua): `scripts/reaper/STEMwerk.lua`
- [Workflow Control](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Workflow.lua): `scripts/reaper/_internal/STEMwerk_Workflow.lua`
- [Model and Device Settings](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Settings.lua): `scripts/reaper/_internal/STEMwerk_Settings.lua`
- [Progress UI](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Progress_Render.lua): `scripts/reaper/_internal/STEMwerk_Progress_Render.lua`

### Audio Processing

- [Stem Separation](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/audio_separator_process.py): `scripts/reaper/audio_separator_process.py`
- [DrumSep Processing](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/stemwerk_drumsep_process.py): `scripts/reaper/_internal/stemwerk_drumsep_process.py`
- [Sample Rate Guard](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/stemwerk_samplerate_guard.py): `scripts/reaper/_internal/stemwerk_samplerate_guard.py`
- **Python Backend**

### REAPER Integration

- [Project Context](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Project_Context.lua): `scripts/reaper/_internal/STEMwerk_Project_Context.lua`
- [Track and Take Output](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Workflow.lua): `scripts/reaper/_internal/STEMwerk_Workflow.lua`
- [Kit Split Import](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_DKS_Import.lua): `scripts/reaper/_internal/STEMwerk_DKS_Import.lua`

### Runtime Support

- [Setup and Repair](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/STEMwerk-SETUP.lua): `scripts/reaper/STEMwerk-SETUP.lua`
- [Managed Python Runtime](https://github.com/flarkflarkflark/stemwerk-reaper/blob/main/scripts/reaper/_internal/STEMwerk_Managed_Python.lua): `scripts/reaper/_internal/STEMwerk_Managed_Python.lua`

### Other components

- **REAPER User**
- **REAPER Project**

## Connections

- REAPER User → STEMwerk Entry: starts workflow (evidence: `README.md`)
- STEMwerk Entry → Workflow Control: runs workflow
- Workflow Control → Model and Device Settings: configures separation
- Workflow Control → Stem Separation: runs backend (evidence: `README.md`)
- Stem Separation → Python Backend: uses Python (evidence: `README.md`)
- Workflow Control → Progress UI: shows progress
- Workflow Control → Project Context: reads selection (evidence: `README.md`)
- Workflow Control → Track and Take Output: returns results (evidence: `README.md`)
- Track and Take Output → REAPER Project: creates tracks or takes (evidence: `README.md`)
- Workflow Control → DrumSep Processing: runs kit separation
- DrumSep Processing → Kit Split Import: imports kit stems
- Setup and Repair → Managed Python Runtime: manages runtime
- Stem Separation → Sample Rate Guard: guards audio rate
