# benexl/yt-x architecture

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

- Interactive diagram: https://gitdiagram.com/benexl/yt-x
- Repository: https://github.com/benexl/yt-x

## Overview

##### Main Components

a) Core Application Layer:
- Terminal UI Interface (using fzf/rofi)
- Command Processing Module
- Configuration Manager
- Extension System

b) External Services Layer:
- YouTube API Integration (via yt-dlp)
- Local File System Interface
- Media Player Integration (mpv/vlc)

c) Data Management Layer:
- Custom Playlists Storage
- History & Recent Tracks
- Saved Channels/Videos
- Configuration Files

**┌─────────────────────────────────────────┐**
- User Interface             │
- (Terminal/fzf/rofi/gum interfaces)    │
- ┤
- Core Application              │
- ┌──────────┐  ┌──────────┐  ┌──────┐  │
- Command   │  │Extension │  │Config│  │
- Processor │  │Manager   │  │Manager│  │
- ┘  └──────────┘  └──────┘  │
- ┤
- External Integrations           │
- ┌──────────┐  ┌──────────┐  ┌──────┐  │
- yt-dlp   │  │   mpv    │  │ curl │  │
- Interface │  │Interface  │  │ API  │  │
- ┘  └──────────┘  └──────┘  │
- ┤
- Data Storage                 │
- (Playlists, History, Config)        │
- ┘

##### Important Flows to Highlight

a) User Interaction Flow:
- How user commands flow from UI through the command processor
- How results are displayed back to the user

b) Media Playback Flow:
- Demonstrate the path from video selection to playback
- Integration with mpv/vlc

c) Extension System Flow:
- How extensions integrate with the core system
- Extension loading and execution paths

##### Implementation Details

- File system structure for configurations (~/.config/yt-x/)
- External dependency connections
- Data flow between components
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef ui fill:#FF9900,stroke:#333,stroke-width:2px
    classDef core fill:#3498DB,stroke:#333,stroke-width:2px
    classDef external fill:#2ECC71,stroke:#333,stroke-width:2px
    classDef data fill:#9B59B6,stroke:#333,stroke-width:2px
    classDef config fill:#95A5A6,stroke:#333,stroke-width:2px

    %% User Interface Layer
    subgraph UI
        Terminal["Terminal Interface"]:::ui
        FZF["FZF Interface"]:::ui
        Rofi["Rofi Interface"]:::ui
        Gum["Gum Interface"]:::ui
    end

    %% Core Application Layer
    subgraph Core
        CmdProc["Command Processor"]:::core
        ExtMgr["Extension Manager"]:::core
        click ExtMgr "https://github.com/Benexl/yt-x/tree/master/extensions/"
        ConfigMgr["Configuration Manager"]:::core
        click ConfigMgr "https://github.com/Benexl/yt-x/blob/master/flake.nix"
        CoreApp["Core Application"]:::core
        click CoreApp "https://github.com/Benexl/yt-x/tree/master/yt-x"
    end

    %% External Integrations Layer
    subgraph External
        YTDlp["yt-dlp Interface"]:::external
        MPV["MPV Interface"]:::external
        Curl["Curl API"]:::external
    end

    %% Data Storage Layer
    subgraph Data
        Playlists["Custom Playlists"]:::data
        History["History & Recent"]:::data
        Config["Configuration Files"]:::data
    end

    %% Extension System
    subgraph Extensions
        ExtSystem["Extension System"]:::core
        click ExtSystem "https://github.com/Benexl/yt-x/tree/master/extensions/"
        ExampleExt["Example Extension"]:::core
        click ExampleExt "https://github.com/Benexl/yt-x/tree/master/extensions/example/"
    end

    %% Relationships
    Terminal --> FZF
    Terminal --> Rofi
    Terminal --> Gum
    
    FZF --> CmdProc
    Rofi --> CmdProc
    Gum --> CmdProc
    
    CmdProc --> CoreApp
    CoreApp --> ExtMgr
    CoreApp --> ConfigMgr
    
    ExtMgr --> ExtSystem
    ExtSystem --> ExampleExt
    
    CoreApp --> YTDlp
    CoreApp --> MPV
    CoreApp --> Curl
    
    CoreApp --> Playlists
    CoreApp --> History
    ConfigMgr --> Config

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Core Components"]:::core
        L3["External Services"]:::external
        L4["Data Storage"]:::data
        L5["Configuration"]:::config
    end
```
