# bogdanbto/youtubeplaylistdownloader architecture

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

- Interactive diagram: https://gitdiagram.com/bogdanbto/youtubeplaylistdownloader
- Repository: https://github.com/bogdanbto/youtubeplaylistdownloader

## Overview

##### Project type and purpose
- This is a desktop full-stack application (WPF/.NET) whose sole purpose is to download YouTube videos, playlists, or channels, convert them to various formats, tag them automatically, and keep itself up to date.

##### File structure
- Top-level folders and files:
- YoutubePlaylistDownloader/ – contains the entire WPF application
- YPDSetup/ – Inno Setup installer scripts
- README.md, LICENSE, solution (.sln), project (.csproj)
- Inside YoutubePlaylistDownloader/:
- XAML views (MainPage.xaml, DownloadPage.xaml, About.xaml, Settings.xaml, etc.)
- Code-behind (.xaml.cs) for each view
- Objects/ – domain models (DownloadSettings, FullPlaylist, QueuedDownload, etc.)
- Utilities/ – helper classes (YoutubeHelpers, ExtensionMethods)
- appsettings.json & config files – version info, update URLs
- No external database; data persistence relies on local settings and file system.

##### README
- Confirms it’s open-source, ad-free, multi-format conversion, theming, multi-language support, and has an auto-update mechanism.

a. Main components
1. User Interface Layer (WPF XAML + code-behind)
2. ViewModel/Controller Layer (DownloadPageController, SettingsController patterns implied in code-behind)
3. Core Download Engine (Objects classes + Utilities.YoutubeHelpers)
4. Conversion Module (FFmpeg or internal converter invoked by VideoQualityConverter)
5. Update Service (checks latestVersion*.txt & installer URLs)
6. Persistence & Configuration (appsettings.json, Settings.settings, local file writes)
7. External Services
– YouTube web endpoints / APIs
– GitHub releases (for update checks)

b. Relationships & interactions
– UI → ViewModel/Controller: user triggers “Download” or “Settings”
– Controller → Download Engine: enqueues download tasks (QueuedDownload, FixedQueue)
– Download Engine ↔ YouTube API: fetches video/playlist metadata and streams (ProgressStream)
– Download Engine → Conversion Module: post-processing to convert format & apply tags
– Engine/Converter → File System: writes video files to user’s directory
– Update Service → GitHub Releases endpoint: polls for new version, triggers YPDSetup installer

c. Architectural patterns
– MVVM-style division (Views in XAML, code-behind acting as ViewModels/controllers)
– Producer-consumer queue (FixedQueue & QueuedDownload) for parallel downloads
– Helper/util classes isolate platform-specific API calls (YoutubeHelpers)
– Resource bundles for multi-language support (Languages/*.xaml)

d. Key technologies & frameworks
– .NET 6+ (C#) with WPF
– XAML for UI and theming
– Inno Setup for installer (YPDSetup)
– JSON & .config for settings and versioning
– Potential FFmpeg integration (invoked via VideoQualityConverter)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MainPage["MainPage.xaml/.cs"]:::ui
        DownloadPageUI["DownloadPage.xaml/.cs"]:::ui
        AboutPage["About.xaml/.cs"]:::ui
        SettingsPage["Settings.xaml/.cs"]:::ui
        HelpPage["Help.xaml/.cs"]:::ui
        DownloadSettingsControlUI["DownloadSettingsControl.xaml/.cs"]:::ui
        DownloadUpdateUI["DownloadUpdate.xaml/.cs"]:::ui
        SkeletonPage["Skeleton.xaml/.cs"]:::ui
    end

    %% Controller Layer
    subgraph "Controller Layer"
        direction TB
        DownloadPageController["DownloadPage.xaml.cs"]:::controller
        SettingsController["Settings.xaml.cs"]:::controller
        DownloadSettingsControlController["DownloadSettingsControl.xaml.cs"]:::controller
        DownloadUpdateController["DownloadUpdate.xaml.cs"]:::controller
        MainPageController["MainPage.xaml.cs"]:::controller
    end

    %% Core Download Engine
    subgraph "Core Download Engine"
        direction TB
        DownloadSettingsObj["DownloadSettings.cs"]:::core
        FixedQueue["FixedQueue.cs"]:::core
        FullPlaylist["FullPlaylist.cs"]:::core
        IDownload["IDownload.cs"]:::core
        ProgressStream["ProgressStream.cs"]:::core
        QueuedDownload["QueuedDownload.cs"]:::core
    end

    %% Conversion Module
    VideoQualityConverter["VideoQualityConverter.cs"]:::conv

    %% Persistence & Configuration
    subgraph "Persistence & Configuration"
        direction TB
        FileSystem["Local File System"]:::persist
        AppSettings["appsettings.json"]:::persist
        SettingsConfig["Settings.settings / Settings.Designer.cs"]:::persist
        SettingsObj["Settings.cs"]:::persist
        AppConfig["App.config"]:::persist
    end

    %% Update Service
    subgraph "Update Service"
        direction TB
        UpdateUI["DownloadUpdate UI"]:::update
        LatestVersion["latestVersion.txt"]:::update
        LatestLink["latestVersionLink.txt"]:::update
        LatestRev["latestVersionWithRevision.txt"]:::update
        InstallerScript["YPDSetup.iss"]:::update
        InstallerLoc["ChineseSimplified.isl"]:::update
    end

    %% External Services
    subgraph "External Services"
        direction TB
        YouTubeAPI["YouTube API"]:::external
        GitHubReleases["GitHub Releases"]:::external
    end

    %% Flows
    MainPage -->|1:Navigate / Download| DownloadPageController
    DownloadPageUI -->|1| DownloadPageController
    SettingsPage -->|1| SettingsController
    DownloadSettingsControlUI -->|1| DownloadSettingsControlController
    DownloadUpdateUI -->|1| DownloadUpdateController
    MainPageUI -->|1| MainPageController

    DownloadPageController -->|Enqueue Download| DownloadSettingsObj
    DownloadSettingsObj --> FixedQueue
    FixedQueue --> QueuedDownload
    QueuedDownload --> ProgressStream
    ProgressStream --> FullPlaylist
    QueuedDownload --> YouTubeAPI
    QueuedDownload --> DownloadSettingsObj

    %% Download flow to conversion and persistence
    QueuedDownload -->|2:Stream| VideoQualityConverter
    VideoQualityConverter -->|2:Convert & Tag| FileSystem
    FileSystem --> AppSettings
    FileSystem --> SettingsConfig
    FileSystem --> SettingsObj
    FileSystem --> AppConfig

    %% Update flow
    UpdateUI -->|Check Update| LatestVersion
    UpdateUI --> LatestLink
    UpdateUI --> LatestRev
    LatestVersion --> GitHubReleases
    GitHubReleases --> InstallerScript
    InstallerScript --> InstallerLoc

    %% External Service interactions
    ProgressStream --> YouTubeAPI
    UpdateUI --> GitHubReleases

    %% Click Events - UI Layer
    click MainPage "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/MainPage.xaml"
    click DownloadPageUI "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/DownloadPage.xaml"
    click AboutPage "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/About.xaml"
    click SettingsPage "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Settings.xaml"
    click HelpPage "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Help.xaml"
    click DownloadSettingsControlUI "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/DownloadSettingsControl.xaml"
    click DownloadUpdateUI "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/DownloadUpdate.xaml"
    click SkeletonPage "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Skeleton.xaml"

    %% Click Events - Controller Layer
    click DownloadPageController "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/DownloadPage.xaml.cs"
    click SettingsController "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Settings.xaml.cs"
    click DownloadSettingsControlController "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/DownloadSettingsControl.xaml.cs"
    click DownloadUpdateController "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/DownloadUpdate.xaml.cs"
    click MainPageController "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/MainPage.xaml.cs"

    %% Click Events - Core Download Engine
    click DownloadSettingsObj "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/DownloadSettings.cs"
    click FixedQueue "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/FixedQueue.cs"
    click FullPlaylist "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/FullPlaylist.cs"
    click IDownload "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/IDownload.cs"
    click ProgressStream "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/ProgressStream.cs"
    click QueuedDownload "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/QueuedDownload.cs"

    %% Click Events - Conversion Module
    click VideoQualityConverter "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/VideoQualityConverter.cs"

    %% Click Events - Persistence & Configuration
    click AppSettings "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/appsettings.json"
    click SettingsConfig "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Properties/Settings.settings"
    click SettingsObj "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Objects/Settings.cs"
    click AppConfig "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/App.config"

    %% Click Events - Update Service
    click LatestVersion "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/latestVersion.txt"
    click LatestLink "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/latestVersionLink.txt"
    click LatestRev "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/latestVersionWithRevision.txt"
    click InstallerScript "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YPDSetup/YPDSetup.iss"
    click InstallerLoc "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YPDSetup/ChineseSimplified.isl"

    %% Click Events - Utilities & Resources
    click YoutubeHelpers "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Utilities/YoutubeHelpers.cs"
    click ExtensionMethods "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Utilities/ExtensionMethods.cs"
    click EnglishLang "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Languages/English.xaml"
    click RussianLang "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Languages/Русский.xaml"
    click LanguagesList "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Languages/LanguagesList.xaml"
    click Styles "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Resources/Styles.xaml"
    click Icons "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Resources/Icons.xaml"
    click IconsNonShared "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/Resources/IconsNonShared.xaml"
    click ProjectFile "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader/YoutubePlaylistDownloader.csproj"
    click SolutionFile "https://github.com/bogdanbto/youtubeplaylistdownloader/blob/master/YoutubePlaylistDownloader.sln"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef controller fill:#d4edda,stroke:#28a745,color:#000;
    classDef core fill:#ffe5b4,stroke:#ff8c00,color:#000;
    classDef conv fill:#fff3cd,stroke:#ffcd39,color:#000;
    classDef persist fill:#e2e3e5,stroke:#6c757d,color:#000;
    classDef update fill:#f8d7da,stroke:#dc3545,color:#000;
    classDef external fill:#d1ecf1,stroke:#17a2b8,color:#000;
```
