# vikizv/hb_bot architecture

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

- Interactive diagram: https://gitdiagram.com/vikizv/hb_bot
- Repository: https://github.com/vikizv/hb_bot

## Overview

HB_Bot is a Telegram birthday-notification bot. Its main flow starts in main.py, checks MySQL for birthdays matching today, requests a personalized greeting from OpenRouter, and sends it to the configured administrator. The bot also handles /start, while the DB class provides person insert and update operations. Edges reflect calls visible in the excerpts or capabilities explicitly documented in the README; configuration is described there but no config.py is present in the tree.

Main entry points: [`bot.py`](https://github.com/vikizv/hb_bot/blob/main/bot.py) (Bot logic), [`main.py`](https://github.com/vikizv/hb_bot/blob/main/main.py) (Entry point), [`db.py`](https://github.com/vikizv/hb_bot/blob/main/db.py) (DB operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot runtime"]
  node_main["Entry point<br/>[main.py]"]
  node_bot["Bot logic<br/>[bot.py]"]
end

subgraph group_data["Birthday data"]
  node_dbclass["DB operations<br/>[db.py]"]
end

node_user(("Telegram user"))
node_admin(("Administrator"))
node_openrouter{{"OpenRouter AI"}}
node_mysql[("MySQL")]

node_main -->|"starts check"| node_bot
node_main -->|"starts polling"| node_bot
node_bot -->|"creates and connects"| node_dbclass
node_bot -->|"queries birthdays"| node_mysql
node_bot -->|"requests greeting"| node_openrouter
node_bot -->|"sends greeting"| node_admin
node_user -->|"sends /start"| node_bot
node_bot -->|"replies"| node_user
node_dbclass -->|"connects, inserts, updates"| node_mysql

click node_main "https://github.com/vikizv/hb_bot/blob/main/main.py"
click node_bot "https://github.com/vikizv/hb_bot/blob/main/bot.py"
click node_dbclass "https://github.com/vikizv/hb_bot/blob/main/db.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_main,node_bot,node_user toneBlue
class node_dbclass,node_mysql toneAmber
class node_admin toneIndigo
class node_openrouter toneMint
```

## Components

### Bot runtime

- [Entry point](https://github.com/vikizv/hb_bot/blob/main/main.py): `main.py`
- [Bot logic](https://github.com/vikizv/hb_bot/blob/main/bot.py): `bot.py`

### Birthday data

- [DB operations](https://github.com/vikizv/hb_bot/blob/main/db.py): `db.py`

### Other components

- **Telegram user**
- **Administrator**
- **OpenRouter AI**
- **MySQL**

## Connections

- Entry point → Bot logic: starts check (evidence: `main.py`)
- Entry point → Bot logic: starts polling (evidence: `main.py`)
- Bot logic → DB operations: creates and connects (evidence: `bot.py`)
- Bot logic → MySQL: queries birthdays (evidence: `bot.py`)
- Bot logic → OpenRouter AI: requests greeting (evidence: `bot.py`)
- Bot logic → Administrator: sends greeting (evidence: `bot.py`)
- Telegram user → Bot logic: sends /start (evidence: `bot.py`)
- Bot logic → Telegram user: replies (evidence: `bot.py`)
- DB operations → MySQL: connects, inserts, updates (evidence: `db.py`)
