# emberedsky/skydl architecture

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

- Interactive diagram: https://gitdiagram.com/emberedsky/skydl
- Repository: https://github.com/emberedsky/skydl

## Overview

a. User Interface Layer:
- Elements such as App.xaml, MainWindow.xaml, and HelpWindow.xaml. These define the UI and interaction side.

b. Application / Business Logic Layer:
- Core logic coded in files such as App.xaml.cs, MainWindow.xaml.cs, and HelpWindow.xaml.cs. Although all are in the solution root, these contain the code-behind that orchestrates the program’s behavior.
- This layer as the “Controller” handling inputs from the UI, managing workflows, and coordinating tasks.

c. External Dependencies / Services:
- That the business logic layer interacts with these tools by executing them (likely via command-line calls or process execution commands).

d. Configuration and Project Settings:
- Although less prominent in functionality, include your configuration files such as App.config and build/deployment artifacts (Skydl.csproj, Skydl.sln, packages.config). They represent setup and dependency management.

e. File System & Data Storage:
- Where downloaded or processed files are stored. A component representing file I/O or a “File Manager” module can be added to show data output and logging (for example, Msg to Empy.txt or similar artifacts).

##### Relationships and Interactions

- The UI layer sends user commands (download, convert, trim, etc.) to the Business Logic/Controller.
- The Controller then processes these actions by invoking the appropriate external services (youtube-dl, ffmpeg, AtomicParsley).
- Incoming data from the UI into the Business Logic.
- Outgoing commands from the Business Logic to each external dependency.
- Data flow from external tools (such as downloaded media or conversion output) back to the application for display or saving to disk.
- That some operations might require piping results between tools (e.g., trimming using ffmpeg on a file initially downloaded by youtube-dl).

##### Architectural Patterns and Design Principles

- External Process Invocation: Since core functionalities are delegated to external programs (youtube-dl, ffmpeg, etc.), show how the application acts as an orchestrator.
- Decoupled and Modular Design: Emphasize that each external dependency is treated as a separate component that could be updated independently (e.g., updating youtube-dl without affecting the main application logic).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "WPF UI Layer"
        UI1["App.xaml"]:::ui
        UI2["MainWindow.xaml"]:::ui
        UI3["HelpWindow.xaml"]:::ui
    end

    subgraph "Business Logic / Controller"
        BL1["App.xaml.cs"]:::logic
        BL2["MainWindow.xaml.cs"]:::logic
        BL3["HelpWindow.xaml.cs"]:::logic
    end

    subgraph "External Dependencies"
        ED1["youtube-dl"]:::external
        ED2["ffmpeg"]:::external
        ED3["AtomicParsley"]:::external
    end

    subgraph "Configuration & Settings"
        CFG1["App.config"]:::config
        CFG2["Skydl.csproj"]:::config
        CFG3["Skydl.sln"]:::config
        CFG4["packages.config"]:::config
    end

    FI["File Manager (Msg to Empy.txt)"]:::file

    %% UI sends commands to Business Logic
    UI2 -->|"command"| BL2

    %% Business Logic invokes External Dependencies
    BL2 -->|"invoke"| ED1
    BL2 -->|"invoke"| ED2
    BL2 -->|"invoke"| ED3

    %% External Dependencies return data to Business Logic
    ED1 -->|"data"| BL2
    ED2 -->|"data"| BL2
    ED3 -->|"data"| BL2

    %% Business Logic passes processed data to File I/O
    BL2 -->|"save"| FI

    %% Configuration supplies settings to Business Logic
    CFG1 -->|"config"| BL2
    CFG2 -->|"config"| BL2
    CFG3 -->|"config"| BL2
    CFG4 -->|"config"| BL2

    %% Click events for WPF UI Components
    click UI1 "https://github.com/emberedsky/skydl/blob/master/App.xaml"
    click UI2 "https://github.com/emberedsky/skydl/blob/master/MainWindow.xaml"
    click UI3 "https://github.com/emberedsky/skydl/blob/master/HelpWindow.xaml"

    %% Click events for Business Logic / Controller Components
    click BL1 "https://github.com/emberedsky/skydl/blob/master/App.xaml.cs"
    click BL2 "https://github.com/emberedsky/skydl/blob/master/MainWindow.xaml.cs"
    click BL3 "https://github.com/emberedsky/skydl/blob/master/HelpWindow.xaml.cs"

    %% Click events for Configuration & Settings Components
    click CFG1 "https://github.com/emberedsky/skydl/blob/master/App.config"
    click CFG2 "https://github.com/emberedsky/skydl/blob/master/Skydl.csproj"
    click CFG3 "https://github.com/emberedsky/skydl/blob/master/Skydl.sln"
    click CFG4 "https://github.com/emberedsky/skydl/blob/master/packages.config"

    %% Click event for File I/O / Data Storage Component
    click FI "https://github.com/emberedsky/skydl/blob/master/Msg to Empy.txt"

    %% Style Definitions
    classDef ui fill:#AEDFF7,stroke:#000,stroke-width:1px;
    classDef logic fill:#FFF59D,stroke:#000,stroke-width:1px;
    classDef external fill:#C8E6C9,stroke:#000,stroke-width:1px;
    classDef config fill:#E0E0E0,stroke:#000,stroke-width:1px;
    classDef file fill:#FFCC80,stroke:#000,stroke-width:1px;
```
