# bla1r1/legacytg architecture

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

- Interactive diagram: https://gitdiagram.com/bla1r1/legacytg
- Repository: https://github.com/bla1r1/legacytg

## Overview

LegacyTG is a Telegram client for older iOS devices: UIKit screens sit over a TDLib-backed client, with capabilities adjusted for device tier. The principal flow is user sign-in, then chat and account interactions through the client to Telegram; the README documents this overall relationship but sampled headers do not expose the screen-to-client call sites. Other major branches include profiles, settings, media playback, and encrypted calls. Dashed links mark integrations whose wiring was not shown in the excerpts.

Main entry points: [`src/Core/Client/TGClient.h`](https://github.com/bla1r1/legacytg/blob/main/src/Core/Client/TGClient.h) (TDLib client), [`src/Features/Settings/TGSettingsViewControllerInternal.h`](https://github.com/bla1r1/legacytg/blob/main/src/Features/Settings/TGSettingsViewControllerInternal.h) (Settings), [`src/App/RootViewController.h`](https://github.com/bla1r1/legacytg/blob/main/src/App/RootViewController.h) (App navigation), [`src/Features/Auth/TGLoginViewControllerInternal.h`](https://github.com/bla1r1/legacytg/blob/main/src/Features/Auth/TGLoginViewControllerInternal.h) (Sign-in screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and UI"]
  node_root["App navigation"]
  node_sharedui["Shared UIKit"]
end

subgraph group_client["Client and state"]
  node_clientapi["TDLib client<br/>[TGClient.h]"]
  node_stores[("Client state stores")]
end

subgraph group_features["User features"]
  node_authscreen["Sign-in screens"]
  node_chat["Chat experience"]
  node_chatlist["Chat list"]
  node_profile["Profiles"]
  node_settings["Settings"]
  node_business["Business tools"]
  node_payments["Payments and gifts"]
  node_groups["Groups and channels"]
  node_callui["Call screens"]
end

subgraph group_media["Media and calls"]
  node_callengine["Call engine<br/>[TGCall.h]"]
  node_audio["Audio playback<br/>[TGMusicPlayer.h]"]
  node_video["Video playback"]
  node_callvideo["Call video"]
  node_softclock["Video lag control<br/>[TGSoftVideoClock.c]"]
  node_softclockheader["Video clock API<br/>[TGSoftVideoClock.h]"]
end

subgraph group_platform["Platform and presentation"]
  node_tiers["Device capabilities<br/>[TGCapabilities.h]"]
  node_themes["Themes and styling<br/>[TGTheme.h]"]
end

node_user(("User"))
node_tdlib["TDLib"]

node_user -->|"opens app"| node_root
node_root -.->|"offers sign-in"| node_authscreen
node_authscreen -.->|"requests authentication"| node_clientapi
node_clientapi -->|"bridges to"| node_tdlib
node_chat -.->|"uses client"| node_clientapi
node_chatlist -.->|"uses client"| node_clientapi
node_profile -.->|"uses client"| node_clientapi
node_settings -.->|"uses client"| node_clientapi
node_business -.->|"uses client"| node_clientapi
node_payments -.->|"uses client"| node_clientapi
node_groups -.->|"uses client"| node_clientapi
node_clientapi -.->|"maintains state"| node_stores
node_callui -.->|"uses call engine"| node_callengine
node_callengine -.->|"uses video engine"| node_callvideo
node_softclock -->|"implements API"| node_softclockheader
node_root -.->|"presents screens"| node_sharedui
node_settings -->|"shows device tier"| node_tiers
node_settings -->|"configures appearance"| node_themes
node_audio -.->|"plays Telegram media"| node_tdlib
node_video -.->|"plays Telegram media"| node_tdlib

click node_root "https://github.com/bla1r1/legacytg/blob/main/src/App/RootViewController.h"
click node_sharedui "https://github.com/bla1r1/legacytg/blob/main/src/UI/Controllers/TGRowsViewController.h"
click node_authscreen "https://github.com/bla1r1/legacytg/blob/main/src/Features/Auth/TGLoginViewControllerInternal.h"
click node_chat "https://github.com/bla1r1/legacytg/blob/main/src/Features/Chat/TGChatViewControllerInternal.h"
click node_chatlist "https://github.com/bla1r1/legacytg/blob/main/src/Features/ChatList/TGChatListViewControllerInternal.h"
click node_profile "https://github.com/bla1r1/legacytg/blob/main/src/Features/Profile/TGProfileViewControllerInternal.h"
click node_settings "https://github.com/bla1r1/legacytg/blob/main/src/Features/Settings/TGSettingsViewControllerInternal.h"
click node_business "https://github.com/bla1r1/legacytg/tree/main/src/Features/Business"
click node_payments "https://github.com/bla1r1/legacytg/tree/main/src/Features/BotsPayments"
click node_groups "https://github.com/bla1r1/legacytg/tree/main/src/Features/Groups"
click node_clientapi "https://github.com/bla1r1/legacytg/blob/main/src/Core/Client/TGClient.h"
click node_stores "https://github.com/bla1r1/legacytg/tree/main/src/Core/Stores"
click node_callui "https://github.com/bla1r1/legacytg/tree/main/src/Features/Calls"
click node_callengine "https://github.com/bla1r1/legacytg/blob/main/src/CallEngine/TGCall.h"
click node_audio "https://github.com/bla1r1/legacytg/blob/main/src/Audio/TGMusicPlayer.h"
click node_video "https://github.com/bla1r1/legacytg/blob/main/src/Media/TGSoftVideoPlayer.h"
click node_callvideo "https://github.com/bla1r1/legacytg/blob/main/src/CallEngine/Media/TGCallVideoEngine.h"
click node_softclock "https://github.com/bla1r1/legacytg/blob/main/src/Media/TGSoftVideoClock.c"
click node_softclockheader "https://github.com/bla1r1/legacytg/blob/main/src/Media/TGSoftVideoClock.h"
click node_tiers "https://github.com/bla1r1/legacytg/blob/main/src/Core/Platform/TGCapabilities.h"
click node_themes "https://github.com/bla1r1/legacytg/blob/main/src/Core/Style/TGTheme.h"

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_root,node_sharedui,node_user toneBlue
class node_clientapi,node_stores toneAmber
class node_authscreen,node_chat,node_chatlist,node_profile,node_settings,node_business,node_payments,node_groups,node_callui toneMint
class node_callengine,node_audio,node_video,node_callvideo,node_softclock,node_softclockheader toneRose
class node_tiers,node_themes,node_tdlib toneIndigo
```

## Components

### App and UI

- [App navigation](https://github.com/bla1r1/legacytg/blob/main/src/App/RootViewController.h): `src/App/RootViewController.h`
- [Shared UIKit](https://github.com/bla1r1/legacytg/blob/main/src/UI/Controllers/TGRowsViewController.h): `src/UI/Controllers/TGRowsViewController.h`

### Client and state

- [TDLib client](https://github.com/bla1r1/legacytg/blob/main/src/Core/Client/TGClient.h): `src/Core/Client/TGClient.h`
- [Client state stores](https://github.com/bla1r1/legacytg/tree/main/src/Core/Stores): `src/Core/Stores`

### User features

- [Sign-in screens](https://github.com/bla1r1/legacytg/blob/main/src/Features/Auth/TGLoginViewControllerInternal.h): `src/Features/Auth/TGLoginViewControllerInternal.h`
- [Chat experience](https://github.com/bla1r1/legacytg/blob/main/src/Features/Chat/TGChatViewControllerInternal.h): `src/Features/Chat/TGChatViewControllerInternal.h`
- [Chat list](https://github.com/bla1r1/legacytg/blob/main/src/Features/ChatList/TGChatListViewControllerInternal.h): `src/Features/ChatList/TGChatListViewControllerInternal.h`
- [Profiles](https://github.com/bla1r1/legacytg/blob/main/src/Features/Profile/TGProfileViewControllerInternal.h): `src/Features/Profile/TGProfileViewControllerInternal.h`
- [Settings](https://github.com/bla1r1/legacytg/blob/main/src/Features/Settings/TGSettingsViewControllerInternal.h): `src/Features/Settings/TGSettingsViewControllerInternal.h`
- [Business tools](https://github.com/bla1r1/legacytg/tree/main/src/Features/Business): `src/Features/Business`
- [Payments and gifts](https://github.com/bla1r1/legacytg/tree/main/src/Features/BotsPayments): `src/Features/BotsPayments`
- [Groups and channels](https://github.com/bla1r1/legacytg/tree/main/src/Features/Groups): `src/Features/Groups`
- [Call screens](https://github.com/bla1r1/legacytg/tree/main/src/Features/Calls): `src/Features/Calls`

### Media and calls

- [Call engine](https://github.com/bla1r1/legacytg/blob/main/src/CallEngine/TGCall.h): `src/CallEngine/TGCall.h`
- [Audio playback](https://github.com/bla1r1/legacytg/blob/main/src/Audio/TGMusicPlayer.h): `src/Audio/TGMusicPlayer.h`
- [Video playback](https://github.com/bla1r1/legacytg/blob/main/src/Media/TGSoftVideoPlayer.h): `src/Media/TGSoftVideoPlayer.h`
- [Call video](https://github.com/bla1r1/legacytg/blob/main/src/CallEngine/Media/TGCallVideoEngine.h): `src/CallEngine/Media/TGCallVideoEngine.h`
- [Video lag control](https://github.com/bla1r1/legacytg/blob/main/src/Media/TGSoftVideoClock.c): `src/Media/TGSoftVideoClock.c`
- [Video clock API](https://github.com/bla1r1/legacytg/blob/main/src/Media/TGSoftVideoClock.h): `src/Media/TGSoftVideoClock.h`

### Platform and presentation

- [Device capabilities](https://github.com/bla1r1/legacytg/blob/main/src/Core/Platform/TGCapabilities.h): `src/Core/Platform/TGCapabilities.h`
- [Themes and styling](https://github.com/bla1r1/legacytg/blob/main/src/Core/Style/TGTheme.h): `src/Core/Style/TGTheme.h`

### Other components

- **User**
- **TDLib**

## Connections

- User → App navigation: opens app (evidence: `README.md`)
- App navigation → Sign-in screens: offers sign-in
- Sign-in screens → TDLib client: requests authentication
- TDLib client → TDLib: bridges to (evidence: `README.md`)
- Chat experience → TDLib client: uses client
- Chat list → TDLib client: uses client
- Profiles → TDLib client: uses client
- Settings → TDLib client: uses client
- Business tools → TDLib client: uses client
- Payments and gifts → TDLib client: uses client
- Groups and channels → TDLib client: uses client
- TDLib client → Client state stores: maintains state
- Call screens → Call engine: uses call engine
- Call engine → Call video: uses video engine
- Video lag control → Video clock API: implements API (evidence: `src/Media/TGSoftVideoClock.c`)
- App navigation → Shared UIKit: presents screens
- Settings → Device capabilities: shows device tier (evidence: `README.md`)
- Settings → Themes and styling: configures appearance (evidence: `README.md`)
- Audio playback → TDLib: plays Telegram media
- Video playback → TDLib: plays Telegram media
