# jodacola/flowjam architecture

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

- Interactive diagram: https://gitdiagram.com/jodacola/flowjam
- Repository: https://github.com/jodacola/flowjam

## Overview

##### Main Components

a) Input Layer:
- Key Event Capture System (using Quartz API)
- Event Processing & Threshold Management

b) Audio Management Layer:
- Audio Track Management
- Layer Mixing & Playback

c) Jam Library System:
- Library Management
- Manifest Processing
- Audio File Storage

##### Component Relationships

**[Global Keyboard Input] → [Key Event Manager] → [Threshold Manager]**
- ↓
**[Jam Library] → [Audio Manager] ← [Threshold-based Track Selection]**
- ↓
- [Audio Output]

##### Detailed Component Breakdown

Key Event Manager (flowjam/key_event_manager.py):
- Connection to macOS Quartz API
- Event counting mechanism
- To threshold management

Audio Manager (flowjam/audio_manager.py):
- Track layering system
- Connection to audio playback
- Relationship with thresholds

Jam Library (jams/library.py):
- Manifest processing
- Audio file management
- Relationship with audio manager

##### Configuration Elements

A separate section showing configurable parameters:
- Threshold settings
- Falloff period
- Jam library path

##### Technical Details

- Python 3 runtime environment
- macOS-specific components
- File format support (WAV/MP3)
- Real-time audio mixing capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef input fill:#a8d1f0,stroke:#333
    classDef processing fill:#90EE90,stroke:#333
    classDef audio fill:#DDA0DD,stroke:#333
    classDef config fill:#D3D3D3,stroke:#333
    classDef external fill:#FFE4B5,stroke:#333
    classDef storage fill:#F0E68C,stroke:#333

    %% Input Layer
    subgraph InputLayer["Input Processing Layer"]
        QuartzListener["Quartz Event Listener"]
        EventCounter["Event Counter/Timer"]
        ThresholdCalc["Threshold Calculator"]
    end

    %% Processing Layer
    subgraph ProcessingLayer["Core Processing Layer"]
        LibraryManager["Jam Library Manager"]
        ManifestParser["Manifest Parser"]
        ConfigManager["Configuration Manager"]
        AppController["Main Application Controller"]
    end

    %% Audio Layer
    subgraph AudioLayer["Audio Management Layer"]
        TrackManager["Audio Track Manager"]
        Mixer["Multi-track Mixer"]
        AudioOutput["Audio Output"]
    end

    %% External Dependencies
    subgraph ExternalDeps["External Dependencies"]
        Quartz["macOS Quartz Framework"]
        PythonRuntime["Python Runtime"]
        AudioSystem["System Audio"]
    end

    %% Storage
    subgraph Storage["Storage Layer"]
        JamLibrary["Jam Library"]
        ManifestFile["Manifest File"]
        AudioFiles["Audio Track Files"]
    end

    %% Relationships
    Quartz --> QuartzListener
    QuartzListener --> EventCounter
    EventCounter --> ThresholdCalc
    ThresholdCalc --> AppController
    
    ConfigManager --> AppController
    AppController --> LibraryManager
    LibraryManager --> ManifestParser
    ManifestParser --> TrackManager
    
    LibraryManager --> JamLibrary
    JamLibrary --> ManifestFile
    JamLibrary --> AudioFiles
    
    TrackManager --> Mixer
    Mixer --> AudioOutput
    AudioOutput --> AudioSystem

    %% Click Events
    click QuartzListener "https://github.com/jodacola/flowjam/blob/main/flowjam/key_event_manager.py"
    click ThresholdCalc "https://github.com/jodacola/flowjam/blob/main/flowjam/thresholds.py"
    click TrackManager "https://github.com/jodacola/flowjam/blob/main/flowjam/audio_manager.py"
    click LibraryManager "https://github.com/jodacola/flowjam/blob/main/jams/library.py"
    click ManifestParser "https://github.com/jodacola/flowjam/blob/main/jams/jam.py"
    click ConfigManager "https://github.com/jodacola/flowjam/blob/main/arguments.py"
    click AppController "https://github.com/jodacola/flowjam/blob/main/app.py"
    click JamLibrary "https://github.com/jodacola/flowjam/tree/main/jam_library/flowjam/"
    click ManifestFile "https://github.com/jodacola/flowjam/blob/main/jam_library/flowjam/manifest.json"
    click AudioFiles "https://github.com/jodacola/flowjam/blob/main/jam_library/flowjam/flow_jam_level_1.wav"

    %% Style Applications
    class QuartzListener,EventCounter,ThresholdCalc input
    class LibraryManager,ManifestParser,ConfigManager,AppController processing
    class TrackManager,Mixer,AudioOutput audio
    class Quartz,PythonRuntime,AudioSystem external
    class JamLibrary,ManifestFile,AudioFiles storage

    %% Legend
    subgraph Legend
        InputComp["Input Component"]:::input
        ProcessComp["Processing Component"]:::processing
        AudioComp["Audio Component"]:::audio
        ExtComp["External Dependency"]:::external
        StorageComp["Storage Component"]:::storage
    end
```
