# devgaganin/auto-forward-bot-v2 architecture

> Architecture diagram of the GitHub repository devgaganin/auto-forward-bot-v2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/devgaganin/auto-forward-bot-v2
- Repository: https://github.com/devgaganin/auto-forward-bot-v2

## Overview

##### Project type and purpose
- This is a single-process, Python-based Telegram bot (“Advance Content Saver Bot”) whose job is to listen for messages/files in channels (restricted or not) and forward or clone them for authenticated users.
- The README describes features such as forwarding public/private channel messages, batch-cloning posts by link (up to 10K), broadcasting, stats, and various management commands.

##### File structure
Top‐level files:
- Dockerfile, Procfile, heroku.yml, app.json, start.sh – deployment artifacts for Docker, Heroku, or VPS
- config.py – runtime configuration (API keys, DB URIs, etc.)
- logging.conf – logging configuration
- database.py – persistence layer (e.g., SQLite/Postgres access, schemas)
- bot.py – Telegram client setup (long‐polling or webhook) and dispatcher initialization
- main.py – entry point: loads config, sets up logging, connects DB, starts the bot
- translation.py – internationalization/resource strings
- plugins/ – plugin modules, each implementing one or more command handlers (broadcast.py, forward logic in commands.py, settings.py, etc.)
- requirements.txt – Python dependencies

##### README for additional insights
- Confirms use of Telegram Bot API, user authentication requirements, batch processing via a `/batch` command.
- Deployment on VPS or Heroku; shows need to configure dynos (Procfile), env vars (config.py), and link GitHub → Heroku.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Service
    TelegramAPI["Telegram Bot API"]:::external

    %% Deployment & Infrastructure
    subgraph "Deployment & Infrastructure"
        Dockerfile["Dockerfile"]:::infra
        Procfile["Procfile"]:::infra
        AppJson["app.json"]:::infra
        HerokuYml["heroku.yml"]:::infra
        StartSh["start.sh"]:::infra
    end

    %% Configuration & Logging
    subgraph "Configuration & Logging"
        Config["config.py"]:::config
        LoggingConf["logging.conf"]:::config
    end

    %% Bot Core
    subgraph "Bot Core"
        Main["main.py"]:::core
        Bot["bot.py"]:::core
        Trans["translation.py"]:::core
    end

    %% Plugin Layer
    subgraph "Plugin Layer"
        Broadcast["broadcast.py"]:::plugin
        Commands["commands.py"]:::plugin
        Public["public.py"]:::plugin
        Regix["regix.py"]:::plugin
        Settings["settings.py"]:::plugin
        Test["test.py"]:::plugin
        Unequify["unequify.py"]:::plugin
        Utils["utils.py"]:::plugin
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["database.py"]:::db
    end

    %% Storage Layer
    subgraph "Storage Layer"
        Storage["Local / Cloud Storage"]:::storage
    end

    %% Data Flows
    TelegramAPI -->|updates| Main
    Main -->|load config| Config
    Main -->|load logging| LoggingConf
    Main -->|start bot| Bot
    Bot -->|dispatch update| Broadcast
    Bot -->|dispatch update| Commands
    Bot -->|dispatch update| Public
    Bot -->|dispatch update| Regix
    Bot -->|dispatch update| Settings
    Bot -->|dispatch update| Test
    Bot -->|dispatch update| Unequify
    Bot -->|dispatch update| Utils
    Broadcast -->|DB query/write| DB
    Commands -->|DB query/write| DB
    Public -->|DB query/write| DB
    Regix -->|DB query/write| DB
    Settings -->|DB query/write| DB
    Test -->|DB query/write| DB
    Unequify -->|DB query/write| DB
    Utils -->|DB query/write| DB
    Broadcast -->|download/save file| Storage
    Commands -->|download/save file| Storage
    Public -->|download/save file| Storage
    Regix -->|download/save file| Storage
    Settings -->|download/save file| Storage
    Test -->|download/save file| Storage
    Unequify -->|download/save file| Storage
    Utils -->|download/save file| Storage
    Bot -->|send message/file| TelegramAPI

    %% Click Events
    click Main "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/main.py"
    click Bot "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/bot.py"
    click Trans "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/translation.py"
    click Config "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/config.py"
    click LoggingConf "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/logging.conf"
    click DB "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/database.py"
    click Broadcast "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/broadcast.py"
    click Commands "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/commands.py"
    click Public "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/public.py"
    click Regix "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/regix.py"
    click Settings "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/settings.py"
    click Test "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/test.py"
    click Unequify "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/unequify.py"
    click Utils "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/plugins/utils.py"
    click Dockerfile "https://github.com/devgaganin/auto-forward-bot-v2/tree/main/Dockerfile"
    click Procfile "https://github.com/devgaganin/auto-forward-bot-v2/tree/main/Procfile"
    click AppJson "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/app.json"
    click HerokuYml "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/heroku.yml"
    click StartSh "https://github.com/devgaganin/auto-forward-bot-v2/blob/main/start.sh"

    %% Styles
    classDef external fill:#E8F1FA,stroke:#0366D6,color:#0366D6;
    classDef core fill:#E6F4EA,stroke:#28A745,color:#28A745;
    classDef plugin fill:#FFF5BA,stroke:#FFD33D,color:#8A6D3B;
    classDef db fill:#FFE5D9,stroke:#FF7F11,color:#D35400;
    classDef storage fill:#F4E1D2,stroke:#8B4513,color:#8B4513;
    classDef config fill:#F0F0F0,stroke:#6C757D,color:#343A40;
    classDef infra fill:#F3E5F5,stroke:#6F42C1,color:#5A32A3;
```
