# ajaxy/telegram-tt architecture

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

- Interactive diagram: https://gitdiagram.com/ajaxy/telegram-tt
- Repository: https://github.com/ajaxy/telegram-tt

## Overview

Telegram Web A is Telegram’s browser client, built around a custom Teact UI and a custom GramJS MTProto implementation. The principal workflow is opening the client, rendering the application, maintaining shared state, and communicating with Telegram; incoming updates are reconciled through the update manager. The tree also shows distinct chat, messaging, media, calls, settings, and instant-view areas. Some feature-level wiring is not shown in the excerpts, so those connections are omitted or marked unverified rather than inferred from folder names.

Main entry points: [`src/components/main/Main.tsx`](https://github.com/ajaxy/telegram-tt/blob/master/src/components/main/Main.tsx) (Main interface), [`src/index.tsx`](https://github.com/ajaxy/telegram-tt/blob/master/src/index.tsx) (Application entry), [`src/api/gramjs/updates/updateManager.ts`](https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/updates/updateManager.ts) (Update manager), [`src/lib/gramjs/client/TelegramClient.ts`](https://github.com/ajaxy/telegram-tt/blob/master/src/lib/gramjs/client/TelegramClient.ts) (MTProto client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Client application"]
  node_entry["Application entry<br/>[index.tsx]"]
  node_main["Main interface<br/>[Main.tsx]"]
end

subgraph group_features["User features"]
  node_chatlist["Chat navigation<br/>[ChatList.tsx]"]
  node_messages["Message interactions"]
  node_calls["Voice and video calls"]
  node_settings["Settings<br/>[Settings.tsx]"]
  node_instantview["Instant View"]
end

subgraph group_transport["Telegram transport"]
  node_api["Telegram API methods"]
  node_client["MTProto client<br/>[TelegramClient.ts]"]
  node_updates["Update manager<br/>[updateManager.ts]"]
  node_entities["Entity processor<br/>[entityProcessor.ts]"]
  node_localdb[("Local API database<br/>[localDb.ts]")]
end

subgraph group_runtime["Runtime foundations"]
  node_state["Shared state<br/>[index.ts]"]
  node_teact["Teact runtime<br/>[teact.ts]"]
  node_render["DOM renderer<br/>[teact-dom.ts]"]
end

node_user(("Telegram user"))
node_telegram{{"Telegram service"}}

node_user -->|"opens client"| node_entry
node_entry -->|"initializes state"| node_state
node_entry -->|"uses renderer"| node_render
node_entry -->|"loads interface"| node_main
node_main -.-> node_chatlist
node_main -.-> node_messages
node_main -.-> node_calls
node_main -.-> node_settings
node_main -.-> node_instantview
node_entry -->|"uses runtime"| node_teact
node_teact -->|"renders through"| node_render
node_client -->|"exchanges MTProto"| node_telegram
node_client -->|"handles updates"| node_updates
node_updates -->|"processes entities"| node_entities
node_updates -->|"reads update state"| node_localdb
node_api -.-> node_client
node_state -.-> node_api

click node_entry "https://github.com/ajaxy/telegram-tt/blob/master/src/index.tsx"
click node_main "https://github.com/ajaxy/telegram-tt/blob/master/src/components/main/Main.tsx"
click node_state "https://github.com/ajaxy/telegram-tt/blob/master/src/global/index.ts"
click node_teact "https://github.com/ajaxy/telegram-tt/blob/master/src/lib/teact/teact.ts"
click node_chatlist "https://github.com/ajaxy/telegram-tt/blob/master/src/components/left/main/ChatList.tsx"
click node_messages "https://github.com/ajaxy/telegram-tt/blob/master/src/components/middle/message/hooks/useInnerHandlers.ts"
click node_calls "https://github.com/ajaxy/telegram-tt/tree/master/src/components/calls"
click node_settings "https://github.com/ajaxy/telegram-tt/blob/master/src/components/left/settings/Settings.tsx"
click node_instantview "https://github.com/ajaxy/telegram-tt/tree/master/src/components/iv"
click node_api "https://github.com/ajaxy/telegram-tt/tree/master/src/api/gramjs/methods"
click node_client "https://github.com/ajaxy/telegram-tt/blob/master/src/lib/gramjs/client/TelegramClient.ts"
click node_updates "https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/updates/updateManager.ts"
click node_entities "https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/updates/entityProcessor.ts"
click node_localdb "https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/localDb.ts"
click node_render "https://github.com/ajaxy/telegram-tt/blob/master/src/lib/teact/teact-dom.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_entry,node_main,node_user toneBlue
class node_chatlist,node_messages,node_calls,node_settings,node_instantview toneAmber
class node_api,node_client,node_updates,node_entities,node_localdb toneMint
class node_state,node_teact,node_render toneRose
class node_telegram toneIndigo
```

## Components

### Client application

- [Application entry](https://github.com/ajaxy/telegram-tt/blob/master/src/index.tsx): `src/index.tsx`
- [Main interface](https://github.com/ajaxy/telegram-tt/blob/master/src/components/main/Main.tsx): `src/components/main/Main.tsx`

### User features

- [Chat navigation](https://github.com/ajaxy/telegram-tt/blob/master/src/components/left/main/ChatList.tsx): `src/components/left/main/ChatList.tsx`
- [Message interactions](https://github.com/ajaxy/telegram-tt/blob/master/src/components/middle/message/hooks/useInnerHandlers.ts): `src/components/middle/message/hooks/useInnerHandlers.ts`
- [Voice and video calls](https://github.com/ajaxy/telegram-tt/tree/master/src/components/calls): `src/components/calls`
- [Settings](https://github.com/ajaxy/telegram-tt/blob/master/src/components/left/settings/Settings.tsx): `src/components/left/settings/Settings.tsx`
- [Instant View](https://github.com/ajaxy/telegram-tt/tree/master/src/components/iv): `src/components/iv`

### Telegram transport

- [Telegram API methods](https://github.com/ajaxy/telegram-tt/tree/master/src/api/gramjs/methods): `src/api/gramjs/methods`
- [MTProto client](https://github.com/ajaxy/telegram-tt/blob/master/src/lib/gramjs/client/TelegramClient.ts): `src/lib/gramjs/client/TelegramClient.ts`
- [Update manager](https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/updates/updateManager.ts): `src/api/gramjs/updates/updateManager.ts`
- [Entity processor](https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/updates/entityProcessor.ts): `src/api/gramjs/updates/entityProcessor.ts`
- [Local API database](https://github.com/ajaxy/telegram-tt/blob/master/src/api/gramjs/localDb.ts): `src/api/gramjs/localDb.ts`

### Runtime foundations

- [Shared state](https://github.com/ajaxy/telegram-tt/blob/master/src/global/index.ts): `src/global/index.ts`
- [Teact runtime](https://github.com/ajaxy/telegram-tt/blob/master/src/lib/teact/teact.ts): `src/lib/teact/teact.ts`
- [DOM renderer](https://github.com/ajaxy/telegram-tt/blob/master/src/lib/teact/teact-dom.ts): `src/lib/teact/teact-dom.ts`

### Other components

- **Telegram user**
- **Telegram service**

## Connections

- Telegram user → Application entry: opens client (evidence: `README.md`)
- Application entry → Shared state: initializes state (evidence: `src/index.tsx`)
- Application entry → DOM renderer: uses renderer (evidence: `src/index.tsx`)
- Application entry → Main interface: loads interface
- Main interface → Chat navigation
- Main interface → Message interactions
- Main interface → Voice and video calls
- Main interface → Settings
- Main interface → Instant View
- Application entry → Teact runtime: uses runtime (evidence: `src/index.tsx`)
- Teact runtime → DOM renderer: renders through (evidence: `src/lib/teact/teact.ts`)
- MTProto client → Telegram service: exchanges MTProto (evidence: `README.md`)
- MTProto client → Update manager: handles updates (evidence: `src/lib/gramjs/client/TelegramClient.ts`)
- Update manager → Entity processor: processes entities (evidence: `src/api/gramjs/updates/updateManager.ts`)
- Update manager → Local API database: reads update state (evidence: `src/api/gramjs/updates/updateManager.ts`)
- Telegram API methods → MTProto client
- Shared state → Telegram API methods
