# clinton-abraham/tele-leechx architecture

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

- Interactive diagram: https://gitdiagram.com/clinton-abraham/tele-leechx
- Repository: https://github.com/clinton-abraham/tele-leechx

## Overview

##### Project type and purpose
- Tele-LeechX is a Python-based, event-driven Telegram Bot (built on Pyrogram) whose purpose is to accept links/torrents/YouTube playlists from users, download or process them (via Aria2, youtube_dl, Real-Debrid, ffmpeg), and then re-upload to Telegram or external cloud storage (via Rclone). It is packaged to run on Heroku, Docker, or any Linux server.

##### File structure
- **Root**
- Dockerfile, heroku.yml, app.json, start.sh – deployment scripts
- requirements.txt, runtime.txt, sample_config.env – dependency and env config
- genStringSession.py – helper to generate Pyrogram session
- **tobrot/**
- `__main__.py` – application entrypoint
- UserDynaConfig.py – dynamic loading of environment/config vars
- **aria2/** – Aria2 configuration
- **bot_theme/** – custom UI elements (bot_UI.py)
- **helper_funcs/** – core utilities (downloaders, compressors, link parsers, upload handlers, progress display, exception definitions, etc.)
- **plugins/** – feature modules (callback handlers, command handlers, torrent search, speedtest, IMDB lookup, rclone config, custom thumbnailing, etc.)
- **update.py** – self-update mechanism

##### README for technical insights
- Confirms use of Pyrogram, Aria2, Rclone, youtube_dl, Real-Debrid
- Deployment targets: Heroku and Docker
- Highlights up to 4 GB upload limits, modular UI, premium account support

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and External API
    subgraph "User Interaction"
        User["User Telegram Client"]:::external
        TelegramAPI["Telegram API"]:::external
    end

    %% Internal Application
    subgraph "Internal Application"
        subgraph "Bot Core"
            BotCore["Bot Core (Pyrogram Event Loop & Dispatcher)"]:::core
            Config["Configuration Manager"]:::core
        end

        subgraph "Plugin Layer"
            Plugin["Plugins (Command & Callback Handlers)"]:::plugin
        end

        subgraph "Helper Layer"
            Helper["Helper Functions (Download, Upload, Parser, Progress, Exceptions)"]:::helper
        end

        subgraph "Download Engines"
            Aria2["Aria2 Download Engine"]:::engine
            YT["YouTube Download Engine"]:::engine
            RD["Real-Debrid Integration"]:::engine
            FFM["FFmpeg Media Processing"]:::engine
        end

        Local["Local Storage (Temp Downloads)"]:::storage

        subgraph "Upload Engines"
            TGUpload["Telegram Upload Engine"]:::engine
            RClone["Rclone Integration"]:::engine
        end
    end

    %% External Services
    subgraph "External Services"
        RealDebridAPI["Real-Debrid API"]:::external
        CloudStorage["Cloud Storage Providers"]:::external
        TorrentIdx["Torrent Indexers"]:::external
    end

    %% Data & Control Flow
    User -->|sends command/link| TelegramAPI -->|forwards update| BotCore
    BotCore --> Config
    BotCore --> Plugin
    Plugin --> Helper
    Helper --> Aria2
    Helper --> YT
    Helper --> RD
    Helper --> FFM
    Aria2 --> Local
    YT --> Local
    RD --> Local
    FFM --> Local
    Helper --> TGUpload
    Helper --> RClone
    Helper -.->|calls API| RealDebridAPI
    Plugin -.->|searches| TorrentIdx
    RClone -.->|uploads to| CloudStorage
    BotCore -->|sends updates| User

    %% Click Events
    click BotCore "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/__main__.py"
    click Config "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/UserDynaConfig.py"
    click Plugin "https://github.com/clinton-abraham/tele-leechx/tree/h-code/tobrot/plugins/"
    click Helper "https://github.com/clinton-abraham/tele-leechx/tree/h-code/tobrot/helper_funcs/"
    click Aria2 "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/aria2/aria2.conf"
    click YT "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/helper_funcs/youtube_dl_extractor.py"
    click RD "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/helper_funcs/real_debrid_extractor.py"
    click FFM "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/helper_funcs/help_Nekmo_ffmpeg.py"
    click TGUpload "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/helper_funcs/upload_to_tg.py"
    click RClone "https://github.com/clinton-abraham/tele-leechx/blob/h-code/tobrot/plugins/choose_rclone_config.py"

    %% Styling
    classDef core fill:#D6EAF8,stroke:#2980B9,color:#154360;
    classDef plugin fill:#D5F5E3,stroke:#28B463,color:#145A32;
    classDef helper fill:#FCF3CF,stroke:#F1C40F,color:#7D6608;
    classDef engine fill:#FADBD8,stroke:#E74C3C,color:#641E16;
    classDef external fill:#F5EEF8,stroke:#8E44AD,color:#4A235A;
    classDef storage fill:#E8E8E8,stroke:#95A5A6,color:#2C3E50;
```
