# go-telegram-bot-api/telegram-bot-api architecture

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

## Overview

This repository is a Go client library wrapping Telegram’s Bot API, not a bot framework: applications construct typed requests, fetch updates by polling or webhook, and send API responses. The central transport and request dispatch live in bot.go; configs.go encodes endpoint-specific requests, helpers.go supplies constructors, and types.go plus passport.go define API payloads. The README documents broad API coverage and both polling and webhook workflows. Unsampled portions prevent mapping individual endpoint families or asserting additional internal call relationships.

Main entry points: [`bot.go`](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go) (Bot client), [`configs.go`](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/configs.go) (Request configurations), [`helpers.go`](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/helpers.go) (Request constructors), [`types.go`](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/types.go) (API data types)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Client runtime"]
  node_bot_client["Bot client<br/>[bot.go]"]
end

subgraph group_requests["Requests and models"]
  node_request_configs["Request configurations<br/>[configs.go]"]
  node_request_helpers["Request constructors<br/>[helpers.go]"]
  node_request_params["Parameter encoding<br/>[params.go]"]
  node_api_types["API data types<br/>[types.go]"]
  node_passport_types["Passport types<br/>[passport.go]"]
end

subgraph group_updates["Update delivery"]
  node_polling["Long polling<br/>[bot.go]"]
  node_webhook["Webhook handling<br/>[bot.go]"]
end

node_application(("Bot application"))
node_telegram_api["Telegram Bot API"]

node_application -->|"constructs requests"| node_request_helpers
node_application -->|"uses client"| node_bot_client
node_request_helpers -->|"creates configs"| node_request_configs
node_request_configs -->|"encodes parameters"| node_request_params
node_application -->|"supplies API configs"| node_request_configs
node_bot_client -->|"serializes requests"| node_request_params
node_bot_client -->|"sends API requests"| node_telegram_api
node_telegram_api -->|"returns responses"| node_bot_client
node_telegram_api -->|"provides updates"| node_polling
node_polling -->|"fetches updates"| node_bot_client
node_telegram_api -->|"delivers updates"| node_webhook
node_webhook -->|"yields updates"| node_application
node_application -->|"sends replies"| node_bot_client
node_api_types -.->|"models payloads"| node_bot_client
node_passport_types -.->|"extends API models"| node_api_types

click node_bot_client "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go"
click node_request_configs "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/configs.go"
click node_request_helpers "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/helpers.go"
click node_request_params "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/params.go"
click node_api_types "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/types.go"
click node_passport_types "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/passport.go"
click node_polling "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go"
click node_webhook "https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go"

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_client toneBlue
class node_request_configs,node_request_helpers,node_request_params,node_api_types,node_passport_types toneAmber
class node_polling,node_webhook,node_telegram_api toneMint
class node_application toneIndigo
```

## Components

### Client runtime

- [Bot client](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go): `bot.go`

### Requests and models

- [Request configurations](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/configs.go): `configs.go`
- [Request constructors](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/helpers.go): `helpers.go`
- [Parameter encoding](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/params.go): `params.go`
- [API data types](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/types.go): `types.go`
- [Passport types](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/passport.go): `passport.go`

### Update delivery

- [Long polling](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go): `bot.go`
- [Webhook handling](https://github.com/go-telegram-bot-api/telegram-bot-api/blob/master/bot.go): `bot.go`

### Other components

- **Bot application**
- **Telegram Bot API**

## Connections

- Bot application → Request constructors: constructs requests (evidence: `README.md`)
- Bot application → Bot client: uses client (evidence: `README.md`)
- Request constructors → Request configurations: creates configs (evidence: `helpers.go`)
- Request configurations → Parameter encoding: encodes parameters (evidence: `configs.go`)
- Bot application → Request configurations: supplies API configs (evidence: `README.md`)
- Bot client → Parameter encoding: serializes requests (evidence: `bot.go`)
- Bot client → Telegram Bot API: sends API requests (evidence: `README.md`)
- Telegram Bot API → Bot client: returns responses (evidence: `bot.go`)
- Telegram Bot API → Long polling: provides updates (evidence: `README.md`)
- Long polling → Bot client: fetches updates (evidence: `bot.go`)
- Telegram Bot API → Webhook handling: delivers updates (evidence: `README.md`)
- Webhook handling → Bot application: yields updates (evidence: `README.md`)
- Bot application → Bot client: sends replies (evidence: `README.md`)
- API data types → Bot client: models payloads
- Passport types → API data types: extends API models
