The 274-Module Monolith: Architecture Map of Telegram iOS
11 minA top-down aerial survey of the Telegram iOS codebase — its Bazel build system, 274 submodules, dependency graph, and how to navigate it all.
App Lifecycle: From main.m to Your Chat List
14 minTracing the complete launch path of Telegram iOS — from the Objective-C entry point through the massive AppDelegate to the moment your chat list appears.
SwiftSignalKit: Telegram's Reactive Framework from Scratch
16 minA complete deep dive into SwiftSignalKit — the custom reactive framework that predates Combine by years and powers every async operation in Telegram iOS.
SSignalKit: The Objective-C Reactive Layer
21 minA deep dive into the Objective-C twin of SwiftSignalKit — the reactive framework powering LegacyComponents, media pipelines, and the bridge between ObjC and Swift in Telegram iOS.
Reactive Patterns in Practice: The Telegram iOS Cookbook
16 minReal-world patterns from the Telegram iOS codebase — Promise vs ValuePromise, disposable lifecycle management, the cached-then-remote strategy, signal composition chains, and more.
Postbox: Telegram's Custom SQLite Persistence Layer
13 minWhy Telegram built its own database framework instead of using Core Data or Realm, and how Postbox turns raw SQLite into a reactive, type-safe persistence engine.
Postbox Tables: How Telegram Stores Messages, Peers, and Chats
13 minA deep dive into the 70+ table classes that make up Postbox — from the 3,500-line MessageHistoryTable to the 115-line PeerTable, with key encoding strategies, hole management, and cross-table dependencies.
Postbox Views: Live Queries That Power Every Screen
22 minHow Telegram's view system turns database transactions into real-time UI updates — the Mutable/Immutable pattern, ViewTracker, CombinedView, hole tracking, and the type-safe EngineData layer.
Postbox State Sync: How Local and Remote State Converge
18 minThe complete state synchronization pipeline — from MTProto getDifference to Postbox transactions, hole filling, the AccountStateManager operation queue, and SeedConfiguration bootstrap.
MTProto: Telegram's Custom Binary Protocol
15 minA complete walkthrough of MtProtoKit — the Objective-C implementation of Telegram's MTProto 2.0 protocol, covering transport, encryption, session management, DH key exchange, and the message assembly pipeline.
TelegramApi: The Generated Type System
14 minHow Telegram iOS turns the TL schema into 95,000 lines of type-safe Swift — constructor ID registries, binary serialization, the triple-return function pattern, flags-based optional fields, and secret chat layer versioning.
Media Downloads: From Cloud Resources to Cached Files
12 minHow Telegram iOS fetches, caches, and streams media — the MediaBox storage coordinator, resource type hierarchy, multi-datacenter downloads, CDN fallback, multipart uploads, file reference revalidation, and progressive loading.
Real-Time Updates: From Push Channel to UI
11 minHow Telegram iOS receives, groups, validates, and applies real-time updates — the UpdateMessageService push receiver, UpdateGroup classification, AccountStateManager operation queue, gap detection with PTS/QTS/SEQ, and difference polling.
AsyncDisplayKit: Telegram's Custom Rendering Engine
16 minHow Telegram iOS achieves 60fps scrolling using a forked version of Facebook/Pinterest's Texture framework — ASDisplayNode as the abstraction over UIView/CALayer, background rendering pipelines, the interface state machine, display sentinel cancellation, subtree rasterization, and the Display module's Swift wrapper layer.
ComponentFlow: Telegram's Declarative UI Framework
17 minHow Telegram built a SwiftUI-like component system on top of UIKit — the Component protocol with value-type diffing, ComponentState for imperative re-renders, the Environment dependency injection system, CombinedComponent for composite layouts, ComponentHostView as the UIKit bridge, and built-in primitives like VStack, Text, and Button.
Theming and Presentation Data: The Visual Identity System
12 minHow Telegram iOS defines its entire visual appearance through PresentationTheme — a 1,669-line class hierarchy covering every UI surface, with four built-in themes, cloud theme sync, automatic night mode switching, reactive propagation via PresentationData signals, and a resource cache for generated images.
Navigation Architecture: Controllers, Containers, and the Custom Navigation Bar
11 minHow Telegram iOS manages screen hierarchy using a custom NavigationController built on AsyncDisplayKit nodes — the ViewController base class with display nodes, eight navigation presentation modes, flat vs. split containers for iPad, modal and overlay stacking, the custom NavigationBar with SVG back arrows, and layout propagation.
ItemListUI: Building Settings Screens Declaratively
13 minHow Telegram iOS composes its settings screens using ItemListUI — the ItemListController reactive state machine, ItemListNodeEntry for declarative list definitions, automatic diffing with MergeLists, 16 built-in item types (switches, disclosures, inputs, actions), neighbor-aware insets for section styling, and the complete pattern for building an iOS Settings-style screen.
ChatController: The Heart of the Messaging Experience
15 minA deep dive into ChatControllerImpl — at 10,413 lines, Telegram iOS's most complex view controller. Covers the 130-import dependency graph, 50+ disposable properties, the ChatControllerInteraction closure bag with 80+ callbacks, ChatControllerNode's layered display hierarchy, the ContentData reactive state pipeline, input panel management, and how the chat screen coordinates messages, media, recording, search, and overlays into a seamless experience.
Message Rendering: From Model to Pixels
11 minHow a Telegram message goes from a data model to a rendered bubble on screen. Covers ChatMessageItemImpl and the content routing system that selects from 20+ node types, ChatMessageBubbleItemNode's 7,236-line layout engine with its multi-container node tree, the bubble content protocol with four-position sizing, message merging rules, async two-phase layout, date headers with sticky positioning, and the complete pipeline from Message to CALayer.
SyncCore: The State Synchronization Engine
11 minHow Telegram iOS keeps its local database perfectly synchronized with the server. Covers AccountStateManager's operation queue, the pts/qts/seq counter system for gap-free update tracking, UpdateGroup classification, the difference-fetching protocol, AccountMutableState with 50+ mutation operations, channel-specific pts tracking, hole detection and asynchronous filling, the replayFinalState atomic database writer, and the complete update pipeline from WebSocket to Postbox.
TelegramEngine: The API Facade
9 minHow TelegramEngine wraps the complexity of TelegramCore into a clean, modular API surface. Covers the lazy subsystem pattern with 19 domain modules, the _internal_ delegation convention, Engine* wrapper types (EnginePeer, EngineMessage) that simplify raw Postbox models, the EngineData reactive query system with variadic generic subscriptions, PostboxViewDataItem protocol for type-safe database access, EngineDataMap and EngineDataList collection patterns, and how 200+ public methods organize a quarter-million lines of networking and persistence code.
Encryption: MTProto Transport Security and Secret Chats
11 minA deep dive into Telegram iOS's two encryption layers. Covers the MTProto 2.0 transport encryption — auth key negotiation via Diffie-Hellman, the two-step message key derivation using SHA-256, AES-256-IGE encryption, and the encrypt-then-MAC verification scheme. Then explores end-to-end Secret Chats — the SecretChatState state machine, DH key exchange with safe prime validation, the V1/V2 encryption protocols, key fingerprint verification, the Perfect Forward Secrecy rekeying protocol, and the SecretChatKeychain that manages multiple keys during transitions.
Extensions: Six Processes Sharing One Database
14 minA deep dive into Telegram iOS's six app extensions — Share, NotificationService, NotificationContent, Widget, SiriIntents, and BroadcastUpload. Covers how each extension bootstraps a minimal Telegram stack from the shared App Group container, the encryption parameter derivation pattern every extension repeats, the AccountAuxiliaryMethods stub that disables features extensions don't need, and the architectural constraints of running TelegramCore outside the main app process.
Build System: Bazel, 274 Modules, and Reproducible Builds
14 minThe final post in the series. A comprehensive walkthrough of how Telegram iOS's Bazel build system assembles 274 Swift/Objective-C modules and 26 vendored C/C++ libraries into a single IPA. Covers MODULE.bazel and the dependency graph, the Make.py orchestration layer, build configurations (debug_arm64, release_arm64), code signing strategies (git-encrypted profiles, Xcode-managed, local directory), code generation pipelines (localized strings, FlatBuffers, Intents), the .bazelrc compiler flags, release optimizations (WMO, -Osize, dead_strip), and practical advice for navigating and building the codebase.