# overwirehq/claude-code-telegram architecture

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

- Interactive diagram: https://gitdiagram.com/overwirehq/claude-code-telegram
- Repository: https://github.com/overwirehq/claude-code-telegram

## Overview

Claude Code Telegram Bot turns Telegram conversations and automation triggers into Claude Code work, then returns responses through Telegram. The main interaction path is Telegram updates → bot routing → Claude execution → session persistence and formatted replies. Separate branches cover classic commands and file, image, voice, Git, quick-action, and export capabilities; webhook and scheduled events use the event bus and agent handlers. Storage, project-thread synchronization, authentication, validation, rate limiting, and audit logging provide supporting services. Some capabilities are README-documented but their runtime wiring was not sampled, so those relationships are omitted or marked unverified.

Main entry points: [`src/main.py`](https://github.com/overwirehq/claude-code-telegram/blob/main/src/main.py) (Application startup), [`src/bot/handlers/message.py`](https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/handlers/message.py) (Message handling), [`src/claude/facade.py`](https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/facade.py) (Claude facade), [`src/events/bus.py`](https://github.com/overwirehq/claude-code-telegram/blob/main/src/events/bus.py) (Event bus)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_telegram["Telegram interaction"]
  node_main["Application startup<br/>[main.py]"]
  node_botcore["Bot runtime<br/>[core.py]"]
  node_routing["Update orchestration<br/>[orchestrator.py]"]
  node_messages["Message handling<br/>[message.py]"]
  node_commands["Classic commands<br/>[command.py]"]
  node_features["Interaction features"]
  node_formatting["Response formatting<br/>[formatting.py]"]
end

subgraph group_claude["Claude and projects"]
  node_claude["Claude integration<br/>[sdk_integration.py]"]
  node_facade["Claude facade<br/>[facade.py]"]
  node_sessions["Session management<br/>[session.py]"]
  node_projects["Project registry<br/>[registry.py]"]
  node_threads["Project threads<br/>[thread_manager.py]"]
end

subgraph group_automation["Automation and events"]
  node_api["Webhook API<br/>[server.py]"]
  node_scheduler["Job scheduler<br/>[scheduler.py]"]
  node_bus["Event bus<br/>[bus.py]"]
  node_eventhandlers["Agent and notification handlers<br/>[handlers.py]"]
  node_notifications["Notification delivery<br/>[service.py]"]
end

subgraph group_platform["Security and persistence"]
  node_security["Authentication and audit<br/>[auth.py]"]
  node_validators["Path validation<br/>[validators.py]"]
  node_ratelimit["Rate limiting<br/>[rate_limiter.py]"]
  node_storage["Storage services<br/>[facade.py]"]
  node_database[("SQLite database<br/>[database.py]")]
  node_sessionstore["Persistent sessions<br/>[session_storage.py]"]
  node_config["Configuration<br/>[settings.py]"]
end

node_user(("Telegram user"))
node_telegram(("Telegram platform"))

node_user -->|"sends messages"| node_telegram
node_telegram -.->|"delivers updates"| node_botcore
node_main -->|"initializes"| node_botcore
node_botcore -.->|"routes updates"| node_routing
node_routing -->|"dispatches messages"| node_messages
node_routing -->|"dispatches commands"| node_commands
node_messages -->|"requests Claude work"| node_facade
node_commands -.->|"requests Claude work"| node_facade
node_facade -->|"delegates execution"| node_claude
node_facade -->|"manages sessions"| node_sessions
node_claude -->|"checks file paths"| node_validators
node_messages -->|"formats replies"| node_formatting
node_routing -.->|"coordinates features"| node_features
node_main -.->|"configures webhooks"| node_api
node_api -->|"publishes events"| node_bus
node_scheduler -.->|"publishes triggers"| node_bus
node_bus -->|"dispatches events"| node_eventhandlers
node_eventhandlers -->|"runs Claude tasks"| node_facade
node_eventhandlers -->|"publishes responses"| node_bus
node_notifications -.->|"subscribes to responses"| node_bus
node_main -->|"initializes storage"| node_storage
node_storage -->|"uses database"| node_database
node_sessionstore -->|"persists sessions"| node_database
node_sessions -.->|"stores session state"| node_sessionstore
node_main -->|"configures authentication"| node_security
node_main -->|"loads settings"| node_config
node_messages -->|"checks request limits"| node_ratelimit
node_messages -->|"validates inputs"| node_validators
node_threads -->|"resolves projects"| node_projects
node_threads -->|"persists mappings"| node_storage

click node_main "https://github.com/overwirehq/claude-code-telegram/blob/main/src/main.py"
click node_botcore "https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/core.py"
click node_routing "https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/orchestrator.py"
click node_messages "https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/handlers/message.py"
click node_commands "https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/handlers/command.py"
click node_features "https://github.com/overwirehq/claude-code-telegram/tree/main/src/bot/features"
click node_formatting "https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/utils/formatting.py"
click node_claude "https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/sdk_integration.py"
click node_facade "https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/facade.py"
click node_sessions "https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/session.py"
click node_projects "https://github.com/overwirehq/claude-code-telegram/blob/main/src/projects/registry.py"
click node_threads "https://github.com/overwirehq/claude-code-telegram/blob/main/src/projects/thread_manager.py"
click node_api "https://github.com/overwirehq/claude-code-telegram/blob/main/src/api/server.py"
click node_scheduler "https://github.com/overwirehq/claude-code-telegram/blob/main/src/scheduler/scheduler.py"
click node_bus "https://github.com/overwirehq/claude-code-telegram/blob/main/src/events/bus.py"
click node_eventhandlers "https://github.com/overwirehq/claude-code-telegram/blob/main/src/events/handlers.py"
click node_notifications "https://github.com/overwirehq/claude-code-telegram/blob/main/src/notifications/service.py"
click node_security "https://github.com/overwirehq/claude-code-telegram/blob/main/src/security/auth.py"
click node_validators "https://github.com/overwirehq/claude-code-telegram/blob/main/src/security/validators.py"
click node_ratelimit "https://github.com/overwirehq/claude-code-telegram/blob/main/src/security/rate_limiter.py"
click node_storage "https://github.com/overwirehq/claude-code-telegram/blob/main/src/storage/facade.py"
click node_database "https://github.com/overwirehq/claude-code-telegram/blob/main/src/storage/database.py"
click node_sessionstore "https://github.com/overwirehq/claude-code-telegram/blob/main/src/storage/session_storage.py"
click node_config "https://github.com/overwirehq/claude-code-telegram/blob/main/src/config/settings.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_botcore,node_routing,node_messages,node_commands,node_features,node_formatting,node_user toneBlue
class node_claude,node_facade,node_sessions,node_projects,node_threads toneAmber
class node_api,node_scheduler,node_bus,node_eventhandlers,node_notifications toneMint
class node_security,node_validators,node_ratelimit,node_storage,node_database,node_sessionstore,node_config toneRose
class node_telegram toneIndigo
```

## Components

### Telegram interaction

- [Application startup](https://github.com/overwirehq/claude-code-telegram/blob/main/src/main.py): `src/main.py`
- [Bot runtime](https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/core.py): `src/bot/core.py`
- [Update orchestration](https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/orchestrator.py): `src/bot/orchestrator.py`
- [Message handling](https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/handlers/message.py): `src/bot/handlers/message.py`
- [Classic commands](https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/handlers/command.py): `src/bot/handlers/command.py`
- [Interaction features](https://github.com/overwirehq/claude-code-telegram/tree/main/src/bot/features): `src/bot/features`
- [Response formatting](https://github.com/overwirehq/claude-code-telegram/blob/main/src/bot/utils/formatting.py): `src/bot/utils/formatting.py`

### Claude and projects

- [Claude integration](https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/sdk_integration.py): `src/claude/sdk_integration.py`
- [Claude facade](https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/facade.py): `src/claude/facade.py`
- [Session management](https://github.com/overwirehq/claude-code-telegram/blob/main/src/claude/session.py): `src/claude/session.py`
- [Project registry](https://github.com/overwirehq/claude-code-telegram/blob/main/src/projects/registry.py): `src/projects/registry.py`
- [Project threads](https://github.com/overwirehq/claude-code-telegram/blob/main/src/projects/thread_manager.py): `src/projects/thread_manager.py`

### Automation and events

- [Webhook API](https://github.com/overwirehq/claude-code-telegram/blob/main/src/api/server.py): `src/api/server.py`
- [Job scheduler](https://github.com/overwirehq/claude-code-telegram/blob/main/src/scheduler/scheduler.py): `src/scheduler/scheduler.py`
- [Event bus](https://github.com/overwirehq/claude-code-telegram/blob/main/src/events/bus.py): `src/events/bus.py`
- [Agent and notification handlers](https://github.com/overwirehq/claude-code-telegram/blob/main/src/events/handlers.py): `src/events/handlers.py`
- [Notification delivery](https://github.com/overwirehq/claude-code-telegram/blob/main/src/notifications/service.py): `src/notifications/service.py`

### Security and persistence

- [Authentication and audit](https://github.com/overwirehq/claude-code-telegram/blob/main/src/security/auth.py): `src/security/auth.py`
- [Path validation](https://github.com/overwirehq/claude-code-telegram/blob/main/src/security/validators.py): `src/security/validators.py`
- [Rate limiting](https://github.com/overwirehq/claude-code-telegram/blob/main/src/security/rate_limiter.py): `src/security/rate_limiter.py`
- [Storage services](https://github.com/overwirehq/claude-code-telegram/blob/main/src/storage/facade.py): `src/storage/facade.py`
- [SQLite database](https://github.com/overwirehq/claude-code-telegram/blob/main/src/storage/database.py): `src/storage/database.py`
- [Persistent sessions](https://github.com/overwirehq/claude-code-telegram/blob/main/src/storage/session_storage.py): `src/storage/session_storage.py`
- [Configuration](https://github.com/overwirehq/claude-code-telegram/blob/main/src/config/settings.py): `src/config/settings.py`

### Other components

- **Telegram user**
- **Telegram platform**

## Connections

- Telegram user → Telegram platform: sends messages
- Telegram platform → Bot runtime: delivers updates
- Application startup → Bot runtime: initializes (evidence: `src/main.py`)
- Bot runtime → Update orchestration: routes updates
- Update orchestration → Message handling: dispatches messages (evidence: `src/bot/orchestrator.py`)
- Update orchestration → Classic commands: dispatches commands (evidence: `src/bot/orchestrator.py`)
- Message handling → Claude facade: requests Claude work (evidence: `src/bot/handlers/message.py`)
- Classic commands → Claude facade: requests Claude work
- Claude facade → Claude integration: delegates execution (evidence: `src/claude/facade.py`)
- Claude facade → Session management: manages sessions (evidence: `src/claude/facade.py`)
- Claude integration → Path validation: checks file paths (evidence: `src/claude/sdk_integration.py`)
- Message handling → Response formatting: formats replies (evidence: `src/bot/handlers/message.py`)
- Update orchestration → Interaction features: coordinates features
- Application startup → Webhook API: configures webhooks (evidence: `src/main.py`)
- Webhook API → Event bus: publishes events (evidence: `src/api/server.py`)
- Job scheduler → Event bus: publishes triggers (evidence: `src/scheduler/scheduler.py`)
- Event bus → Agent and notification handlers: dispatches events (evidence: `src/events/bus.py`)
- Agent and notification handlers → Claude facade: runs Claude tasks (evidence: `src/events/handlers.py`)
- Agent and notification handlers → Event bus: publishes responses (evidence: `src/events/handlers.py`)
- Notification delivery → Event bus: subscribes to responses (evidence: `src/notifications/service.py`)
- Application startup → Storage services: initializes storage (evidence: `src/main.py`)
- Storage services → SQLite database: uses database (evidence: `src/storage/facade.py`)
- Persistent sessions → SQLite database: persists sessions (evidence: `src/storage/session_storage.py`)
- Session management → Persistent sessions: stores session state (evidence: `src/storage/session_storage.py`)
- Application startup → Authentication and audit: configures authentication (evidence: `src/main.py`)
- Application startup → Configuration: loads settings (evidence: `src/main.py`)
- Message handling → Rate limiting: checks request limits (evidence: `src/bot/handlers/message.py`)
- Message handling → Path validation: validates inputs (evidence: `src/bot/handlers/message.py`)
- Project threads → Project registry: resolves projects (evidence: `src/projects/thread_manager.py`)
- Project threads → Storage services: persists mappings (evidence: `src/projects/thread_manager.py`)
