# fiso64/slsk-batchdl architecture

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

- Interactive diagram: https://gitdiagram.com/fiso64/slsk-batchdl
- Repository: https://github.com/fiso64/slsk-batchdl

## Overview

##### Main Components Identification

a) Core Components:
- Input Processing System (Extractors)
- Search Engine
- Download Manager
- File Management System
- Configuration Manager

b) External Services:
- Soulseek Network
- Spotify API
- YouTube API
- Bandcamp Integration
- yt-dlp (optional component)

**┌─ Input Layer ─────────────────────────┐**
- CSV Files    - Spotify              │
- YouTube      - Bandcamp             │
- Text Files   - Direct Search        │
- ┬───────────────────┘
- ↓
**┌─ Processing Layer ────────────────────┐**
- ┌─ Extractors ──┐  ┌─ Search ───────┐│
- Spotify     │  │ - Query Builder││
- YouTube     │→ │ - Rate Limiter ││
- Bandcamp    │  │ - Result Filter││
- CSV         │  └───────────────┘ │
- ┘         ↓          │
- ┌─ Download Manager ─────────────────┐│
- Concurrent Downloads            ││
- Progress Tracking               ││
- File Validation                 ││
- ┘│
- ┬───────────────────┘
- ↓
**┌─ Output Layer ──────────────────────┐**
- File System Management            │
- M3U Playlist Generation          │
- Index File Management            │
- ┘

##### Important Relationships

- Bidirectional connection between Search Engine and Soulseek Network
- One-way flow from Input Layer through Processing to Output
- Configuration Manager's influence on all components
- External API connections for Spotify, YouTube, and Bandcamp

##### Implementation Details

Technical aspects:
- C# implementation (.NET)
- File format handling (mp3, flac, etc.)
- Concurrent download management
- Configuration file locations
- Docker volume mappings

##### Operational Flows

Key processes:
- Search and download workflow
- Album download process
- Aggregate mode operation
- File validation and conditions checking

This design captures both the high-level architecture and the important implementation details while remaining clear and maintainable. It reflects the project's focus on flexibility in input sources and robust download management while adhering to Soulseek's constraints.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        CSV["CSV Files"]
        SP["Spotify"]:::ext
        YT["YouTube"]:::ext
        BC["Bandcamp"]:::ext
        TXT["Text Files"]
        DS["Direct Search"]
    end

    subgraph Processing
        subgraph Extractors
            SPE["Spotify Extractor"]:::code
            YTE["YouTube Extractor"]:::code
            BCE["Bandcamp Extractor"]:::code
            CSVE["CSV Extractor"]:::code
        end

        subgraph SearchEngine
            QB["Query Builder"]
            RL["Rate Limiter"]:::code
            RF["Result Filter"]
            SE["Search Engine"]:::code
        end

        subgraph DownloadManager
            CD["Concurrent Downloads"]:::code
            PT["Progress Tracking"]
            FV["File Validation"]:::code
        end
    end

    subgraph Output
        FSM["File System Manager"]:::code
        M3U["M3U Playlist Generator"]:::code
        IDX["Index File Manager"]
    end

    subgraph Configuration
        CM["Configuration Manager"]:::code
        FC["File Conditions"]:::code
        UT["Utilities"]:::code
    end

    subgraph ExternalServices
        SN["Soulseek Network"]:::ext
        SAPI["Spotify API"]:::ext
        YTAPI["YouTube API"]:::ext
        BCAPI["Bandcamp API"]:::ext
    end

    %% Connections
    CSV --> CSVE
    SP --> SPE
    YT --> YTE
    BC --> BCE
    TXT --> SE
    DS --> SE

    SPE --> SE
    YTE --> SE
    BCE --> SE
    CSVE --> SE

    SE <--> RL
    RL --> QB
    QB --> RF
    RF --> CD

    CD --> FSM
    FSM --> M3U
    FSM --> IDX

    SE <--> SN
    SPE <--> SAPI
    YTE <--> YTAPI
    BCE <--> BCAPI

    CM --> Processing
    CM --> Output
    FC --> FV
    UT --> Processing

    %% Click Events
    click SPE "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Extractors/Spotify.cs"
    click YTE "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Extractors/YouTube.cs"
    click BCE "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Extractors/Bandcamp.cs"
    click CSVE "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Extractors/Csv.cs"
    click SE "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Search.cs"
    click CD "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Download.cs"
    click FSM "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/FileManager.cs"
    click FV "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/FileSkipper.cs"
    click CM "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Config.cs"
    click RL "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Utilities/RateLimitedSemaphore.cs"
    click M3U "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/M3uEditor.cs"
    click FC "https://github.com/fiso64/slsk-batchdl/blob/master/slsk-batchdl/Models/FileConditions.cs"
    click UT "https://github.com/fiso64/slsk-batchdl/tree/master/slsk-batchdl/Utilities"

    %% Styles
    classDef ext fill:#90EE90
    classDef code fill:#ADD8E6
    classDef input fill:#FFFFE0
    classDef output fill:#FFFFE0

    %% Legend
    subgraph Legend
        L1["External Services"]:::ext
        L2["Code Components"]:::code
        L3["Input/Output"]:::input
    end
```
