# chorus4/discord-backdoor-bot architecture

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

- Interactive diagram: https://gitdiagram.com/chorus4/discord-backdoor-bot
- Repository: https://github.com/chorus4/discord-backdoor-bot

## Overview

This is a Telegram control bot for managing Discord bot accounts and their servers. The main workflow starts in Telegram: the dispatcher routes interactions to handlers, which retrieve Discord guilds through the shared guild-access layer and present or perform server-management actions. Bot setup and runtime are backed by SQLite records and in-memory Discord clients; additional branches cover invites, member and role administration, and the log-clearing operation. The README is empty, so capabilities and connections here are based on the supplied source excerpts and SOURCE INDEX; unsampled handler details are not inferred.

Main entry points: [`main.py`](https://github.com/chorus4/discord-backdoor-bot/blob/main/main.py) (Update dispatcher), [`ds/guilds.py`](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/guilds.py) (Guild access), [`ds/logs.py`](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/logs.py) (Log clearing), [`ds/__init__.py`](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/__init__.py) (Discord bot runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram interface"]
  node_dispatcher["Update dispatcher<br/>[main.py]"]
  node_welcome["Welcome flow<br/>[welcome.py]"]
end

subgraph group_lifecycle["Bot lifecycle"]
  node_bot_handlers["Bot management<br/>[bots.py]"]
  node_bot_runtime["Discord bot runtime<br/>[__init__.py]"]
  node_bot_storage["Client registry<br/>[botStorage.py]"]
end

subgraph group_server["Server management"]
  node_guild_handlers["Guild browser<br/>[guilds.py]"]
  node_invite_handlers["Invite tools<br/>[invite.py]"]
  node_member_handlers["Member tools<br/>[members.py]"]
  node_role_handlers["Role tools<br/>[roles.py]"]
  node_guild_access["Guild access<br/>[guilds.py]"]
end

subgraph group_logging["Log operations"]
  node_log_handlers["Log controls<br/>[logs.py]"]
  node_log_runner["Log clearing<br/>[logs.py]"]
  node_log_state["Log task state<br/>[logs_loop.py]"]
  node_progress["Progress display<br/>[progressbar.py]"]
end

subgraph group_persistence["Persistence"]
  node_db_init["Database setup<br/>[__init__.py]"]
  node_bot_records[("Bot records<br/>[dsBots.py]")]
end

node_user(("Telegram user"))
node_sqlite[("SQLite database")]
node_discord(("Discord service"))

node_user -->|"sends updates"| node_dispatcher
node_dispatcher -->|"routes updates"| node_welcome
node_dispatcher -->|"routes updates"| node_bot_handlers
node_dispatcher -->|"routes updates"| node_guild_handlers
node_dispatcher -->|"routes updates"| node_member_handlers
node_dispatcher -->|"routes updates"| node_role_handlers
node_dispatcher -->|"routes updates"| node_invite_handlers
node_dispatcher -->|"routes updates"| node_log_handlers
node_dispatcher -->|"starts clients"| node_bot_runtime
node_dispatcher -->|"initializes"| node_db_init
node_bot_handlers -->|"reads and writes"| node_bot_records
node_bot_handlers -->|"stops clients"| node_bot_runtime
node_bot_handlers -->|"lists guilds"| node_guild_access
node_bot_runtime -->|"loads bot records"| node_bot_records
node_bot_runtime -->|"registers clients"| node_bot_storage
node_bot_runtime -->|"starts Discord clients"| node_discord
node_guild_access -->|"looks up bot"| node_bot_records
node_guild_access -->|"gets client"| node_bot_storage
node_guild_access -->|"returns guild"| node_discord
node_guild_handlers -->|"gets guilds"| node_guild_access
node_member_handlers -->|"gets guild"| node_guild_access
node_member_handlers -->|"uses callbacks"| node_guild_handlers
node_role_handlers -->|"gets guild"| node_guild_access
node_role_handlers -->|"uses callbacks"| node_guild_handlers
node_invite_handlers -->|"gets guild"| node_guild_access
node_log_handlers -->|"uses guild access"| node_guild_access
node_log_handlers -->|"starts log operation"| node_log_runner
node_log_runner -->|"gets guild"| node_guild_access
node_log_runner -->|"uses stop state"| node_log_state
node_log_runner -->|"renders progress"| node_progress
node_log_runner -->|"creates and deletes invites"| node_discord
node_db_init -->|"creates tables"| node_sqlite
node_db_init -->|"registers model"| node_bot_records

click node_dispatcher "https://github.com/chorus4/discord-backdoor-bot/blob/main/main.py"
click node_welcome "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/welcome.py"
click node_bot_handlers "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/bots.py"
click node_guild_handlers "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/guilds.py"
click node_invite_handlers "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/invite.py"
click node_member_handlers "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/members.py"
click node_role_handlers "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/roles.py"
click node_log_handlers "https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/logs.py"
click node_bot_runtime "https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/__init__.py"
click node_bot_storage "https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/botStorage.py"
click node_guild_access "https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/guilds.py"
click node_log_runner "https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/logs.py"
click node_log_state "https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/utils/logs_loop.py"
click node_progress "https://github.com/chorus4/discord-backdoor-bot/blob/main/utils/progressbar.py"
click node_db_init "https://github.com/chorus4/discord-backdoor-bot/blob/main/db/__init__.py"
click node_bot_records "https://github.com/chorus4/discord-backdoor-bot/blob/main/db/models/dsBots.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dispatcher,node_welcome,node_user toneBlue
class node_bot_handlers,node_bot_runtime,node_bot_storage,node_sqlite toneAmber
class node_guild_handlers,node_invite_handlers,node_member_handlers,node_role_handlers,node_guild_access toneMint
class node_log_handlers,node_log_runner,node_log_state,node_progress toneRose
class node_db_init,node_bot_records,node_discord toneIndigo
```

## Components

### Telegram interface

- [Update dispatcher](https://github.com/chorus4/discord-backdoor-bot/blob/main/main.py): `main.py`
- [Welcome flow](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/welcome.py): `handlers/welcome.py`

### Bot lifecycle

- [Bot management](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/bots.py): `handlers/bots.py`
- [Discord bot runtime](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/__init__.py): `ds/__init__.py`
- [Client registry](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/botStorage.py): `ds/botStorage.py`

### Server management

- [Guild browser](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/guilds.py): `handlers/guilds.py`
- [Invite tools](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/invite.py): `handlers/invite.py`
- [Member tools](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/members.py): `handlers/members.py`
- [Role tools](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/roles.py): `handlers/roles.py`
- [Guild access](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/guilds.py): `ds/guilds.py`

### Log operations

- [Log controls](https://github.com/chorus4/discord-backdoor-bot/blob/main/handlers/logs.py): `handlers/logs.py`
- [Log clearing](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/logs.py): `ds/logs.py`
- [Log task state](https://github.com/chorus4/discord-backdoor-bot/blob/main/ds/utils/logs_loop.py): `ds/utils/logs_loop.py`
- [Progress display](https://github.com/chorus4/discord-backdoor-bot/blob/main/utils/progressbar.py): `utils/progressbar.py`

### Persistence

- [Database setup](https://github.com/chorus4/discord-backdoor-bot/blob/main/db/__init__.py): `db/__init__.py`
- [Bot records](https://github.com/chorus4/discord-backdoor-bot/blob/main/db/models/dsBots.py): `db/models/dsBots.py`

### Other components

- **Telegram user**
- **SQLite database**
- **Discord service**

## Connections

- Telegram user → Update dispatcher: sends updates (evidence: `main.py`)
- Update dispatcher → Welcome flow: routes updates (evidence: `main.py`)
- Update dispatcher → Bot management: routes updates (evidence: `main.py`)
- Update dispatcher → Guild browser: routes updates (evidence: `main.py`)
- Update dispatcher → Member tools: routes updates (evidence: `main.py`)
- Update dispatcher → Role tools: routes updates (evidence: `main.py`)
- Update dispatcher → Invite tools: routes updates (evidence: `main.py`)
- Update dispatcher → Log controls: routes updates (evidence: `main.py`)
- Update dispatcher → Discord bot runtime: starts clients (evidence: `main.py`)
- Update dispatcher → Database setup: initializes (evidence: `main.py`)
- Bot management → Bot records: reads and writes (evidence: `handlers/bots.py`)
- Bot management → Discord bot runtime: stops clients (evidence: `handlers/bots.py`)
- Bot management → Guild access: lists guilds (evidence: `handlers/bots.py`)
- Discord bot runtime → Bot records: loads bot records (evidence: `ds/__init__.py`)
- Discord bot runtime → Client registry: registers clients (evidence: `ds/__init__.py`)
- Discord bot runtime → Discord service: starts Discord clients (evidence: `ds/__init__.py`)
- Guild access → Bot records: looks up bot (evidence: `ds/guilds.py`)
- Guild access → Client registry: gets client (evidence: `ds/guilds.py`)
- Guild access → Discord service: returns guild (evidence: `ds/guilds.py`)
- Guild browser → Guild access: gets guilds (evidence: `handlers/guilds.py`)
- Member tools → Guild access: gets guild (evidence: `handlers/members.py`)
- Member tools → Guild browser: uses callbacks (evidence: `handlers/members.py`)
- Role tools → Guild access: gets guild (evidence: `handlers/roles.py`)
- Role tools → Guild browser: uses callbacks (evidence: `handlers/roles.py`)
- Invite tools → Guild access: gets guild (evidence: `handlers/invite.py`)
- Log controls → Guild access: uses guild access (evidence: `handlers/logs.py`)
- Log controls → Log clearing: starts log operation (evidence: `handlers/logs.py`)
- Log clearing → Guild access: gets guild (evidence: `ds/logs.py`)
- Log clearing → Log task state: uses stop state (evidence: `ds/logs.py`)
- Log clearing → Progress display: renders progress (evidence: `ds/logs.py`)
- Log clearing → Discord service: creates and deletes invites (evidence: `ds/logs.py`)
- Database setup → SQLite database: creates tables (evidence: `db/__init__.py`)
- Database setup → Bot records: registers model (evidence: `db/__init__.py`)
