# umlx5h/llplayer architecture

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

- Interactive diagram: https://gitdiagram.com/umlx5h/llplayer
- Repository: https://github.com/umlx5h/llplayer

## Overview

##### Project type and purpose
- LLPlayer is a full-stack, desktop media player written in C#/WPF focused on language learning.
- It combines a rich WPF UI (dual subtitles, sidebar, word lookup) with a core media engine (FlyleafLib) that drives playback, ASR/OCR, translation, and plugin support.

##### File structure
- Top-level solution (`LLPlayer.slnx`) contains three main folders:
- **LLPlayer/** – The WPF application (UI, ViewModels, Services, Assets, Themes)
- **FlyleafLib/** – Core playback engine and media framework (wrappers around FFmpeg, decoders, demuxers, renderers, engine plugins)
- **Plugins/** – External plugins (e.g., YoutubeDL)
- There’s also a **WpfColorFontDialog/** project (reusable font dialog control) and **FlyleafLibTests/** for unit tests.
- Config files (`*.csproj`, `.github/`, CI workflows) and native binaries (FFmpeg, whisper.cpp, yt-dlp.exe) live at the root or inside respective folders.

##### Key insights from README
- Uses MVVM pattern: Views ↔ ViewModels ↔ Services.
- Services layer handles AppConfig, plugin loading, Whisper ASR, Tesseract OCR, translation engine integrations (OpenAI, Google, DeepL), subtitle download/upload, and SRT export.
- The FlyleafLib provides a modular media pipeline: MediaContext → Demuxer → Decoder → Frame → Renderer.
- Plugin architecture: FlyleafLib.Plugins and Plugins/YoutubeDL support extensibility.
- External dependencies: FFmpeg, whisper.cpp / faster-whisper, Tesseract OCR, translation APIs, yt-dlp.

##### Essential architectural elements
- Do not over-complicate: focus on core layers, media pipeline, service orchestration, plugin mechanism, and external dependencies.
- Clearly separate UI concerns (dual subtitles, sidebar, word lookup) from playback engine concerns (decoding, rendering, ASR/OCR).
- Model download/storage (Whisper models, Tesseract data, SRT export) as part of the Services layer.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["UI / Views"]:::frontend
        Controls["Controls"]:::frontend
        Resources["Resources & Themes"]:::frontend
        Converters["Converters"]:::frontend
        Extensions["Extensions"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        VMs["ViewModels"]:::application
        Services["Services"]:::application
    end

    %% Core Engine Layer
    subgraph "Core Engine Layer"
        Engine["FlyleafLib Engine"]:::core
        MediaFramework["MediaFramework"]:::core
        MediaPlayer["MediaPlayer & Translation"]:::core
        ControlsCore["FlyleafLib WPF Controls"]:::core
        PluginsCore["FlyleafLib Plugins"]:::core
        Utils["Utilities"]:::core
        ThemesCore["Engine Themes"]:::core
    end

    %% External & Infrastructure Layer
    subgraph "Infrastructure & External"
        FFmpeg["FFmpeg"]:::external
        Whisper["Whisper Engines"]:::external
        Tesseract["Tesseract OCR"]:::external
        TranslationAPIs["Translation APIs"]:::external
        YTDLP["yt-dlp"]:::external
        DotNet[".NET Runtime"]:::external
        FontDialog["WpfColorFontDialog"]:::external
    end

    %% Relationships
    User[/"User"/] -->|playback control| UI
    UI -->|data binding| VMs
    VMs -->|commands| Services
    Services -->|API calls| Engine
    Engine -->|media pipeline| MediaFramework
    MediaFramework -->|renders frames| Engine
    Engine -->|plugin discovery| PluginsCore
    PluginsCore -->|external plugin| YTDLP
    Engine -->|WPF host| ControlsCore
    Services -->|translate requests| TranslationAPIs
    Engine -->|decode/demux| FFmpeg
    Engine -->|ASR| Whisper
    Engine -->|OCR| Tesseract
    FontDialog -->|UI dialog| UI
    DotNet -->|runs app| UI
    DotNet -->|runs engine| Engine

    %% Click Events
    click UI "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/Views"
    click Controls "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/Controls"
    click Resources "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/Resources"
    click Converters "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/Converters"
    click Extensions "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/Extensions"
    click VMs "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/ViewModels"
    click Services "https://github.com/umlx5h/llplayer/tree/main/LLPlayer/Services"
    click Engine "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/Engine"
    click MediaFramework "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/MediaFramework"
    click MediaPlayer "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/MediaPlayer"
    click ControlsCore "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/Controls/WPF"
    click PluginsCore "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/Plugins"
    click Utils "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/Utils"
    click ThemesCore "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/Themes"
    click YTDLP "https://github.com/umlx5h/llplayer/tree/main/Plugins/YoutubeDL"
    click FFmpeg "https://github.com/umlx5h/llplayer/tree/main/FFmpeg"
    click Whisper "https://github.com/umlx5h/llplayer/blob/main/FlyleafLib/Engine/WhisperConfig.cs"
    click Tesseract "https://github.com/umlx5h/llplayer/blob/main/FlyleafLib/Engine/TesseractModel.cs"
    click TranslationAPIs "https://github.com/umlx5h/llplayer/tree/main/FlyleafLib/MediaPlayer/Translation"
    click FontDialog "https://github.com/umlx5h/llplayer/tree/main/WpfColorFontDialog"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,stroke-width:2px
    classDef application fill:#d4edda,stroke:#28a745,stroke-width:2px
    classDef core fill:#ffe5b4,stroke:#ff9933,stroke-width:2px
    classDef external fill:#e2e3e5,stroke:#6c757d,stroke-width:2px
```
