# hyeonsangjeon/youtube-dl-nas architecture

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

- Interactive diagram: https://gitdiagram.com/hyeonsangjeon/youtube-dl-nas
- Repository: https://github.com/hyeonsangjeon/youtube-dl-nas

## Overview

##### Main Components

a) Client-Side Components:
- Web Interface (Static Files)
- HTML Templates (static/template/)
- CSS Styles (static/css/)
- JavaScript Logic (static/js/, static/logical_js/)

b) Server-Side Components:
- Web Server (Bottle Framework)
- WebSocket Server (bottle_websocket/)
- Authentication System
- Download Queue Manager
- YouTube-DL Integration (yt-dlp)

c) Storage:
- Download Folder Volume
- Authentication Storage (Auth.json)

##### Component Relationships

- User authentication flow
- Video download request flow
- WebSocket real-time status updates
- File system interactions

- [Client Tier]
- ↕️ HTTPS/WSS
- [Application Tier]
- ↕️ File I/O
- [Storage Tier]

##### Component Details

Client Tier:
**[Web Browser]**
- Login Interface
- Download Queue UI
- WebSocket Client

Application Tier:
**[Bottle Web Server (Port 8080)]**
- Authentication Module
- Queue Manager
- WebSocket Server
- YouTube-DL Integration

Storage Tier:
**[Docker Volume]**
- Download Folder
- Auth.json

##### Additional Elements

- Version information and update scheduler
- Proxy support if enabled
- Supported video quality options

##### Interactions to Highlight

- Authentication flow
- Download request processing
- Queue management
- Real-time status updates via WebSocket
- File system operations

Key Technical Details to Include:
- Port mapping (8080 default)
- Volume mounting (/downfolder)
- WebSocket connection for real-time updates
- REST API endpoint (/youtube-dl/rest)
- Supported video formats and resolutions
- Daily update scheduler

This system design should clearly show how the application handles both authenticated users and API requests, manages the download queue, and provides real-time status updates through WebSocket connections, all while running within a Docker container with configurable environment variables.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
        Templates["Web Templates"]:::templates
        CSS["CSS Styles"]:::css
        JS["JavaScript Logic"]:::js
        Browser --> Templates
        Browser --> CSS
        Browser --> JS
    end

    subgraph "Application Server"
        WebServer["Bottle Web Server<br/>(Port 8080)"]:::server
        Auth["Authentication<br/>Module"]:::auth
        Queue["Queue Manager"]:::queue
        WSServer["WebSocket Server"]:::ws
        YTDLIntegration["YouTube-DL<br/>Integration"]:::ytdl
        UpdateScheduler["Update Scheduler"]:::updater

        WebServer --> Auth
        WebServer --> Queue
        WebServer --> WSServer
        Queue --> YTDLIntegration
        UpdateScheduler --> YTDLIntegration
    end

    subgraph Storage
        AuthStorage["Auth.json"]:::storage
        Downloads["Download Folder"]:::storage
    end

    subgraph "External Services"
        YouTube["YouTube"]:::external
    end

    Browser --"HTTPS"--> WebServer
    Browser --"WSS"--> WSServer
    Auth --> AuthStorage
    YTDLIntegration --> Downloads
    YTDLIntegration --> YouTube

    %% Click Events
    click Templates "https://github.com/hyeonsangjeon/youtube-dl-nas/tree/master/static/template/"
    click CSS "https://github.com/hyeonsangjeon/youtube-dl-nas/tree/master/static/css/"
    click JS "https://github.com/hyeonsangjeon/youtube-dl-nas/blob/master/static/logical_js/logic.js"
    click WSServer "https://github.com/hyeonsangjeon/youtube-dl-nas/tree/master/bottle_websocket/"
    click WebServer "https://github.com/hyeonsangjeon/youtube-dl-nas/blob/master/youtube-dl-server.py"
    click AuthStorage "https://github.com/hyeonsangjeon/youtube-dl-nas/blob/master/Auth.json"
    click Downloads "https://github.com/hyeonsangjeon/youtube-dl-nas/tree/master/downfolder/"
    click UpdateScheduler "https://github.com/hyeonsangjeon/youtube-dl-nas/blob/master/upd_schedule.py"

    %% Styling
    classDef templates fill:#9bc2cf
    classDef css fill:#a6e1ec
    classDef js fill:#b5d6e6
    classDef server fill:#82b366
    classDef auth fill:#97d077
    classDef queue fill:#8cbd7a
    classDef ws fill:#91c285
    classDef ytdl fill:#86b87f
    classDef updater fill:#a7d693
    classDef storage fill:#ffe6cc
    classDef external fill:#ff9999

    %% Legend
    subgraph Legend
        L1["Client Components"]:::templates
        L2["Server Components"]:::server
        L3["Storage"]:::storage
        L4["External Services"]:::external
    end
```
