# nubuki-all/enc architecture

> Architecture diagram of the GitHub repository nubuki-all/enc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nubuki-all/enc
- Repository: https://github.com/nubuki-all/enc

## Overview

ENC is a Telegram bot for queueing downloads and transcoding video files, with controls for queue management, batch selection, encoding settings, and output delivery. The principal workflow begins with an authorized user submitting a file, link, or torrent; queued work is downloaded, transcoded or muxed, and uploaded or forwarded. The README also documents RSS, anime/media information, filtering and rename controls, user permissions, and operational commands. Startup code supports MongoDB or local persistence. Several subsystems are represented by their exact enclosing directories because their implementation was not sampled; those links are omitted where call wiring is unverified.

Main entry points: [`bot/workers/handlers`](https://github.com/nubuki-all/enc/tree/main/bot/workers/handlers) (Command handlers), [`bot/workers/auto/transcode.py`](https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/transcode.py) (Transcode orchestration), [`bot/startup/before.py`](https://github.com/nubuki-all/enc/blob/main/bot/startup/before.py) (Startup and persistence), [`bot/__main__.py`](https://github.com/nubuki-all/enc/blob/main/bot/__main__.py) (Command dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Bot interface"]
  node_dispatch["Command dispatch<br/>[__main__.py]"]
  node_handlers["Command handlers"]
end

subgraph group_work["Media workflow"]
  node_transcode["Transcode orchestration<br/>[transcode.py]"]
  node_download["Downloader<br/>[download.py]"]
  node_encoder["Encoder<br/>[encode.py]"]
  node_upload["Uploader<br/>[upload.py]"]
  node_fasttele["Parallel transfers<br/>[FastTelethon.py]"]
end

subgraph group_state["State and scheduling"]
  node_queue["Queue management<br/>[queue.py]"]
  node_schedule["Automated scheduling<br/>[schedule.py]"]
  node_status["Status reporting<br/>[status.py]"]
  node_startup["Startup and persistence<br/>[before.py]"]
  node_localdb["Local persistence<br/>[local_db_utils.py]"]
  node_dbutils["Database utilities<br/>[db_utils.py]"]
end

subgraph group_features["Bot capabilities"]
  node_rss["RSS subscriptions<br/>[manage.py]"]
  node_anime["Anime information<br/>[ani_utils.py]"]
  node_filters["Filters and renaming<br/>[manage.py]"]
  node_otherhandlers["Management commands<br/>[manage.py]"]
  node_misc["Utilities and messages"]
end

node_user(("Telegram user"))
node_mongodb[("MongoDB")]
node_telegram(("Telegram API"))
node_aria["aria2 / qBittorrent"]
node_ffmpeg["FFmpeg"]

node_user -->|"sends commands"| node_dispatch
node_dispatch -->|"dispatches commands"| node_handlers
node_handlers -->|"adds and manages"| node_queue
node_queue -->|"queues media"| node_transcode
node_transcode -->|"downloads input"| node_download
node_download -->|"fetches media"| node_aria
node_transcode -->|"encodes media"| node_encoder
node_encoder -->|"runs command"| node_ffmpeg
node_transcode -->|"uploads output"| node_upload
node_upload -->|"sends media"| node_telegram
node_download -->|"updates progress"| node_telegram
node_upload -.->|"transfer support"| node_fasttele
node_dispatch -->|"registers handlers"| node_telegram
node_startup -.->|"loads state"| node_mongodb
node_startup -->|"loads fallback"| node_localdb
node_startup -->|"initializes persistence"| node_dbutils
node_schedule -.->|"schedules work"| node_queue
node_status -.->|"reports status"| node_telegram
node_handlers -->|"manages feeds"| node_rss
node_rss -->|"replies with items"| node_telegram
node_handlers -.->|"requests anime data"| node_anime
node_handlers -->|"manages rules"| node_filters
node_handlers -->|"handles controls"| node_otherhandlers
node_handlers -.->|"uses utilities"| node_misc

click node_dispatch "https://github.com/nubuki-all/enc/blob/main/bot/__main__.py"
click node_handlers "https://github.com/nubuki-all/enc/tree/main/bot/workers/handlers"
click node_queue "https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/queue.py"
click node_transcode "https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/transcode.py"
click node_download "https://github.com/nubuki-all/enc/blob/main/bot/workers/downloaders/download.py"
click node_encoder "https://github.com/nubuki-all/enc/blob/main/bot/workers/encoders/encode.py"
click node_upload "https://github.com/nubuki-all/enc/blob/main/bot/workers/uploaders/upload.py"
click node_fasttele "https://github.com/nubuki-all/enc/blob/main/bot/utils/FastTelethon.py"
click node_schedule "https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/schedule.py"
click node_status "https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/status.py"
click node_startup "https://github.com/nubuki-all/enc/blob/main/bot/startup/before.py"
click node_localdb "https://github.com/nubuki-all/enc/blob/main/bot/utils/local_db_utils.py"
click node_dbutils "https://github.com/nubuki-all/enc/blob/main/bot/utils/db_utils.py"
click node_rss "https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/manage.py"
click node_anime "https://github.com/nubuki-all/enc/blob/main/bot/utils/ani_utils.py"
click node_filters "https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/manage.py"
click node_otherhandlers "https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/manage.py"
click node_misc "https://github.com/nubuki-all/enc/tree/main/bot/utils"

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_dispatch,node_handlers,node_user toneBlue
class node_transcode,node_download,node_encoder,node_upload,node_fasttele,node_mongodb toneAmber
class node_queue,node_schedule,node_status,node_startup,node_localdb,node_dbutils,node_telegram toneMint
class node_rss,node_anime,node_filters,node_otherhandlers,node_misc toneRose
class node_aria,node_ffmpeg toneIndigo
```

## Components

### Bot interface

- [Command dispatch](https://github.com/nubuki-all/enc/blob/main/bot/__main__.py): `bot/__main__.py`
- [Command handlers](https://github.com/nubuki-all/enc/tree/main/bot/workers/handlers): `bot/workers/handlers`

### Media workflow

- [Transcode orchestration](https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/transcode.py): `bot/workers/auto/transcode.py`
- [Downloader](https://github.com/nubuki-all/enc/blob/main/bot/workers/downloaders/download.py): `bot/workers/downloaders/download.py`
- [Encoder](https://github.com/nubuki-all/enc/blob/main/bot/workers/encoders/encode.py): `bot/workers/encoders/encode.py`
- [Uploader](https://github.com/nubuki-all/enc/blob/main/bot/workers/uploaders/upload.py): `bot/workers/uploaders/upload.py`
- [Parallel transfers](https://github.com/nubuki-all/enc/blob/main/bot/utils/FastTelethon.py): `bot/utils/FastTelethon.py`

### State and scheduling

- [Queue management](https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/queue.py): `bot/workers/handlers/queue.py`
- [Automated scheduling](https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/schedule.py): `bot/workers/auto/schedule.py`
- [Status reporting](https://github.com/nubuki-all/enc/blob/main/bot/workers/auto/status.py): `bot/workers/auto/status.py`
- [Startup and persistence](https://github.com/nubuki-all/enc/blob/main/bot/startup/before.py): `bot/startup/before.py`
- [Local persistence](https://github.com/nubuki-all/enc/blob/main/bot/utils/local_db_utils.py): `bot/utils/local_db_utils.py`
- [Database utilities](https://github.com/nubuki-all/enc/blob/main/bot/utils/db_utils.py): `bot/utils/db_utils.py`

### Bot capabilities

- [RSS subscriptions](https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/manage.py): `bot/workers/handlers/manage.py`
- [Anime information](https://github.com/nubuki-all/enc/blob/main/bot/utils/ani_utils.py): `bot/utils/ani_utils.py`
- [Filters and renaming](https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/manage.py): `bot/workers/handlers/manage.py`
- [Management commands](https://github.com/nubuki-all/enc/blob/main/bot/workers/handlers/manage.py): `bot/workers/handlers/manage.py`
- [Utilities and messages](https://github.com/nubuki-all/enc/tree/main/bot/utils): `bot/utils`

### Other components

- **Telegram user**
- **MongoDB**
- **Telegram API**
- **aria2 / qBittorrent**
- **FFmpeg**

## Connections

- Telegram user → Command dispatch: sends commands
- Command dispatch → Command handlers: dispatches commands
- Command handlers → Queue management: adds and manages
- Queue management → Transcode orchestration: queues media
- Transcode orchestration → Downloader: downloads input
- Downloader → aria2 / qBittorrent: fetches media
- Transcode orchestration → Encoder: encodes media
- Encoder → FFmpeg: runs command
- Transcode orchestration → Uploader: uploads output
- Uploader → Telegram API: sends media
- Downloader → Telegram API: updates progress
- Uploader → Parallel transfers: transfer support
- Command dispatch → Telegram API: registers handlers
- Startup and persistence → MongoDB: loads state
- Startup and persistence → Local persistence: loads fallback
- Startup and persistence → Database utilities: initializes persistence
- Automated scheduling → Queue management: schedules work
- Status reporting → Telegram API: reports status
- Command handlers → RSS subscriptions: manages feeds
- RSS subscriptions → Telegram API: replies with items
- Command handlers → Anime information: requests anime data
- Command handlers → Filters and renaming: manages rules
- Command handlers → Management commands: handles controls
- Command handlers → Utilities and messages: uses utilities
