# seamless-medley/medley architecture

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

- Interactive diagram: https://gitdiagram.com/seamless-medley/medley
- Repository: https://github.com/seamless-medley/medley

## Overview

##### Main Components Identification

a) Core Engine Layer:
- Node-medley (native audio processing engine)
- Audio processing components (ReplayGain, Limiter)
- Playback and mixing system
- Track management

b) Service Layer:
- Discord Bot integration
- Streaming services (Icecast)
- WebRTC audio streaming
- WebSocket communication

c) Library Management:
- Music database
- Metadata handling
- File scanning system
- Search functionality

d) User Interface:
- Web UI
- Discord commands interface
- Real-time audio visualization

##### Detailed Component Breakdown

Core Engine (node-medley):
**┌─────────────────────────────────┐**
- Node-Medley Engine             │
- ┤
- Audio Deck                   │
- Mixing Engine                │
- DSP Processing              │
- Format Decoders             │
- ┘

Audio Processing Chain:
**┌──────────┐    ┌──────────┐    ┌──────────┐**
- ReplayGain├───►│ Limiter  ├───►│ Output   │
- ┘    └──────────┘    └──────────┘

##### Integration Points

Clear connection points for:
- Discord Bot integration
- Streaming outputs
- Web UI connections
- Database interactions

##### Key Features to Highlight

- Seamless mixing paths
- Real-time audio processing flow
- Metadata handling
- User interaction points

##### Technical Details

Technical annotations for:
- Supported audio formats
- Network protocols (WebRTC, WebSocket)
- Database connections
- API endpoints

**━━━━ Audio Signal Flow**
**→→→→ Control Flow**
**▢▢▢▢ External Services**
- Data Flow

##### Implementation Notes

- Maintain consistent styling
- Version information
- Notes for scaling considerations

##### Documentation Integration

References to:
- Configuration options
- Deployment scenarios
- Integration points
- Scaling capabilities

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef core fill:#b3d9ff,stroke:#333
    classDef audio fill:#99ccff,stroke:#333
    classDef service fill:#99ff99,stroke:#333
    classDef library fill:#ffcc99,stroke:#333
    classDef ui fill:#e6b3ff,stroke:#333
    classDef db fill:#ffb3b3,stroke:#333

    subgraph CoreEngine["Core Audio Engine"]
        AudioDeck["Audio Deck"]:::core
        AudioProc["Audio Processing"]:::core
        Limiter["Limiter"]:::core
        NodeMedley["Node-Medley Integration"]:::core
    end

    subgraph LibraryMgmt["Library Management"]
        MusicDB["Music Database"]:::library
        FileScanner["File Scanner"]:::library
        SearchSystem["Search System"]:::library
        MetadataHandler["Metadata Handler"]:::library
    end

    subgraph StreamingServices["Streaming Services"]
        Icecast["Icecast Integration"]:::service
        Shoutcast["Shoutcast Integration"]:::service
        WebRTC["WebRTC Audio"]:::service
        WebSocket["WebSocket Audio"]:::service
    end

    subgraph DiscordInt["Discord Integration"]
        BotCore["Bot Core"]:::service
        Commands["Commands"]:::service
        VoiceSystem["Voice System"]:::service
    end

    subgraph WebInterface["Web Interface"]
        MainUI["Main UI"]:::ui
        Components["UI Components"]:::ui
        AudioControls["Audio Controls"]:::ui
    end

    subgraph PlaybackSystem["Playback System"]
        CorePlayback["Core Playback"]:::core
        StationMgmt["Station Management"]:::core
        TrackMgmt["Track Management"]:::core
    end

    subgraph Config["Configuration"]
        StationConfig["Station Config"]:::core
        StreamConfig["Streaming Config"]:::core
    end

    subgraph Database["Database Systems"]
        Models["DB Models"]:::db
        MusicDBSystem["Music Database"]:::db
    end

    %% Relationships
    AudioDeck --> AudioProc
    AudioProc --> Limiter
    NodeMedley --> AudioDeck
    
    CorePlayback --> AudioDeck
    TrackMgmt --> CorePlayback
    StationMgmt --> CorePlayback

    MusicDB --> SearchSystem
    FileScanner --> MusicDB
    MetadataHandler --> MusicDB

    CorePlayback --> Icecast
    CorePlayback --> Shoutcast
    CorePlayback --> WebRTC
    CorePlayback --> WebSocket

    BotCore --> VoiceSystem
    Commands --> BotCore
    VoiceSystem --> CorePlayback

    MainUI --> Components
    Components --> AudioControls
    AudioControls --> WebSocket

    StationConfig --> StationMgmt
    StreamConfig --> StreamingServices

    Models --> MusicDBSystem
    MusicDBSystem --> MusicDB

    %% Click events
    click AudioDeck "https://github.com/seamless-medley/medley/blob/main/packages/engine/src/Deck.cpp"
    click AudioProc "https://github.com/seamless-medley/medley/blob/main/packages/engine/src/PostProcessor.cpp"
    click Limiter "https://github.com/seamless-medley/medley/blob/main/packages/engine/src/LookAheadLimiter.cpp"
    click NodeMedley "https://github.com/seamless-medley/medley/tree/main/packages/node-medley/src"
    click MusicDB "https://github.com/seamless-medley/medley/blob/main/packages/core/src/library/music_db.ts"
    click FileScanner "https://github.com/seamless-medley/medley/blob/main/packages/core/src/library/scanner.ts"
    click SearchSystem "https://github.com/seamless-medley/medley/blob/main/packages/core/src/library/search.ts"
    click MetadataHandler "https://github.com/seamless-medley/medley/tree/main/packages/core/src/metadata"
    click Icecast "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/streaming/icy"
    click Shoutcast "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/streaming/shout"
    click BotCore "https://github.com/seamless-medley/medley/blob/main/packages/radio/src/discord/bot_main.ts"
    click Commands "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/discord/command/commands"
    click VoiceSystem "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/discord/voice"
    click MainUI "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/ui/app"
    click Components "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/ui/components"
    click AudioControls "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/ui/audio"
    click WebRTC "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/server/audio/rtc"
    click WebSocket "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/server/audio/ws"
    click CorePlayback "https://github.com/seamless-medley/medley/tree/main/packages/core/src/playout"
    click StationMgmt "https://github.com/seamless-medley/medley/tree/main/packages/core/src/station"
    click TrackMgmt "https://github.com/seamless-medley/medley/blob/main/packages/core/src/track.ts"
    click StationConfig "https://github.com/seamless-medley/medley/blob/main/packages/radio/src/config/station.ts"
    click StreamConfig "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/config/streaming"
    click Models "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/db/models"
    click MusicDBSystem "https://github.com/seamless-medley/medley/tree/main/packages/radio/src/db/musicdb"
```
