# hackerheroop/msg-scheduler architecture

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

- Interactive diagram: https://gitdiagram.com/hackerheroop/msg-scheduler
- Repository: https://github.com/hackerheroop/msg-scheduler

## Overview

This is a Telegram channel-post scheduler with administrative controls for channels and scheduled posts, plus HTTP health checks. The visible main workflow is bot startup and command handling; scheduling and delivery are also represented in `main.py` and in a separate `scheduler.py` implementation. The excerpts do not establish that the standalone scheduler is wired into bot startup, or show all command registrations and persistence calls, so those relationships are omitted.

Main entry points: [`scheduler.py`](https://github.com/hackerheroop/msg-scheduler/blob/main/scheduler.py) (Scheduler Loop), [`main.py`](https://github.com/hackerheroop/msg-scheduler/blob/main/main.py) (Bot Admin), [`database.py`](https://github.com/hackerheroop/msg-scheduler/blob/main/database.py) (Post Storage), [`start.py`](https://github.com/hackerheroop/msg-scheduler/blob/main/start.py) (HTTP Health Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot Runtime"]
  node_admin["Bot Admin<br/>[main.py]"]
  node_channel_controls["Channel Controls<br/>[main.py]"]
  node_bot_startup["Bot Startup<br/>[main.py]"]
end

subgraph group_scheduling["Post Scheduling"]
  node_post_scheduling["Post Scheduling<br/>[main.py]"]
  node_post_dispatch["Scheduled Delivery<br/>[main.py]"]
  node_scheduler_loop["Scheduler Loop<br/>[scheduler.py]"]
end

subgraph group_persistence["Persistence"]
  node_post_storage["Post Storage<br/>[database.py]"]
  node_mongo[("MongoDB")]
end

subgraph group_operations["Health Checks"]
  node_web_health["HTTP Health Server<br/>[start.py]"]
end

node_health_actor(("Health Probe"))
node_telegram["Telegram"]

node_bot_startup -->|"runs bot"| node_admin
node_health_actor -.->|"requests health"| node_web_health
node_web_health -->|"starts bot"| node_bot_startup
node_scheduler_loop -->|"fetches and updates"| node_post_storage
node_post_storage -->|"persists posts"| node_mongo
node_scheduler_loop -->|"sends posts"| node_telegram
node_post_scheduling -.->|"dispatches due posts"| node_post_dispatch
node_admin -.->|"offers controls"| node_channel_controls

click node_admin "https://github.com/hackerheroop/msg-scheduler/blob/main/main.py"
click node_channel_controls "https://github.com/hackerheroop/msg-scheduler/blob/main/main.py"
click node_web_health "https://github.com/hackerheroop/msg-scheduler/blob/main/start.py"
click node_bot_startup "https://github.com/hackerheroop/msg-scheduler/blob/main/main.py"
click node_post_scheduling "https://github.com/hackerheroop/msg-scheduler/blob/main/main.py"
click node_post_dispatch "https://github.com/hackerheroop/msg-scheduler/blob/main/main.py"
click node_scheduler_loop "https://github.com/hackerheroop/msg-scheduler/blob/main/scheduler.py"
click node_post_storage "https://github.com/hackerheroop/msg-scheduler/blob/main/database.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_admin,node_channel_controls,node_bot_startup toneBlue
class node_post_scheduling,node_post_dispatch,node_scheduler_loop toneAmber
class node_post_storage,node_mongo toneMint
class node_web_health toneRose
class node_health_actor,node_telegram toneIndigo
```

## Components

### Bot Runtime

- [Bot Admin](https://github.com/hackerheroop/msg-scheduler/blob/main/main.py): `main.py`
- [Channel Controls](https://github.com/hackerheroop/msg-scheduler/blob/main/main.py): `main.py`
- [Bot Startup](https://github.com/hackerheroop/msg-scheduler/blob/main/main.py): `main.py`

### Post Scheduling

- [Post Scheduling](https://github.com/hackerheroop/msg-scheduler/blob/main/main.py): `main.py`
- [Scheduled Delivery](https://github.com/hackerheroop/msg-scheduler/blob/main/main.py): `main.py`
- [Scheduler Loop](https://github.com/hackerheroop/msg-scheduler/blob/main/scheduler.py): `scheduler.py`

### Persistence

- [Post Storage](https://github.com/hackerheroop/msg-scheduler/blob/main/database.py): `database.py`
- **MongoDB**

### Health Checks

- [HTTP Health Server](https://github.com/hackerheroop/msg-scheduler/blob/main/start.py): `start.py`

### Other components

- **Health Probe**
- **Telegram**

## Connections

- Bot Startup → Bot Admin: runs bot (evidence: `main.py`)
- Health Probe → HTTP Health Server: requests health
- HTTP Health Server → Bot Startup: starts bot (evidence: `start.py`)
- Scheduler Loop → Post Storage: fetches and updates (evidence: `scheduler.py`)
- Post Storage → MongoDB: persists posts (evidence: `database.py`)
- Scheduler Loop → Telegram: sends posts (evidence: `scheduler.py`)
- Post Scheduling → Scheduled Delivery: dispatches due posts (evidence: `main.py`)
- Bot Admin → Channel Controls: offers controls (evidence: `main.py`)
