# iqbwl/domainbot architecture

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

- Interactive diagram: https://gitdiagram.com/iqbwl/domainbot
- Repository: https://github.com/iqbwl/domainbot

## Overview

DomainBot monitors domain expiration through Telegram commands and CSV imports: requests enter the bot runtime, handlers validate and process them, WHOIS/RDAP supplies registration data when needed, and SQLite stores monitored records. Users can request reports, checks, edits, and alerts; background services refresh records and dispatch scheduled summaries. The README also documents a terminal CSV-import path. Edges reflect shown calls or documented capabilities; unsampled scheduler and import details are represented only where supported.

Main entry points: [`index.js`](https://github.com/iqbwl/domainbot/blob/main/index.js) (Bot runtime), [`handlers/commands.js`](https://github.com/iqbwl/domainbot/blob/main/handlers/commands.js) (Command handlers), [`services/alertService.js`](https://github.com/iqbwl/domainbot/blob/main/services/alertService.js) (Expiration alerts), [`lib/whois.js`](https://github.com/iqbwl/domainbot/blob/main/lib/whois.js) (WHOIS and RDAP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Bot Runtime"]
  node_app["Bot runtime<br/>[index.js]"]
  node_config["Configuration<br/>[config.js]"]
end

subgraph group_domain_ops["Domain Operations"]
  node_commands["Command handlers<br/>[commands.js]"]
  node_upload["CSV upload handler<br/>[upload.js]"]
  node_csv["CSV parser<br/>[csv.js]"]
  node_import_cli["CSV import CLI<br/>[import.js]"]
  node_whois["WHOIS and RDAP<br/>[whois.js]"]
end

subgraph group_data["Data and Reports"]
  node_database[("Domain database<br/>[db.js]")]
  node_reports["Markdown reports<br/>[markdown.js]"]
  node_telegram_helpers["Telegram helpers<br/>[telegram.js]"]
end

subgraph group_background["Background Services"]
  node_auto_checker["Auto-checker<br/>[autoChecker.js]"]
  node_sync_state["Sync state<br/>[syncState.js]"]
  node_alerts["Expiration alerts<br/>[alertService.js]"]
end

node_telegram_user(("Telegram users"))
node_terminal_user(("CLI operator"))
node_registry_network{{"RDAP / WHOIS servers"}}
node_telegram_service{{"Telegram API"}}

node_telegram_user -->|"sends updates"| node_app
node_app -->|"registers"| node_commands
node_app -->|"registers"| node_upload
node_app -->|"initializes"| node_database
node_app -->|"starts"| node_auto_checker
node_app -->|"starts scheduler"| node_alerts
node_app -->|"configures"| node_config
node_commands -->|"reads and writes"| node_database
node_commands -->|"looks up"| node_whois
node_commands -->|"generates"| node_reports
node_commands -->|"formats and sends"| node_telegram_helpers
node_commands -->|"runs test"| node_alerts
node_commands -->|"checks state"| node_sync_state
node_upload -->|"parses"| node_csv
node_upload -->|"deduplicates and saves"| node_database
node_upload -->|"looks up missing data"| node_whois
node_upload -->|"checks permissions"| node_telegram_helpers
node_terminal_user -->|"runs import"| node_import_cli
node_import_cli -->|"parses"| node_csv
node_import_cli -->|"imports records"| node_database
node_import_cli -->|"syncs domain data"| node_whois
node_whois -->|"queries RDAP / WHOIS"| node_registry_network
node_auto_checker -->|"selects and updates"| node_database
node_auto_checker -->|"checks domains"| node_whois
node_auto_checker -->|"checks sync flag"| node_sync_state
node_auto_checker -->|"uses interval"| node_config
node_alerts -->|"reads and updates"| node_database
node_alerts -->|"calculates days left"| node_whois
node_alerts -->|"formats alert table"| node_reports
node_alerts -->|"sends alerts"| node_telegram_helpers
node_alerts -->|"delivers messages"| node_telegram_service
node_telegram_helpers -->|"sends via API"| node_telegram_service
node_reports -->|"calculates days left"| node_whois

click node_app "https://github.com/iqbwl/domainbot/blob/main/index.js"
click node_config "https://github.com/iqbwl/domainbot/blob/main/config.js"
click node_commands "https://github.com/iqbwl/domainbot/blob/main/handlers/commands.js"
click node_upload "https://github.com/iqbwl/domainbot/blob/main/handlers/upload.js"
click node_csv "https://github.com/iqbwl/domainbot/blob/main/lib/csv.js"
click node_import_cli "https://github.com/iqbwl/domainbot/blob/main/import.js"
click node_whois "https://github.com/iqbwl/domainbot/blob/main/lib/whois.js"
click node_database "https://github.com/iqbwl/domainbot/blob/main/lib/db.js"
click node_reports "https://github.com/iqbwl/domainbot/blob/main/lib/markdown.js"
click node_telegram_helpers "https://github.com/iqbwl/domainbot/blob/main/lib/telegram.js"
click node_auto_checker "https://github.com/iqbwl/domainbot/blob/main/services/autoChecker.js"
click node_sync_state "https://github.com/iqbwl/domainbot/blob/main/services/syncState.js"
click node_alerts "https://github.com/iqbwl/domainbot/blob/main/services/alertService.js"

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_app,node_config,node_telegram_user toneBlue
class node_commands,node_upload,node_csv,node_import_cli,node_whois toneAmber
class node_database,node_reports,node_telegram_helpers,node_registry_network,node_telegram_service toneMint
class node_auto_checker,node_sync_state,node_alerts toneRose
class node_terminal_user toneIndigo
```

## Components

### Bot Runtime

- [Bot runtime](https://github.com/iqbwl/domainbot/blob/main/index.js): `index.js`
- [Configuration](https://github.com/iqbwl/domainbot/blob/main/config.js): `config.js`

### Domain Operations

- [Command handlers](https://github.com/iqbwl/domainbot/blob/main/handlers/commands.js): `handlers/commands.js`
- [CSV upload handler](https://github.com/iqbwl/domainbot/blob/main/handlers/upload.js): `handlers/upload.js`
- [CSV parser](https://github.com/iqbwl/domainbot/blob/main/lib/csv.js): `lib/csv.js`
- [CSV import CLI](https://github.com/iqbwl/domainbot/blob/main/import.js): `import.js`
- [WHOIS and RDAP](https://github.com/iqbwl/domainbot/blob/main/lib/whois.js): `lib/whois.js`

### Data and Reports

- [Domain database](https://github.com/iqbwl/domainbot/blob/main/lib/db.js): `lib/db.js`
- [Markdown reports](https://github.com/iqbwl/domainbot/blob/main/lib/markdown.js): `lib/markdown.js`
- [Telegram helpers](https://github.com/iqbwl/domainbot/blob/main/lib/telegram.js): `lib/telegram.js`

### Background Services

- [Auto-checker](https://github.com/iqbwl/domainbot/blob/main/services/autoChecker.js): `services/autoChecker.js`
- [Sync state](https://github.com/iqbwl/domainbot/blob/main/services/syncState.js): `services/syncState.js`
- [Expiration alerts](https://github.com/iqbwl/domainbot/blob/main/services/alertService.js): `services/alertService.js`

### Other components

- **Telegram users**
- **CLI operator**
- **RDAP / WHOIS servers**
- **Telegram API**

## Connections

- Telegram users → Bot runtime: sends updates (evidence: `README.md`)
- Bot runtime → Command handlers: registers (evidence: `index.js`)
- Bot runtime → CSV upload handler: registers (evidence: `index.js`)
- Bot runtime → Domain database: initializes (evidence: `index.js`)
- Bot runtime → Auto-checker: starts (evidence: `index.js`)
- Bot runtime → Expiration alerts: starts scheduler (evidence: `index.js`)
- Bot runtime → Configuration: configures (evidence: `index.js`)
- Command handlers → Domain database: reads and writes (evidence: `handlers/commands.js`)
- Command handlers → WHOIS and RDAP: looks up (evidence: `handlers/commands.js`)
- Command handlers → Markdown reports: generates (evidence: `handlers/commands.js`)
- Command handlers → Telegram helpers: formats and sends (evidence: `handlers/commands.js`)
- Command handlers → Expiration alerts: runs test (evidence: `handlers/commands.js`)
- Command handlers → Sync state: checks state (evidence: `handlers/commands.js`)
- CSV upload handler → CSV parser: parses (evidence: `handlers/upload.js`)
- CSV upload handler → Domain database: deduplicates and saves (evidence: `handlers/upload.js`)
- CSV upload handler → WHOIS and RDAP: looks up missing data (evidence: `handlers/upload.js`)
- CSV upload handler → Telegram helpers: checks permissions (evidence: `handlers/upload.js`)
- CLI operator → CSV import CLI: runs import (evidence: `README.md`)
- CSV import CLI → CSV parser: parses (evidence: `import.js`)
- CSV import CLI → Domain database: imports records (evidence: `import.js`)
- CSV import CLI → WHOIS and RDAP: syncs domain data (evidence: `import.js`)
- WHOIS and RDAP → RDAP / WHOIS servers: queries RDAP / WHOIS (evidence: `README.md`)
- Auto-checker → Domain database: selects and updates (evidence: `services/autoChecker.js`)
- Auto-checker → WHOIS and RDAP: checks domains (evidence: `services/autoChecker.js`)
- Auto-checker → Sync state: checks sync flag (evidence: `services/autoChecker.js`)
- Auto-checker → Configuration: uses interval (evidence: `services/autoChecker.js`)
- Expiration alerts → Domain database: reads and updates (evidence: `services/alertService.js`)
- Expiration alerts → WHOIS and RDAP: calculates days left (evidence: `services/alertService.js`)
- Expiration alerts → Markdown reports: formats alert table (evidence: `services/alertService.js`)
- Expiration alerts → Telegram helpers: sends alerts (evidence: `services/alertService.js`)
- Expiration alerts → Telegram API: delivers messages
- Telegram helpers → Telegram API: sends via API (evidence: `lib/telegram.js`)
- Markdown reports → WHOIS and RDAP: calculates days left (evidence: `lib/markdown.js`)
