# terranc/claude-telegram-bot-bridge architecture

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

- Interactive diagram: https://gitdiagram.com/terranc/claude-telegram-bot-bridge
- Repository: https://github.com/terranc/claude-telegram-bot-bridge

## Overview

This is a Telegram bridge for remotely operating Claude Code in a chosen project. The main flow is a Telegram message handled by the bot, routed to a per-user Claude SDK session, and returned through progressive Telegram updates. Distinct branches cover voice input and output, session/history and revert controls, and access approval. The map includes documented capabilities whose implementation was not sampled; their relationships are shown only where README statements or excerpts support them.

Main entry points: [`core/bot.py`](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/bot.py) (Bot commands and routing), [`core/project_chat.py`](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/project_chat.py) (Project chat handler), [`utils/transcription.py`](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/transcription.py) (Speech transcription), [`session/manager.py`](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/session/manager.py) (Session manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Telegram interface"]
  node_bot["Bot commands and routing<br/>[bot.py]"]
end

subgraph group_claude["Claude interaction"]
  node_project_chat["Project chat handler<br/>[project_chat.py]"]
  node_streaming["Progressive updates<br/>[streaming.py]"]
end

subgraph group_voice["Voice processing"]
  node_audio["Audio conversion<br/>[audio_processor.py]"]
  node_transcription["Speech transcription<br/>[transcription.py]"]
  node_tos["Voice file upload<br/>[tos_uploader.py]"]
  node_tts["Voice reply synthesis<br/>[tts.py]"]
end

subgraph group_state["Sessions and operations"]
  node_session_manager["Session manager<br/>[manager.py]"]
  node_session_store[("JSON session store<br/>[store.py]")]
  node_config["Configuration<br/>[config.py]"]
  node_health["Health monitoring<br/>[health.py]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram"))
node_claude_sdk["Claude Code SDK"]
node_openai["OpenAI Whisper"]
node_volcengine["Volcengine ASR and TOS"]

node_user -->|"sends messages"| node_telegram
node_telegram -->|"delivers updates"| node_bot
node_bot -->|"routes chat"| node_project_chat
node_project_chat -->|"runs requests"| node_claude_sdk
node_project_chat -->|"updates drafts"| node_streaming
node_streaming -->|"edits messages"| node_telegram
node_bot -->|"reads session state"| node_session_manager
node_session_manager -->|"reads and writes"| node_session_store
node_session_manager -->|"reads timeout"| node_config
node_bot -->|"converts voice"| node_audio
node_audio -->|"prepares audio"| node_transcription
node_transcription -->|"transcribes"| node_openai
node_transcription -.->|"optional ASR"| node_volcengine
node_bot -->|"synthesizes replies"| node_tts
node_tos -->|"uploads voice files"| node_volcengine
node_bot -.->|"reports health"| node_health

click node_bot "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/bot.py"
click node_project_chat "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/project_chat.py"
click node_streaming "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/streaming.py"
click node_session_manager "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/session/manager.py"
click node_session_store "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/session/store.py"
click node_config "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/config.py"
click node_health "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/health.py"
click node_audio "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/audio_processor.py"
click node_transcription "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/transcription.py"
click node_tos "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/tos_uploader.py"
click node_tts "https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/tts.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_bot,node_user toneBlue
class node_project_chat,node_streaming toneAmber
class node_audio,node_transcription,node_tos,node_tts toneMint
class node_session_manager,node_session_store,node_config,node_health toneRose
class node_telegram,node_claude_sdk,node_openai,node_volcengine toneIndigo
```

## Components

### Telegram interface

- [Bot commands and routing](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/bot.py): `core/bot.py`

### Claude interaction

- [Project chat handler](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/project_chat.py): `core/project_chat.py`
- [Progressive updates](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/core/streaming.py): `core/streaming.py`

### Voice processing

- [Audio conversion](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/audio_processor.py): `utils/audio_processor.py`
- [Speech transcription](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/transcription.py): `utils/transcription.py`
- [Voice file upload](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/tos_uploader.py): `utils/tos_uploader.py`
- [Voice reply synthesis](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/tts.py): `utils/tts.py`

### Sessions and operations

- [Session manager](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/session/manager.py): `session/manager.py`
- [JSON session store](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/session/store.py): `session/store.py`
- [Configuration](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/config.py): `utils/config.py`
- [Health monitoring](https://github.com/terranc/claude-telegram-bot-bridge/blob/master/utils/health.py): `utils/health.py`

### Other components

- **Telegram user**
- **Telegram**
- **Claude Code SDK**
- **OpenAI Whisper**
- **Volcengine ASR and TOS**

## Connections

- Telegram user → Telegram: sends messages (evidence: `README.md`)
- Telegram → Bot commands and routing: delivers updates (evidence: `README.md`)
- Bot commands and routing → Project chat handler: routes chat (evidence: `core/bot.py`)
- Project chat handler → Claude Code SDK: runs requests (evidence: `README.md`)
- Project chat handler → Progressive updates: updates drafts (evidence: `core/project_chat.py`)
- Progressive updates → Telegram: edits messages (evidence: `core/streaming.py`)
- Bot commands and routing → Session manager: reads session state (evidence: `core/bot.py`)
- Session manager → JSON session store: reads and writes (evidence: `session/manager.py`)
- Session manager → Configuration: reads timeout (evidence: `session/manager.py`)
- Bot commands and routing → Audio conversion: converts voice (evidence: `README.md`)
- Audio conversion → Speech transcription: prepares audio (evidence: `README.md`)
- Speech transcription → OpenAI Whisper: transcribes (evidence: `README.md`)
- Speech transcription → Volcengine ASR and TOS: optional ASR
- Bot commands and routing → Voice reply synthesis: synthesizes replies (evidence: `README.md`)
- Voice file upload → Volcengine ASR and TOS: uploads voice files (evidence: `utils/tos_uploader.py`)
- Bot commands and routing → Health monitoring: reports health
