# ather86/ai_projects_telegram architecture

> Architecture diagram of the GitHub repository ather86/ai_projects_telegram, 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/ather86/ai_projects_telegram
- Repository: https://github.com/ather86/ai_projects_telegram

## Overview

This repository implements a Telegram-driven AI video-generation bot, with a separate alert webhook and a small command-line ComfyUI bridge. The main workflow accepts a script or prompt, prepares scenes and prompts, submits rendering work to ComfyUI, and processes the resulting clips into a video. The graph reflects the sampled Python excerpts and the workflow file in the tree; some Telegram handlers and processing details were not included, so uncertain connections are omitted.

Main entry points: [`telegram_gate.py`](https://github.com/ather86/ai_projects_telegram/blob/main/telegram_gate.py) (Telegram bot and webhook), [`video_processor.py`](https://github.com/ather86/ai_projects_telegram/blob/main/video_processor.py) (Scene and video processing), [`comfy_bridge.py`](https://github.com/ather86/ai_projects_telegram/blob/main/comfy_bridge.py) (Standalone bridge), [`workflow_api/video_ltx2_3_i2v.json`](https://github.com/ather86/ai_projects_telegram/blob/main/workflow_api/video_ltx2_3_i2v.json) (LTX image-to-video workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bot["Bot and alerts"]
  node_gate["Telegram bot and webhook<br/>[telegram_gate.py]"]
end

subgraph group_generation["Video generation"]
  node_processor["Scene and video processing<br/>[video_processor.py]"]
end

subgraph group_rendering["Rendering integration"]
  node_comfy["ComfyUI API and renderer"]
  node_queue["Render queue"]
  node_workflow["LTX image-to-video workflow"]
end

subgraph group_bridge["Standalone bridge"]
  node_bridge["Standalone bridge<br/>[comfy_bridge.py]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram platform"))
node_ollama["Ollama LLM"]
node_ffmpeg["FFmpeg tools"]
node_alert_source(("Alert sender"))
node_image_input["ComfyUI input images"]
node_input_image["Latest input image"]
node_video_output["Generated video"]

node_user -->|"sends request"| node_telegram
node_telegram -->|"delivers updates"| node_gate
node_gate -->|"replies and sends alerts"| node_telegram
node_gate -->|"processes video request"| node_processor
node_processor -->|"parses script"| node_ollama
node_processor -->|"stitches clips"| node_ffmpeg
node_gate -->|"loads selected workflow"| node_workflow
node_gate -->|"submits render prompt"| node_comfy
node_comfy -->|"enqueues render"| node_queue
node_comfy -->|"streams render events"| node_gate
node_alert_source -->|"posts alert"| node_gate
node_bridge -->|"searches latest image"| node_image_input
node_image_input -->|"selects image"| node_input_image
node_bridge -->|"loads workflow"| node_workflow
node_bridge -->|"submits render prompt"| node_comfy
node_processor -->|"produces video"| node_video_output

click node_gate "https://github.com/ather86/ai_projects_telegram/blob/main/telegram_gate.py"
click node_processor "https://github.com/ather86/ai_projects_telegram/blob/main/video_processor.py"
click node_workflow "https://github.com/ather86/ai_projects_telegram/blob/main/workflow_api/video_ltx2_3_i2v.json"
click node_bridge "https://github.com/ather86/ai_projects_telegram/blob/main/comfy_bridge.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_gate,node_user,node_image_input toneBlue
class node_processor toneAmber
class node_comfy,node_queue,node_workflow toneMint
class node_bridge toneRose
class node_telegram,node_ollama,node_ffmpeg,node_alert_source,node_input_image,node_video_output toneIndigo
```

## Components

### Bot and alerts

- [Telegram bot and webhook](https://github.com/ather86/ai_projects_telegram/blob/main/telegram_gate.py): `telegram_gate.py`

### Video generation

- [Scene and video processing](https://github.com/ather86/ai_projects_telegram/blob/main/video_processor.py): `video_processor.py`

### Rendering integration

- **ComfyUI API and renderer**
- **Render queue**
- [LTX image-to-video workflow](https://github.com/ather86/ai_projects_telegram/blob/main/workflow_api/video_ltx2_3_i2v.json): `workflow_api/video_ltx2_3_i2v.json`

### Standalone bridge

- [Standalone bridge](https://github.com/ather86/ai_projects_telegram/blob/main/comfy_bridge.py): `comfy_bridge.py`

### Other components

- **Telegram user**
- **Telegram platform**
- **Ollama LLM**
- **FFmpeg tools**
- **Alert sender**
- **ComfyUI input images**
- **Latest input image**
- **Generated video**

## Connections

- Telegram user → Telegram platform: sends request
- Telegram platform → Telegram bot and webhook: delivers updates
- Telegram bot and webhook → Telegram platform: replies and sends alerts
- Telegram bot and webhook → Scene and video processing: processes video request
- Scene and video processing → Ollama LLM: parses script
- Scene and video processing → FFmpeg tools: stitches clips
- Telegram bot and webhook → LTX image-to-video workflow: loads selected workflow
- Telegram bot and webhook → ComfyUI API and renderer: submits render prompt
- ComfyUI API and renderer → Render queue: enqueues render
- ComfyUI API and renderer → Telegram bot and webhook: streams render events
- Alert sender → Telegram bot and webhook: posts alert
- Standalone bridge → ComfyUI input images: searches latest image
- ComfyUI input images → Latest input image: selects image
- Standalone bridge → LTX image-to-video workflow: loads workflow
- Standalone bridge → ComfyUI API and renderer: submits render prompt
- Scene and video processing → Generated video: produces video
