# enotkiller/telegram-bot-for-college architecture

> Architecture diagram of the GitHub repository enotkiller/telegram-bot-for-college, 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/enotkiller/telegram-bot-for-college
- Repository: https://github.com/enotkiller/telegram-bot-for-college

## Overview

This is an asynchronous Telegram bot that answers schedule queries and sends timed lesson notifications. Telegram commands enter through the bot, which uses the system layer for date, week, and lesson calculations and the database layer for schedule and user data; scheduled notifications are sent back through Telegram. The README documents JSON-to-Redis loading and the command set. Excerpts show the main interactions, but do not expose every handler or storage operation, so those relationships are limited to documented or directly supported links.

Main entry points: [`code/Bot.py`](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Bot.py) (Bot commands), [`code/DataBase.py`](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/DataBase.py) (Database access), [`code/System.py`](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py) (Time and week logic), [`code/Debug.py`](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Debug.py) (Debug logging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Telegram interaction"]
  node_entry["Application entry<br/>[main.py]"]
  node_commands["Bot commands<br/>[Bot.py]"]
  node_timed["Timed notifications<br/>[Bot.py]"]
end

subgraph group_schedule["Schedule logic"]
  node_calendar["Time and week logic<br/>[System.py]"]
  node_lesson["Lesson resolution<br/>[System.py]"]
  node_cancellations["Lesson cancellations<br/>[System.py]"]
end

subgraph group_storage["Data and persistence"]
  node_jsondata["Schedule JSON data"]
  node_datastore["Database access<br/>[DataBase.py]"]
  node_redis[("Redis store")]
  node_pings["Ping registry<br/>[DataBase.py]"]
  node_debug["Debug logging<br/>[Debug.py]"]
end

node_students(("Students"))
node_telegram{{"Telegram Bot API"}}

node_students -->|"send commands"| node_telegram
node_telegram -->|"delivers messages"| node_commands
node_entry -->|"starts bot"| node_commands
node_commands -->|"queries time"| node_calendar
node_commands -->|"requests lessons"| node_lesson
node_commands -->|"reads user data"| node_datastore
node_commands -.->|"toggles cancellations"| node_cancellations
node_timed -->|"checks schedule"| node_calendar
node_timed -->|"gets recipients"| node_datastore
node_timed -->|"sends notifications"| node_telegram
node_calendar -->|"reads time settings"| node_datastore
node_lesson -->|"gets lesson data"| node_datastore
node_jsondata -->|"loads configuration"| node_datastore
node_datastore -->|"reads and writes"| node_redis
node_pings -->|"stores subscribers"| node_redis
node_commands -->|"logs activity"| node_debug
node_datastore -->|"logs operations"| node_debug
node_calendar -->|"logs calculations"| node_debug

click node_entry "https://github.com/enotkiller/telegram-bot-for-college/blob/main/main.py"
click node_commands "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Bot.py"
click node_timed "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Bot.py"
click node_calendar "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py"
click node_lesson "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py"
click node_cancellations "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py"
click node_jsondata "https://github.com/enotkiller/telegram-bot-for-college/tree/main/data"
click node_datastore "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/DataBase.py"
click node_pings "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/DataBase.py"
click node_debug "https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Debug.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_entry,node_commands,node_timed toneBlue
class node_calendar,node_lesson,node_cancellations toneAmber
class node_jsondata,node_datastore,node_redis,node_pings,node_debug,node_telegram toneMint
class node_students toneIndigo
```

## Components

### Telegram interaction

- [Application entry](https://github.com/enotkiller/telegram-bot-for-college/blob/main/main.py): `main.py`
- [Bot commands](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Bot.py): `code/Bot.py`
- [Timed notifications](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Bot.py): `code/Bot.py`

### Schedule logic

- [Time and week logic](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py): `code/System.py`
- [Lesson resolution](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py): `code/System.py`
- [Lesson cancellations](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/System.py): `code/System.py`

### Data and persistence

- [Schedule JSON data](https://github.com/enotkiller/telegram-bot-for-college/tree/main/data): `data`
- [Database access](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/DataBase.py): `code/DataBase.py`
- **Redis store**
- [Ping registry](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/DataBase.py): `code/DataBase.py`
- [Debug logging](https://github.com/enotkiller/telegram-bot-for-college/blob/main/code/Debug.py): `code/Debug.py`

### Other components

- **Students**
- **Telegram Bot API**

## Connections

- Students → Telegram Bot API: send commands (evidence: `README.md`)
- Telegram Bot API → Bot commands: delivers messages (evidence: `README.md`)
- Application entry → Bot commands: starts bot (evidence: `main.py`)
- Bot commands → Time and week logic: queries time (evidence: `code/Bot.py`)
- Bot commands → Lesson resolution: requests lessons (evidence: `code/Bot.py`)
- Bot commands → Database access: reads user data (evidence: `code/Bot.py`)
- Bot commands → Lesson cancellations: toggles cancellations (evidence: `code/Bot.py`)
- Timed notifications → Time and week logic: checks schedule (evidence: `code/Bot.py`)
- Timed notifications → Database access: gets recipients (evidence: `code/Bot.py`)
- Timed notifications → Telegram Bot API: sends notifications (evidence: `code/Bot.py`)
- Time and week logic → Database access: reads time settings (evidence: `code/System.py`)
- Lesson resolution → Database access: gets lesson data (evidence: `code/System.py`)
- Schedule JSON data → Database access: loads configuration (evidence: `README.md`)
- Database access → Redis store: reads and writes (evidence: `code/DataBase.py`)
- Ping registry → Redis store: stores subscribers (evidence: `code/DataBase.py`)
- Bot commands → Debug logging: logs activity (evidence: `code/Bot.py`)
- Database access → Debug logging: logs operations (evidence: `code/DataBase.py`)
- Time and week logic → Debug logging: logs calculations (evidence: `code/System.py`)
