# fabricelacharme/karaboss architecture

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

- Interactive diagram: https://gitdiagram.com/fabricelacharme/karaboss
- Repository: https://github.com/fabricelacharme/karaboss

## Overview

##### Project type and purpose
- Karaboss is a Windows desktop application written in C#/.NET (WinForms).
- It serves as a MIDI karaoke player and a lightweight MIDI file editor/sequencer.
- It integrates several components: UI for playback and editing, an audio/MIDI engine, lyrics retrieval, playlist management, and an auto-updater.

##### File structure
- Top-level solution (Karaboss.sln) contains multiple .csproj projects.
- The Karaboss folder is the main executable. Inside Karaboss/ you find:
- Audio (AudioManager)
- Buttons, Dialogs, Display, Pages, Controls (UI)
- Chords, GuitarTraining, PianoRoll (musical features)
- Lrc, MP3, MP3GPlayer, Midi, KaraokeEffect (format support & effects)
- Utilities, Configuration (core services)
- Other folders are reusable class libraries or APIs (e.g., AzLyrics.Api, CDGNet, Hqub.MusicBrainz.API, Sanford.Multimedia.Midi, various custom UI controls).
- AutoUpdater is a separate executable/project for self-updating.
- Configuration files (app.config), resources (.resx), and third-party binaries (lame.exe) are also present.

##### README for additional insights
- Karaboss relies on the Sanford Multimedia MIDI toolkit for MIDI I/O and on Midi Sheet Music for score rendering.
- It supports lyrics display and editing, playlist management, background customization, and basic sequencing (score editing).

##### Main components and interactions
a. Presentation Layer (UI – WinForms)
- Player windows (frmExplorer, frmMp3Player, frmCDGPlayer, frmPianoRoll, etc.)
- Editor windows (frmChords, frmLrcGenerator, frmNoteEdit)
- Configuration dialogs, custom controls (buttons, sliders, sidebars)
b. Core Services (Business Logic)
- AudioManager: playback control, mixing
- Sequencer/Editor: score parsing, note insertion/deletion
- LyricsManager: LrcManager, web-API clients (AzLyrics, LyricsWikia, SongLyrics)
- PlaylistManager: load/save playlists, MRU
- File I/O: MIDI, MP3, CDG decoding (CDGNet), TagLibSharp for metadata
- Utilities: file helpers, serialization, settings
c. External Libraries
- Sanford.Multimedia.Midi: MIDI read/write, event dispatch
- Midi Sheet Music (embedded or interop)
- Hqub.MusicBrainz.API: metadata lookup
- Third-party binaries: lame.exe, mencoder.exe
d. Infrastructure
- Local filesystem: song files, settings, playlists
- App configuration (app.config, settings.settings)
- AutoUpdater service: checks remote version, downloads patches

##### Architectural patterns and design principles
- Layered architecture: Presentation → Core → External Services → Infrastructure
- Separation of concerns: UI code in forms and controls, business logic in manager classes, web access in API clients
- Plugin-style extensibility: many small class libraries for different concerns (controls, APIs)
- Event-driven playback and editing via the Sanford MIDI event system

##### Elements
- Presentation (blue)
- Core Services (green)
- External Libraries (orange)
- Infrastructure (gray)
- Clear labels: project names (.exe or .dll), major classes (AudioManager, LrcManager, Sequencer).

##### Detail without over-splitting
- Major modules and their interactions, but group similar controls or APIs into cohesive blocks.
- Special flows where web APIs fetch lyrics or where CDGNet decodes graphic data.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Central Executable
    KarabossExe["Karaboss.exe"]:::executable

    %% AutoUpdater Service
    AutoUpdaterExe["AutoUpdater.exe"]:::service
    AutoUpdaterExe -->|"updates"| KarabossExe

    %% Presentation Layer
    subgraph "Presentation Layer" 
        direction TB
        Explorer["frmExplorer"]:::ui
        Mp3Player["frmMp3Player"]:::ui
        CDGPlayer["frmCDGPlayer"]:::ui
        PianoRoll["frmPianoRoll"]:::ui
        Chords["frmChords"]:::ui
        LrcGenerator["frmLrcGenerator"]:::ui
        NoteEdit["frmNoteEdit"]:::ui
    end
    KarabossExe -->|"hosts UI"| Explorer
    KarabossExe --> Mp3Player
    KarabossExe --> CDGPlayer
    KarabossExe --> PianoRoll
    KarabossExe --> Chords
    KarabossExe --> LrcGenerator
    KarabossExe --> NoteEdit

    %% Core Services
    subgraph "Core Services"
        direction TB
        AudioManager["AudioManager"]:::core
        Sequencer["Sequencer"]:::core
        LrcManager["LrcManager"]:::core
        AzLyricsClient["AzLyricsWebClient"]:::core
        LyricsWikiaClient["LyricsWikiaWebClient"]:::core
        SongLyricsClient["SongLyricsWebClient"]:::core
        PlaylistControl["PlaylistsControl"]:::core
        PlaylistHelper["PlaylistGroupsHelper"]:::core
        CDGFileIO["CDGFile"]:::core
        TaglibSharp["TaglibSharp"]:::core
        FilesUtil["Files.cs"]:::core
        LyricsUtil["LyricsUtilities"]:::core
        MidiFileUtil["CreateNewMidiFile"]:::core
    end

    %% External Libraries & APIs
    subgraph "External Libraries"
        direction TB
        SanfordMidi["Sanford.Multimedia.Midi"]:::external
        MusicBrainz["Hqub.MusicBrainz.API"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        AppConfig["app.config"]:::infra
        ConfigForm["ConfigurationForm"]:::infra
        StringsResx["Strings.resx"]:::infra
    end

    %% External Binaries
    subgraph "External Binaries"
        direction TB
        LameExe["lame.exe"]:::binary
        MencoderExe["mencoder.exe"]:::binary
    end

    %% UI to Core interactions
    Explorer -->|"Play"| AudioManager
    Mp3Player --> AudioManager
    CDGPlayer --> AudioManager
    PianoRoll --> Sequencer
    Chords --> Sequencer
    LrcGenerator --> LrcManager
    NoteEdit --> Sequencer
    Explorer --> PlaylistControl

    %% Core to External Libraries
    Sequencer --> SanfordMidi
    LrcManager --> AzLyricsClient
    LrcManager --> LyricsWikiaClient
    LrcManager --> SongLyricsClient
    AudioManager --> LameExe
    AudioManager --> MencoderExe

    %% Core to Infrastructure
    AudioManager --> AppConfig
    PlaylistControl --> AppConfig
    LrcManager --> AppConfig
    FilesUtil --> AppConfig

    %% Core to File I/O
    CDGFileIO --> SanfordMidi
    TaglibSharp --> Mp3Player

    %% Core Utilities
    FilesUtil -->|"file helpers"| CDGFileIO
    LyricsUtil --> LrcManager
    MidiFileUtil --> Sequencer

    %% Infra resources
    ConfigForm --> AppConfig
    StringsResx --> ConfigForm

    %% Click Events
    click KarabossExe "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Karaboss.csproj"
    click AutoUpdaterExe "https://github.com/fabricelacharme/karaboss/blob/master/AutoUpdater/AutoUpdater.csproj"
    click Explorer "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/frmExplorer.cs"
    click Explorer "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/frmExplorer.Designer.cs"
    click Mp3Player "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/MP3/Mp3Player/frmMp3Player.cs"
    click Mp3Player "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/MP3/Mp3Player/frmMp3Player.Designer.cs"
    click CDGPlayer "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/MP3GPlayer/frmCDGPlayer.cs"
    click CDGPlayer "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/MP3GPlayer/frmCDGPlayer.Designer.cs"
    click PianoRoll "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/frmPianoRoll.cs"
    click PianoRoll "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/frmPianoRoll.Designer.cs"
    click Chords "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Chords/frmChords.cs"
    click Chords "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Chords/frmChords.Designer.cs"
    click LrcGenerator "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Lrc/frmLrcGenerator.cs"
    click LrcGenerator "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Lrc/frmLrcGenerator.Designer.cs"
    click NoteEdit "https://github.com/fabricelacharme/karaboss/blob/master/Sanford.Multimedia.Midi/Score/UI/frmNoteEdit.cs"
    click NoteEdit "https://github.com/fabricelacharme/karaboss/blob/master/Sanford.Multimedia.Midi/Score/UI/frmNoteEdit.Designer.cs"
    click AudioManager "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Audio/AudioManager.cs"
    click Sequencer "https://github.com/fabricelacharme/karaboss/blob/master/Sanford.Multimedia.Midi/Sequencing/Sequencer.cs"
    click LrcManager "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Lrc/LrcManager.cs"
    click AzLyricsClient "https://github.com/fabricelacharme/karaboss/blob/master/AzLyrics.Api/AzLyricsWebClient.cs"
    click LyricsWikiaClient "https://github.com/fabricelacharme/karaboss/blob/master/LyricsWikia.Api/LyricsWikiaWebClient.cs"
    click SongLyricsClient "https://github.com/fabricelacharme/karaboss/blob/master/SongLyrics.Api/SongLyricsWebClient.cs"
    click PlaylistControl "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Pages/PlaylistsControl/PlaylistsControl.cs"
    click PlaylistHelper "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Pages/PlaylistsControl/PlaylistGroupsHelper.cs"
    click CDGFileIO "https://github.com/fabricelacharme/karaboss/blob/master/CDGNet/CDGFile.cs"
    click TaglibSharp "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/MP3/TagLibSharp/TaglibSharp.xml"
    click FilesUtil "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Utilities/IO/Files.cs"
    click LyricsUtil "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Utilities/Lyrics/LyricsUtilities.cs"
    click MidiFileUtil "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Utilities/MidiFile/CreateNewMidiFile.cs"
    click SanfordMidi "https://github.com/fabricelacharme/karaboss/blob/master/Sanford.Multimedia.Midi/Sanford.Multimedia.Midi.csproj"
    click MusicBrainz "https://github.com/fabricelacharme/karaboss/blob/master/Hqub.MusicBrainz.API/Hqub.MusicBrainz.API.csproj"
    click AppConfig "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/app.config"
    click ConfigForm "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Configuration/ConfigurationForm.cs"
    click StringsResx "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Resources/Localization/Strings.resx"
    click LameExe "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Mp3 Video/Lame/lame.exe"
    click MencoderExe "https://github.com/fabricelacharme/karaboss/blob/master/Karaboss/Mp3 Video/Lame/mencoder.exe"

    %% Styles
    classDef executable fill:#AED6F1,stroke:#2E86C1,stroke-width:1px
    classDef service fill:#D2B4DE,stroke:#8E44AD,stroke-width:1px
    classDef ui fill:#D6EAF8,stroke:#2980B9,stroke-width:1px
    classDef core fill:#D5F5E3,stroke:#27AE60,stroke-width:1px
    classDef external fill:#F9E79F,stroke:#B7950B,stroke-width:1px
    classDef infra fill:#E5E7E9,stroke:#7B7D7D,stroke-width:1px
    classDef binary fill:#FADBD8,stroke:#C0392B,stroke-width:1px
```
