# mrmkn/professor-bot architecture

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

- Interactive diagram: https://gitdiagram.com/mrmkn/professor-bot
- Repository: https://github.com/mrmkn/professor-bot

## Overview

##### Main Components
- Bot Entry Point: Highlight bot.py (and possibly Script.py if used for initialization) as the central file that triggers the bot’s operation.
- Database Layer: Use the “database” folder and its files (e.g., connections_mdb.py, filters_mdb.py, gfilters_mdb.py, ia_filterdb.py, users_chats_db.py) to represent the data persistence and interactions (primarily with mongoDB, as seen in the environment variables).
- Plugins System: Represent the entire “plugins” directory as a modular collection, subdividing into:
- Core files (admin_control.py, banned.py, broadcast.py, commands.py, connection.py, file_store.py, filters_global.py, group_filter.py, index.py, inline.py, pm_filter.py, query.py)
- Extra modifications/extended features in the “plugins/ExtraMods” directory (e.g., carbon.py, font.py, group_manager.py, json.py, lyrics.py, password.py, paste.py, photo.py, share_text.py, telegraph.py, tts.py, yt_dl.py)
- Image Editing: Include the “image” folder, which contains several scripts (edit_1.py through edit_5.py and font_string.py) for image edits or background removal.
- Supporting Utilities & Configuration: Consider files like utils.py, logging.conf, info.py, and configuration files (Dockerfile, Procfile, runtime.txt, app.json) that determine deployment and runtime behavior.

##### Establish Relationships & Interactions
- The Main Bot (from bot.py) acts as the orchestrator – it receives Telegram updates and directs them to the Plugin Manager.
- The Plugins: Each plugin file (and ExtraMods plugins) represents a specialized command or functionality module. They interact directly with the bot entry point to process commands and can depend on the utilities in utils.py.
- Image Processing: Specific commands invoke image processing functions (via scripts in the “image” folder). Connect these to the plugin modules related to image editing.

##### Indicating Architectural Patterns & Technologies
- File-based Modular Design: Emphasize that the system uses individual files organized by functionalities – each file in a directory represents a distinct module.
- Decoupled Plugin Architecture: The plugins directory shows that functionality is divided into granular plugins that can be loaded, updated, or extended independently.
- Database Abstraction: The separate “database” folder indicates that data access is abstracted away from the core business logic.
- Deployment Configuration Files: These allow the bot to be containerized (Dockerfile) and deployed to platforms like Heroku or Koyeb (Procfile, runtime.txt, etc.).
- Underlying Technologies: Mention that the project likely uses Python (given the .py files and naming conventions), integrates with Telegram API (as described in the README with required tokens and API parameters), and uses MongoDB.

##### Essential Elements
- Clear, descriptive labels that mention both the component and, where appropriate, the key file names.
- Separation of concerns: visually represent the physical separation between main logic (bot.py), plugins (commands, etc.), and the supporting database and image utilities.
- That it’s easy to see where each functional area is located within the file system, thereby making maintenance or future extensions clear.
- To indicate the file-based structure: each node representing a folder might include a sub-listing of critical files.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Configurations & Utilities
    subgraph "Configurations & Utilities"
        utils["utils.py"]:::utility
        logging["logging.conf"]:::utility
        info["info.py"]:::utility
        Docker["Dockerfile"]:::utility
        Proc["Procfile"]:::utility
        runtime["runtime.txt"]:::utility
        appjson["app.json"]:::utility
    end

    %% Bot Service
    subgraph "Bot Service"
        bot_py["bot.py"]:::core
        script_py["Script.py"]:::core
    end

    %% Plugins System
    subgraph "Plugins System"
        subgraph "Core Plugins"
            plugins_core["plugins/"]:::plugin
        end
        subgraph "Extra Mods"
            plugins_extramods["plugins/ExtraMods/"]:::plugin_extra
        end
    end

    %% Database Layer
    subgraph "Database Layer"
        db["database"]:::database
    end

    %% Image Editing
    subgraph "Image Editing"
        image_edit["image/"]:::image
    end

    %% Relationships
    script_py -->|"launches"| bot_py
    bot_py -->|"delegates_commands"| plugins_core
    plugins_extramods -->|"extends"| plugins_core
    plugins_core -->|"reads/writes"| db
    plugins_core -->|"processes_images"| image_edit
    utils -->|"provides_utilities"| bot_py
    Docker -->|"deployment_config"| bot_py
    logging -->|"logging"| bot_py
    info -->|"shared_info"| plugins_core

    %% Click Events
    click bot_py "https://github.com/mrmkn/professor-bot/blob/main/bot.py"
    click script_py "https://github.com/mrmkn/professor-bot/blob/main/Script.py"
    click db "https://github.com/mrmkn/professor-bot/tree/main/database/"
    click plugins_core "https://github.com/mrmkn/professor-bot/tree/main/plugins/"
    click plugins_extramods "https://github.com/mrmkn/professor-bot/tree/main/plugins/ExtraMods/"
    click image_edit "https://github.com/mrmkn/professor-bot/tree/main/image/"
    click utils "https://github.com/mrmkn/professor-bot/blob/main/utils.py"
    click logging "https://github.com/mrmkn/professor-bot/blob/main/logging.conf"
    click info "https://github.com/mrmkn/professor-bot/blob/main/info.py"
    click Docker "https://github.com/mrmkn/professor-bot/tree/main/Dockerfile"
    click Proc "https://github.com/mrmkn/professor-bot/tree/main/Procfile"
    click runtime "https://github.com/mrmkn/professor-bot/blob/main/runtime.txt"
    click appjson "https://github.com/mrmkn/professor-bot/blob/main/app.json"

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px,color:black;
    classDef utility fill:#F9E79F,stroke:#B7950B,stroke-width:2px,color:black;
    classDef database fill:#D5F5E3,stroke:#1D8348,stroke-width:2px,color:black;
    classDef plugin fill:#FAD7A0,stroke:#CA6F1E,stroke-width:2px,color:black;
    classDef plugin_extra fill:#F5B7B1,stroke:#C0392B,stroke-width:2px,color:black;
    classDef image fill:#D2B4DE,stroke:#6C3483,stroke-width:2px,color:black;
```
