# kurtbestor/hitomi-downloader architecture

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

- Interactive diagram: https://gitdiagram.com/kurtbestor/hitomi-downloader
- Repository: https://github.com/kurtbestor/hitomi-downloader

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Core Application Layer
- Download Manager Engine
- User Interface (with dark mode support)
- Task Management System
- Clipboard Monitor
- Configuration Manager

b) Extractor Layer
- Website-specific Downloaders (70+ specialized downloaders)
- Generic Downloaders (M3U8, Torrent, File)
- Protocol Handlers

c) External Integration Layer
- Browser Extension Interface
- Script Plugin System
- Translation System

**┌─ User Interface Layer ─────────────────────┐**
- GUI Components                          │
- Dark/Light Theme                        │
- Multi-language Support                  │
- ┬────────────────────────┘
- ↓
**┌─ Core Services Layer ───────────────────────┐**
- ┌─ Task Management ─┐ ┌─ Download Engine ─┐│
- Queue System    │ │ - Thread Pool     ││
- Status Tracking │ │ - Speed Control   ││
- ┘ └─────────────────┘ ││
- ┌─ Clipboard Monitor┐ ┌─ Config Manager ─┐││
- ┘ └─────────────────┘ ││
- ┬────────────────────────┘
- ↓
**┌─ Extractor Layer ──────────────────────────┐**
- ┌─ Site Specific ─┐ ┌─ Generic ─────────┐ │
- YouTube       │ │ - M3U8            │ │
- Pixiv        │ │ - Torrent         │ │
- Twitter      │ │ - Direct File     │ │
- ┘ └─────────────────┘ │
- ┬────────────────────────┘
- ↓
**┌─ External Integration Layer ───────────────┐**
- Browser Extension API                   │
- Plugin System                           │
- Translation Services                    │
- ┘

##### Important Elements to Highlight

- Multi-threading capability (24 threads per task)
- Speed limiting mechanism
- Plugin architecture
- Translation system (supporting 10+ languages)
- Clipboard monitoring system
- Task organization system

##### Data Flow Indicators

Following flows:
- User input → Task Management
- Task Management → Download Engine
- Download Engine → Extractors
- Extractors → External Services
- Configuration → All Components

##### Technical Details

- Thread pool management
- Speed control mechanism
- File handling system
- Protocol support
- Website-specific API integrations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        GUI["GUI Components"]
        Theme["Dark/Light Theme"]
        Lang["Multi-language Support"]:::translation
    end

    subgraph Core["Core Services Layer"]
        subgraph TaskMgmt["Task Management"]
            Queue["Queue System"]
            Status["Status Tracking"]
        end
        
        subgraph DLEngine["Download Engine"]
            ThreadPool["Thread Pool"]
            SpeedCtrl["Speed Control"]
        end
        
        ClipMon["Clipboard Monitor"]
        ConfigMgr["Configuration Manager"]
    end

    subgraph Extractors["Extractor Layer"]
        subgraph SiteSpec["Site-Specific Downloaders"]
            YouTube["YouTube"]:::extractor
            Pixiv["Pixiv"]:::extractor
            Twitter["Twitter"]:::extractor
        end
        
        subgraph Generic["Generic Downloaders"]
            M3U8["M3U8"]:::generic
            Torrent["Torrent"]:::generic
            File["Direct File"]:::generic
        end
        
        ProtocolH["Protocol Handlers"]:::protocol
    end

    subgraph External["External Integration Layer"]
        BrowserExt["Browser Extension API"]
        PluginSys["Plugin System"]
        TransSys["Translation System"]:::translation
    end

    %% Connections
    UI --> Core
    Core --> Extractors
    Extractors --> External

    %% Internal Connections
    GUI --> Theme
    GUI --> Lang
    Queue --> Status
    ThreadPool --> SpeedCtrl
    ClipMon --> Queue
    ConfigMgr --> DLEngine

    %% Style Definitions
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef extractor fill:#e67e22,stroke:#d35400,color:white
    classDef generic fill:#f1c40f,stroke:#f39c12,color:white
    classDef protocol fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef translation fill:#9b59b6,stroke:#8e44ad,color:white

    %% Apply Styles
    class GUI,Theme ui
    class Queue,Status,ThreadPool,SpeedCtrl,ClipMon,ConfigMgr core
    class YouTube,Pixiv,Twitter extractor
    class M3U8,Torrent,File generic
    class Lang,TransSys translation

    %% Click Events
    click YouTube "https://github.com/KurtBestor/Hitomi-Downloader/blob/master/src/extractor/youtube_downloader.py"
    click Pixiv "https://github.com/KurtBestor/Hitomi-Downloader/blob/master/src/extractor/pixiv_downloader.py"
    click Twitter "https://github.com/KurtBestor/Hitomi-Downloader/blob/master/src/extractor/twitter_downloader.py"
    click M3U8 "https://github.com/KurtBestor/Hitomi-Downloader/blob/master/src/extractor/m3u8_downloader.py"
    click Torrent "https://github.com/KurtBestor/Hitomi-Downloader/blob/master/src/extractor/torrent_downloader.py"
    click File "https://github.com/KurtBestor/Hitomi-Downloader/blob/master/src/extractor/file_downloader.py"
    click TransSys "https://github.com/KurtBestor/Hitomi-Downloader/tree/master/translation"
    click Lang "https://github.com/KurtBestor/Hitomi-Downloader/tree/master/translation"
    click ProtocolH "https://github.com/KurtBestor/Hitomi-Downloader/tree/master/src/extractor"
```
