How instagram/iglistkit works
Project type and purpose
• IGListKit is an open-source, data-driven UICollectionView framework (iOS/tvOS/macOS) that decouples the diffing algorithm from UI, provides a reusable adapter/section-controller architecture, and ships with Swift interop and code-generation plugin support.
• Key indicators: README (“A data-driven UICollectionView framework…”), top-level folders: Source (core), Examples (sample apps), Tests, docs, remodel-plugin, scripts, spm, Podspecs, Package.swift.
File structure
• Top-level modules:
• Source/IGListDiffKit – pure Objective-C diffing engine
• Source/IGListKit – adapter + SectionController UI layer
• Source/IGListSwiftKit – Swift extensions on IGListKit
• remodel-plugin – a codegen plugin to mark models as IGListDiffable
• Examples – platform sample applications (iOS, macOS, tvOS) demonstrating IGListKit usage
• Tests – unit and integration tests for DiffKit, Kit, SwiftKit
• docs – generated API reference and guides
• scripts – build, docs generation, linting, versioning
• Package/Pod/Carthage manifests – integration points for SPM/CocoaPods/Carthage
• .github/workflows/CI.yml – CI pipeline
README for additional insights
• Project purpose: performant collection updates (batch updates), flexible multi-type collections, fully tested, extendable API.
• Architectural vision: “Never call performBatchUpdates or reloadData again,” “decoupled diffing algorithm,” “extendable API.”
• Installation via CocoaPods/Carthage/SPM.
Main components
a. IGListDiffKit (Diff Engine)
b. IGListKit (Adapter + UI Layer)
c. IGListSwiftKit (Swift API sugar)
d. Codegen Plugin (remodel-plugin)
e. Example Applications (iOS, macOS, tvOS)
f. Tests (unit/integration harness)
g. Documentation (docs)
h. Build & CI (scripts, GitHub Actions)
i. Package Managers (CocoaPods, Carthage, SPM manifests)
Relationships & interactions
• IGListKit → depends on → IGListDiffKit for diff computation
• IGListSwiftKit → extends → IGListKit
• remodel-plugin → generates → Swift/ObjC model code conforming to IGListDiffable
• Example apps → import → IGListKit (+ optionally SwiftKit + DiffKit)
• Tests → invoke → DiffKit / Kit / SwiftKit APIs
• scripts/CI → orchestrate → linting, building, docs generation, packaging
• Package manifests → expose → modules to consumer build tools (Pod, Carthage, SPM)
Architectural patterns & design principles
• Adapter pattern: IGListAdapter mediates between data objects and UICollectionView
• SectionController pattern: one controller per section type, encapsulating cell config & interaction
• Strategy/Decoupling: diffing algorithm isolated in IGListDiffKit
• Extension & plugin architecture: remodel-plugin for code generation, SwiftKit for language interop
• Modular design: clear folder separation (core, UI, Swift extensions, tooling)
Essential details to capture
• Module boundaries and dependencies (no code internals)
• Public API layers vs. internal components
• Extension points (protocols, plugins)
• Consumer surface (Example apps, Package managers)
• OSS pipeline (CI, docs, linting)