# gregorytravis/rhythmr architecture

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

- Interactive diagram: https://gitdiagram.com/gregorytravis/rhythmr
- Repository: https://github.com/gregorytravis/rhythmr

## Overview

##### Project Type and Purpose
- The project is an interactive audio loop creation system. It processes randomly acquired audio loops and lets users vote (swipe left/right) to iteratively refine a model that helps generate a complete song.
- It’s built in Haskell (note the abundance of .hs files in src) and leverages a combination of audio analysis, user-interaction, model-building, and musical score insertion.

##### Key Components from the File Structure
a. Core Haskell Modules (located in the src directory):
- Modules like Main.hs, Analysis.hs, Loop.hs, Looper.hs, Project.hs, and Gui.hs indicate the engine for managing loops, processing audio, interfacing with the user, and handling business logic.
- Other modules (e.g., AesonHelpers.hs, State.hs, SaveLoad.hs) suggest data modeling, serialization, state management, and perhaps interactions with external data sources or config files.

b. Build and Packaging:
- The build directory contains scripts, templates, and helper utilities (such as generate-distribution, generate-icns, shell scripts, and even a packaged macOS app template under Rhythmr.app-template) for generating a distributable version of the application.

c. Audio Input/Resources:
- The wavs directory and scripts like get-mp3s.py and musicinformationretrieval.py imply components for sourcing or preprocessing audio.

d. Documentation and Presentation:
- The doc and presentation directories indicate extensive documentation, installation instructions, and feature descriptions essential for onboarding and maintenance.

- From “User Interface” to “Core Orchestrator” (user actions) and vice versa for presenting analysis results.
- Between Audio Processing and Model Training, showing iterative improvements.
4. A separate section for build/deployment workflows, drawing connections from the core system to packaging scripts.
5. Component with the relevant technologies (e.g., “Written in Haskell”, “Packaging scripts in Bash/Python”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Subgraph
    subgraph "User Interface"
        UI1["Gui.hs"]:::haskell
        UI2["Animate.hs"]:::haskell
    end

    %% Audio Processing & Analysis Engine Subgraph
    subgraph "Audio Processing & Analysis Engine"
        AP1["Analysis.hs"]:::haskell
        AP2["Loop.hs"]:::haskell
        AP3["Looper.hs"]:::haskell
        AP4["musicinformationretrieval.py"]:::script
    end

    %% Model Training / Decision Module Subgraph
    subgraph "Model Training / Decision Module"
        MT1["State.hs"]:::haskell
        MT2["History.hs"]:::haskell
    end

    %% Application Core (Orchestrator) Subgraph
    subgraph "Application Core (Orchestrator)"
        AC1["Main.hs"]:::haskell
        AC2["Project.hs"]:::haskell
    end

    %% Build & Packaging Module Subgraph
    subgraph "Build & Packaging Module"
        BP1["build (Scripts & Templates)"]:::build
    end

    %% Connections
    UI1 -->|"user_input"| AC1
    UI2 -->|"user_input"| AC1
    AC1 -->|"trigger_build"| BP1
    AP1 -->|"audio_loops"| UI1
    AP2 -->|"audio_loops"| UI1
    AP3 -->|"audio_loops"| UI1
    AP4 -->|"audio_loops"| UI1
    AP1 -->|"loop_data"| MT1
    AP2 -->|"loop_data"| MT1
    AP3 -->|"loop_data"| MT1
    AC1 -->|"orchestrates"| AP1
    AC1 -->|"orchestrates"| AP2
    AC1 -->|"orchestrates"| AP3
    AC1 -->|"orchestrates"| AP4

    %% Click Events
    click UI1 "https://github.com/gregorytravis/rhythmr/blob/main/src/Gui.hs"
    click UI2 "https://github.com/gregorytravis/rhythmr/blob/main/src/Animate.hs"
    click AP1 "https://github.com/gregorytravis/rhythmr/blob/main/src/Analysis.hs"
    click AP2 "https://github.com/gregorytravis/rhythmr/blob/main/src/Loop.hs"
    click AP3 "https://github.com/gregorytravis/rhythmr/blob/main/src/Looper.hs"
    click AP4 "https://github.com/gregorytravis/rhythmr/blob/main/musicinformationretrieval.py"
    click MT1 "https://github.com/gregorytravis/rhythmr/blob/main/src/State.hs"
    click MT2 "https://github.com/gregorytravis/rhythmr/blob/main/src/History.hs"
    click AC1 "https://github.com/gregorytravis/rhythmr/blob/main/src/Main.hs"
    click AC2 "https://github.com/gregorytravis/rhythmr/blob/main/src/Project.hs"
    click BP1 "https://github.com/gregorytravis/rhythmr/tree/main/build/"

    %% Styles
    classDef haskell fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef script fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef build fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
