# yuldashevsardor/telegram-bot architecture

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

- Interactive diagram: https://gitdiagram.com/yuldashevsardor/telegram-bot
- Repository: https://github.com/yuldashevsardor/telegram-bot

## Overview

This is a Telegram bot that accepts font-conversion requests and returns fonts converted among TTF, OTF, WOFF, WOFF2, EOT, and SVG; FontForge performs conversion, while PostgreSQL stores users and sessions. The runtime path is represented from Telegram interaction through bot commands, validation, and conversion, with the outbox handling outbound delivery. Application bootstrap and persistence are separate internal layers. Several runtime modules were not sampled, so inferred links are dashed; documented product capabilities are retained without claiming their unsampled implementation details were inspected.

Main entry points: [`src/telegram/bot/bot.ts`](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/bot/bot.ts) (Bot runtime), [`src/bootstrap/application/application.ts`](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/bootstrap/application/application.ts) (Application lifecycle), [`src/telegram/command`](https://github.com/yuldashevsardor/telegram-bot/tree/main/src/telegram/command) (Bot commands), [`src/telegram/outbox/outbox-message-processor.ts`](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-message-processor.ts) (Outbox processor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Telegram interaction"]
  node_bot["Bot runtime<br/>[bot.ts]"]
  node_commands["Bot commands"]
  node_conversation["Start conversation"]
  node_middleware["Request middleware"]
end

subgraph group_conversion["Font conversion"]
  node_validator_resolver["Validator resolver"]
  node_font_validators["Format validators"]
  node_converter["Conversion service<br/>[font-convertor.ts]"]
  node_converter_factory["Converter factory"]
  node_format_converters["Format converters"]
  node_fontforge["FontForge<br/>[font-forge.ts]"]
end

subgraph group_delivery["Outbound delivery"]
  node_outbox_sender["Outbox sender<br/>[outbox-sender.ts]"]
  node_outbox_processor["Outbox processor"]
  node_failure_handler["Failure handling"]
  node_outbox_store[("Outbox store<br/>[outbox-store.ts]")]
  node_task_queue["Task queue<br/>[task-queue.ts]"]
end

subgraph group_persistence["Persistence"]
  node_user_service["User service<br/>[user-service.ts]"]
  node_user_repo["User repository"]
  node_session_storage["Session storage<br/>[pgsql-storage.ts]"]
  node_database[("PostgreSQL<br/>[database.ts]")]
end

subgraph group_platform["Application platform"]
  node_application["Application lifecycle<br/>[application.ts]"]
  node_config["Configuration"]
  node_entrypoint["Process entrypoint<br/>[app.ts]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram API"))

node_user -.->|"sends request"| node_telegram
node_telegram -.->|"delivers updates"| node_bot
node_bot -.->|"dispatches"| node_commands
node_bot -.->|"runs through"| node_middleware
node_bot -.->|"routes conversation"| node_conversation
node_commands -.->|"validates input"| node_validator_resolver
node_validator_resolver -.->|"selects validator"| node_font_validators
node_commands -.->|"requests conversion"| node_converter
node_converter -.->|"creates converter"| node_converter_factory
node_converter_factory -.->|"selects conversion"| node_format_converters
node_format_converters -.->|"delegates conversion"| node_fontforge
node_commands -.->|"queues response"| node_outbox_sender
node_outbox_sender -.->|"dispatches message"| node_outbox_processor
node_outbox_processor -.->|"reads and updates"| node_outbox_store
node_outbox_processor -.->|"handles failures"| node_failure_handler
node_outbox_processor -.->|"sends message"| node_telegram
node_bot -.->|"updates user"| node_user_service
node_user_service -.->|"uses repository"| node_user_repo
node_user_repo -->|"queries users"| node_database
node_bot -.->|"persists sessions"| node_session_storage
node_session_storage -->|"queries sessions"| node_database
node_entrypoint -->|"bootstraps"| node_application
node_application -->|"checks connection"| node_database
node_application -->|"drains queue"| node_task_queue
node_application -->|"sets up and stops"| node_bot
node_application -.->|"assembles settings"| node_config

click node_bot "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/bot/bot.ts"
click node_commands "https://github.com/yuldashevsardor/telegram-bot/tree/main/src/telegram/command"
click node_conversation "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/conversation/start/start.conversation.ts"
click node_middleware "https://github.com/yuldashevsardor/telegram-bot/tree/main/src/telegram/middleware"
click node_user_service "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/user/service/user-service.ts"
click node_user_repo "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/user/pgsql-repository/pgsql-user-repository.ts"
click node_session_storage "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/session/pgsql-storage.ts"
click node_database "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/platform/database/database.ts"
click node_validator_resolver "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/validator/font-validator-resolver.ts"
click node_font_validators "https://github.com/yuldashevsardor/telegram-bot/tree/main/src/font-convertor/validator"
click node_converter "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/font-convertor.ts"
click node_converter_factory "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/convertor/convertor-factory.ts"
click node_format_converters "https://github.com/yuldashevsardor/telegram-bot/tree/main/src/font-convertor/convertor"
click node_fontforge "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/font-forge/font-forge.ts"
click node_outbox_sender "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-sender.ts"
click node_outbox_processor "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-message-processor.ts"
click node_failure_handler "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-failure-handler.ts"
click node_outbox_store "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/store/outbox-store.ts"
click node_task_queue "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbound-queue/task-queue.ts"
click node_application "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/bootstrap/application/application.ts"
click node_config "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/bootstrap/config/container/config-container.ts"
click node_entrypoint "https://github.com/yuldashevsardor/telegram-bot/blob/main/src/app.ts"

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_bot,node_commands,node_conversation,node_middleware,node_user toneBlue
class node_validator_resolver,node_font_validators,node_converter,node_converter_factory,node_format_converters,node_fontforge toneAmber
class node_outbox_sender,node_outbox_processor,node_failure_handler,node_outbox_store,node_task_queue,node_telegram toneMint
class node_user_service,node_user_repo,node_session_storage,node_database toneRose
class node_application,node_config,node_entrypoint toneIndigo
```

## Components

### Telegram interaction

- [Bot runtime](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/bot/bot.ts): `src/telegram/bot/bot.ts`
- [Bot commands](https://github.com/yuldashevsardor/telegram-bot/tree/main/src/telegram/command): `src/telegram/command`
- [Start conversation](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/conversation/start/start.conversation.ts): `src/telegram/conversation/start/start.conversation.ts`
- [Request middleware](https://github.com/yuldashevsardor/telegram-bot/tree/main/src/telegram/middleware): `src/telegram/middleware`

### Font conversion

- [Validator resolver](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/validator/font-validator-resolver.ts): `src/font-convertor/validator/font-validator-resolver.ts`
- [Format validators](https://github.com/yuldashevsardor/telegram-bot/tree/main/src/font-convertor/validator): `src/font-convertor/validator`
- [Conversion service](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/font-convertor.ts): `src/font-convertor/font-convertor.ts`
- [Converter factory](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/convertor/convertor-factory.ts): `src/font-convertor/convertor/convertor-factory.ts`
- [Format converters](https://github.com/yuldashevsardor/telegram-bot/tree/main/src/font-convertor/convertor): `src/font-convertor/convertor`
- [FontForge](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/font-convertor/font-forge/font-forge.ts): `src/font-convertor/font-forge/font-forge.ts`

### Outbound delivery

- [Outbox sender](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-sender.ts): `src/telegram/outbox/outbox-sender.ts`
- [Outbox processor](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-message-processor.ts): `src/telegram/outbox/outbox-message-processor.ts`
- [Failure handling](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/outbox-failure-handler.ts): `src/telegram/outbox/outbox-failure-handler.ts`
- [Outbox store](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbox/store/outbox-store.ts): `src/telegram/outbox/store/outbox-store.ts`
- [Task queue](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/outbound-queue/task-queue.ts): `src/telegram/outbound-queue/task-queue.ts`

### Persistence

- [User service](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/user/service/user-service.ts): `src/telegram/user/service/user-service.ts`
- [User repository](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/user/pgsql-repository/pgsql-user-repository.ts): `src/telegram/user/pgsql-repository/pgsql-user-repository.ts`
- [Session storage](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/telegram/session/pgsql-storage.ts): `src/telegram/session/pgsql-storage.ts`
- [PostgreSQL](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/platform/database/database.ts): `src/platform/database/database.ts`

### Application platform

- [Application lifecycle](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/bootstrap/application/application.ts): `src/bootstrap/application/application.ts`
- [Configuration](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/bootstrap/config/container/config-container.ts): `src/bootstrap/config/container/config-container.ts`
- [Process entrypoint](https://github.com/yuldashevsardor/telegram-bot/blob/main/src/app.ts): `src/app.ts`

### Other components

- **Telegram user**
- **Telegram API**

## Connections

- Telegram user → Telegram API: sends request
- Telegram API → Bot runtime: delivers updates
- Bot runtime → Bot commands: dispatches
- Bot runtime → Request middleware: runs through
- Bot runtime → Start conversation: routes conversation
- Bot commands → Validator resolver: validates input
- Validator resolver → Format validators: selects validator
- Bot commands → Conversion service: requests conversion
- Conversion service → Converter factory: creates converter
- Converter factory → Format converters: selects conversion
- Format converters → FontForge: delegates conversion
- Bot commands → Outbox sender: queues response
- Outbox sender → Outbox processor: dispatches message
- Outbox processor → Outbox store: reads and updates
- Outbox processor → Failure handling: handles failures
- Outbox processor → Telegram API: sends message
- Bot runtime → User service: updates user
- User service → User repository: uses repository
- User repository → PostgreSQL: queries users (evidence: `src/telegram/user/pgsql-repository/pgsql-user-repository.ts`)
- Bot runtime → Session storage: persists sessions
- Session storage → PostgreSQL: queries sessions (evidence: `src/telegram/session/pgsql-storage.ts`)
- Process entrypoint → Application lifecycle: bootstraps (evidence: `src/app.ts`)
- Application lifecycle → PostgreSQL: checks connection (evidence: `src/bootstrap/application/application.ts`)
- Application lifecycle → Task queue: drains queue (evidence: `src/bootstrap/application/application.ts`)
- Application lifecycle → Bot runtime: sets up and stops (evidence: `src/bootstrap/application/application.ts`)
- Application lifecycle → Configuration: assembles settings
