# simpnick6703/disgram architecture

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

- Interactive diagram: https://gitdiagram.com/simpnick6703/disgram
- Repository: https://github.com/simpnick6703/disgram

## Overview

Disgram periodically scrapes configured public Telegram channels in short-lived workers, prepares message text and media, and forwards them to Discord. The main process orchestrates channel chunks and also serves health and administrative endpoints. A shared log tracks forwarded-message markers; optional Git persistence pushes that state to GitHub, while optional Telethon support supplies richer text and media. The workflow and major capabilities are documented in the README; some internal details are shown only in partial excerpts, so relationships not evidenced there are omitted.

Main entry points: [`webhook.py`](https://github.com/simpnick6703/disgram/blob/main/webhook.py) (Channel Worker), [`main.py`](https://github.com/simpnick6703/disgram/blob/main/main.py) (Worker Orchestrator), [`git_manager.py`](https://github.com/simpnick6703/disgram/blob/main/git_manager.py) (Git Log Manager), [`logging_config.py`](https://github.com/simpnick6703/disgram/blob/main/logging_config.py) (Log & Marker Handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime &amp; API"]
  node_config["Runtime Config<br/>[config.py]"]
  node_orchestrator["Worker Orchestrator<br/>[main.py]"]
  node_monitor_api["Health &amp; Admin API<br/>[main.py]"]
end

subgraph group_forwarding["Scrape &amp; Forward"]
  node_worker["Channel Worker<br/>[webhook.py]"]
  node_preview_scraper["Preview Scraper<br/>[webhook.py]"]
  node_message_parser["Message Parser<br/>[webhook.py]"]
  node_media_handler["Media Handling<br/>[webhook.py]"]
  node_layout_sender["Discord Layout Sender<br/>[webhook.py]"]
end

subgraph group_state["Logs &amp; Persistence"]
  node_log_handler["Log &amp; Marker Handler<br/>[logging_config.py]"]
  node_git_manager["Git Log Manager<br/>[git_manager.py]"]
end

subgraph group_telegram["Telegram Integration"]
  node_telethon["Telethon Client<br/>[telethon_client.py]"]
end

node_operator(("Operator"))
node_telegram_public(("Telegram Public"))
node_discord(("Discord"))
node_github(("GitHub"))

node_operator -->|"starts"| node_orchestrator
node_orchestrator -->|"starts API"| node_monitor_api
node_orchestrator -->|"spawns chunks"| node_worker
node_orchestrator -->|"initializes"| node_git_manager
node_config -->|"configures"| node_orchestrator
node_config -->|"configures"| node_worker
node_worker -->|"scrapes channels"| node_preview_scraper
node_preview_scraper -->|"fetches previews"| node_telegram_public
node_worker -->|"processes messages"| node_message_parser
node_message_parser -.->|"fetches rich text"| node_telethon
node_message_parser -->|"extracts media"| node_media_handler
node_media_handler -.->|"downloads media"| node_telethon
node_media_handler -->|"downloads fallback media"| node_telegram_public
node_worker -->|"prepares content"| node_layout_sender
node_layout_sender -->|"sends webhook"| node_discord
node_worker -->|"records markers"| node_log_handler
node_monitor_api -->|"cleans and reads"| node_log_handler
node_git_manager -->|"persists log"| node_log_handler
node_git_manager -->|"commits and pushes"| node_github
node_operator -->|"checks status"| node_monitor_api

click node_config "https://github.com/simpnick6703/disgram/blob/main/config.py"
click node_orchestrator "https://github.com/simpnick6703/disgram/blob/main/main.py"
click node_monitor_api "https://github.com/simpnick6703/disgram/blob/main/main.py"
click node_worker "https://github.com/simpnick6703/disgram/blob/main/webhook.py"
click node_preview_scraper "https://github.com/simpnick6703/disgram/blob/main/webhook.py"
click node_message_parser "https://github.com/simpnick6703/disgram/blob/main/webhook.py"
click node_media_handler "https://github.com/simpnick6703/disgram/blob/main/webhook.py"
click node_layout_sender "https://github.com/simpnick6703/disgram/blob/main/webhook.py"
click node_telethon "https://github.com/simpnick6703/disgram/blob/main/telethon_client.py"
click node_log_handler "https://github.com/simpnick6703/disgram/blob/main/logging_config.py"
click node_git_manager "https://github.com/simpnick6703/disgram/blob/main/git_manager.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_config,node_orchestrator,node_monitor_api toneBlue
class node_worker,node_preview_scraper,node_message_parser,node_media_handler,node_layout_sender toneAmber
class node_log_handler,node_git_manager toneMint
class node_telethon toneRose
class node_operator,node_telegram_public,node_discord,node_github toneIndigo
```

## Components

### Runtime & API

- [Runtime Config](https://github.com/simpnick6703/disgram/blob/main/config.py): `config.py`
- [Worker Orchestrator](https://github.com/simpnick6703/disgram/blob/main/main.py): `main.py`
- [Health & Admin API](https://github.com/simpnick6703/disgram/blob/main/main.py): `main.py`

### Scrape & Forward

- [Channel Worker](https://github.com/simpnick6703/disgram/blob/main/webhook.py): `webhook.py`
- [Preview Scraper](https://github.com/simpnick6703/disgram/blob/main/webhook.py): `webhook.py`
- [Message Parser](https://github.com/simpnick6703/disgram/blob/main/webhook.py): `webhook.py`
- [Media Handling](https://github.com/simpnick6703/disgram/blob/main/webhook.py): `webhook.py`
- [Discord Layout Sender](https://github.com/simpnick6703/disgram/blob/main/webhook.py): `webhook.py`

### Logs & Persistence

- [Log & Marker Handler](https://github.com/simpnick6703/disgram/blob/main/logging_config.py): `logging_config.py`
- [Git Log Manager](https://github.com/simpnick6703/disgram/blob/main/git_manager.py): `git_manager.py`

### Telegram Integration

- [Telethon Client](https://github.com/simpnick6703/disgram/blob/main/telethon_client.py): `telethon_client.py`

### Other components

- **Operator**
- **Telegram Public**
- **Discord**
- **GitHub**

## Connections

- Operator → Worker Orchestrator: starts (evidence: `README.md`)
- Worker Orchestrator → Health & Admin API: starts API (evidence: `README.md`)
- Worker Orchestrator → Channel Worker: spawns chunks (evidence: `README.md`)
- Worker Orchestrator → Git Log Manager: initializes (evidence: `README.md`)
- Runtime Config → Worker Orchestrator: configures (evidence: `main.py`)
- Runtime Config → Channel Worker: configures (evidence: `webhook.py`)
- Channel Worker → Preview Scraper: scrapes channels (evidence: `README.md`)
- Preview Scraper → Telegram Public: fetches previews (evidence: `webhook.py`)
- Channel Worker → Message Parser: processes messages (evidence: `README.md`)
- Message Parser → Telethon Client: fetches rich text (evidence: `README.md`)
- Message Parser → Media Handling: extracts media (evidence: `README.md`)
- Media Handling → Telethon Client: downloads media (evidence: `README.md`)
- Media Handling → Telegram Public: downloads fallback media (evidence: `README.md`)
- Channel Worker → Discord Layout Sender: prepares content (evidence: `README.md`)
- Discord Layout Sender → Discord: sends webhook (evidence: `webhook.py`)
- Channel Worker → Log & Marker Handler: records markers (evidence: `README.md`)
- Health & Admin API → Log & Marker Handler: cleans and reads (evidence: `README.md`)
- Git Log Manager → Log & Marker Handler: persists log (evidence: `README.md`)
- Git Log Manager → GitHub: commits and pushes (evidence: `README.md`)
- Operator → Health & Admin API: checks status (evidence: `README.md`)
