# onevcat/kingfisher architecture

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

- Interactive diagram: https://gitdiagram.com/onevcat/kingfisher
- Repository: https://github.com/onevcat/kingfisher
- Video tour (about a minute): https://gitdiagram.com/onevcat/kingfisher/video

## Overview

Kingfisher is a Swift image-loading library. An app supplies a URL or local data source through a platform view extension or SwiftUI image; the manager coordinates retrieval, processing, and caching, then the presentation layer displays the result. The graph preserves documented capabilities such as prefetching, animated images, Live Photos, and customizable image processing. Some subsystem links are supported only by the README or source-index references; unsampled implementation details are not inferred.

Main entry points: [`Sources/General/KingfisherManager.swift`](https://github.com/onevcat/kingfisher/blob/master/Sources/General/KingfisherManager.swift) (Image manager), [`Sources/Cache/ImageCache.swift`](https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/ImageCache.swift) (Hybrid image cache), [`Sources/Extensions/ImageView+Kingfisher.swift`](https://github.com/onevcat/kingfisher/blob/master/Sources/Extensions/ImageView%2BKingfisher.swift) (View extensions), [`Sources/General/ImageSource/Source.swift`](https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/Source.swift) (Image sources)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["App interfaces"]
  node_view_extensions["View extensions"]
  node_builder["KF builder<br/>[KF.swift]"]
  node_swiftui["SwiftUI image<br/>[KFImage.swift]"]
end

subgraph group_loading["Image retrieval"]
  node_manager["Image manager"]
  node_sources["Image sources<br/>[Source.swift]"]
  node_resources["Network resources<br/>[Resource.swift]"]
  node_providers["Data providers"]
  node_downloader["Image downloader"]
  node_session_task["Session task"]
  node_prefetcher["Image prefetcher"]
  node_live_photo["Live Photo loading"]
end

subgraph group_assets["Image and cache"]
  node_processor["Image processors"]
  node_image_format["Image formats<br/>[ImageFormat.swift]"]
  node_cache[("Hybrid image cache<br/>[ImageCache.swift]")]
  node_memory[("Memory storage")]
  node_disk[("Disk storage<br/>[DiskStorage.swift]")]
  node_serializer["Cache serializer"]
end

subgraph group_presentation["Image presentation"]
  node_swiftui_binder["SwiftUI binder<br/>[ImageBinder.swift]"]
  node_animated_view["Animated image view"]
  node_transition["Image transitions"]
end

node_app(("Host app"))
node_network["URLSession network"]

node_app -->|"sets image"| node_view_extensions
node_app -->|"declares image"| node_swiftui
node_view_extensions -->|"requests image"| node_manager
node_builder -.->|"configures loading"| node_manager
node_swiftui -.->|"binds image"| node_swiftui_binder
node_swiftui_binder -->|"requests image"| node_manager
node_manager -->|"accepts source"| node_sources
node_sources -->|"wraps resource"| node_resources
node_sources -->|"uses provider"| node_providers
node_manager -->|"downloads image"| node_downloader
node_manager -->|"checks and stores"| node_cache
node_manager -->|"processes image"| node_processor
node_downloader -->|"fetches data"| node_network
node_downloader -.->|"manages task"| node_session_task
node_prefetcher -->|"warms cache"| node_cache
node_cache -->|"uses memory"| node_memory
node_cache -->|"uses disk"| node_disk
node_cache -->|"serializes entries"| node_serializer
node_processor -.->|"handles formats"| node_image_format
node_view_extensions -->|"animates setting"| node_transition
node_app -->|"prefetches images"| node_prefetcher
node_app -->|"shows animation"| node_animated_view
node_app -->|"loads Live Photo"| node_live_photo

click node_view_extensions "https://github.com/onevcat/kingfisher/blob/master/Sources/Extensions/ImageView%2BKingfisher.swift"
click node_builder "https://github.com/onevcat/kingfisher/blob/master/Sources/General/KF.swift"
click node_swiftui "https://github.com/onevcat/kingfisher/blob/master/Sources/SwiftUI/KFImage.swift"
click node_manager "https://github.com/onevcat/kingfisher/blob/master/Sources/General/KingfisherManager.swift"
click node_sources "https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/Source.swift"
click node_resources "https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/Resource.swift"
click node_providers "https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/ImageDataProvider.swift"
click node_downloader "https://github.com/onevcat/kingfisher/blob/master/Sources/Networking/ImageDownloader.swift"
click node_session_task "https://github.com/onevcat/kingfisher/blob/master/Sources/Networking/SessionDataTask.swift"
click node_prefetcher "https://github.com/onevcat/kingfisher/blob/master/Sources/Networking/ImagePrefetcher.swift"
click node_processor "https://github.com/onevcat/kingfisher/blob/master/Sources/Image/ImageProcessor.swift"
click node_image_format "https://github.com/onevcat/kingfisher/blob/master/Sources/Image/ImageFormat.swift"
click node_cache "https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/ImageCache.swift"
click node_memory "https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/MemoryStorage.swift"
click node_disk "https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/DiskStorage.swift"
click node_serializer "https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/CacheSerializer.swift"
click node_swiftui_binder "https://github.com/onevcat/kingfisher/blob/master/Sources/SwiftUI/ImageBinder.swift"
click node_animated_view "https://github.com/onevcat/kingfisher/blob/master/Sources/Views/AnimatedImageView.swift"
click node_transition "https://github.com/onevcat/kingfisher/blob/master/Sources/Image/ImageTransition.swift"
click node_live_photo "https://github.com/onevcat/kingfisher/blob/master/Sources/General/KingfisherManager%2BLivePhoto.swift"

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_view_extensions,node_builder,node_swiftui toneBlue
class node_manager,node_sources,node_resources,node_providers,node_downloader,node_session_task,node_prefetcher,node_live_photo toneAmber
class node_processor,node_image_format,node_cache,node_memory,node_disk,node_serializer toneMint
class node_swiftui_binder,node_animated_view,node_transition toneRose
class node_app,node_network toneIndigo
```

## Components

### App interfaces

- [View extensions](https://github.com/onevcat/kingfisher/blob/master/Sources/Extensions/ImageView%2BKingfisher.swift): `Sources/Extensions/ImageView+Kingfisher.swift`
- [KF builder](https://github.com/onevcat/kingfisher/blob/master/Sources/General/KF.swift): `Sources/General/KF.swift`
- [SwiftUI image](https://github.com/onevcat/kingfisher/blob/master/Sources/SwiftUI/KFImage.swift): `Sources/SwiftUI/KFImage.swift`

### Image retrieval

- [Image manager](https://github.com/onevcat/kingfisher/blob/master/Sources/General/KingfisherManager.swift): `Sources/General/KingfisherManager.swift`
- [Image sources](https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/Source.swift): `Sources/General/ImageSource/Source.swift`
- [Network resources](https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/Resource.swift): `Sources/General/ImageSource/Resource.swift`
- [Data providers](https://github.com/onevcat/kingfisher/blob/master/Sources/General/ImageSource/ImageDataProvider.swift): `Sources/General/ImageSource/ImageDataProvider.swift`
- [Image downloader](https://github.com/onevcat/kingfisher/blob/master/Sources/Networking/ImageDownloader.swift): `Sources/Networking/ImageDownloader.swift`
- [Session task](https://github.com/onevcat/kingfisher/blob/master/Sources/Networking/SessionDataTask.swift): `Sources/Networking/SessionDataTask.swift`
- [Image prefetcher](https://github.com/onevcat/kingfisher/blob/master/Sources/Networking/ImagePrefetcher.swift): `Sources/Networking/ImagePrefetcher.swift`
- [Live Photo loading](https://github.com/onevcat/kingfisher/blob/master/Sources/General/KingfisherManager%2BLivePhoto.swift): `Sources/General/KingfisherManager+LivePhoto.swift`

### Image and cache

- [Image processors](https://github.com/onevcat/kingfisher/blob/master/Sources/Image/ImageProcessor.swift): `Sources/Image/ImageProcessor.swift`
- [Image formats](https://github.com/onevcat/kingfisher/blob/master/Sources/Image/ImageFormat.swift): `Sources/Image/ImageFormat.swift`
- [Hybrid image cache](https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/ImageCache.swift): `Sources/Cache/ImageCache.swift`
- [Memory storage](https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/MemoryStorage.swift): `Sources/Cache/MemoryStorage.swift`
- [Disk storage](https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/DiskStorage.swift): `Sources/Cache/DiskStorage.swift`
- [Cache serializer](https://github.com/onevcat/kingfisher/blob/master/Sources/Cache/CacheSerializer.swift): `Sources/Cache/CacheSerializer.swift`

### Image presentation

- [SwiftUI binder](https://github.com/onevcat/kingfisher/blob/master/Sources/SwiftUI/ImageBinder.swift): `Sources/SwiftUI/ImageBinder.swift`
- [Animated image view](https://github.com/onevcat/kingfisher/blob/master/Sources/Views/AnimatedImageView.swift): `Sources/Views/AnimatedImageView.swift`
- [Image transitions](https://github.com/onevcat/kingfisher/blob/master/Sources/Image/ImageTransition.swift): `Sources/Image/ImageTransition.swift`

### Other components

- **Host app**
- **URLSession network**

## Connections

- Host app → View extensions: sets image (evidence: `README.md`)
- Host app → SwiftUI image: declares image (evidence: `README.md`)
- View extensions → Image manager: requests image (evidence: `Sources/Extensions/ImageView+Kingfisher.swift`)
- KF builder → Image manager: configures loading
- SwiftUI image → SwiftUI binder: binds image (evidence: `Sources/SwiftUI/ImageBinder.swift`)
- SwiftUI binder → Image manager: requests image (evidence: `Sources/SwiftUI/ImageBinder.swift`)
- Image manager → Image sources: accepts source (evidence: `Sources/General/KingfisherManager.swift`)
- Image sources → Network resources: wraps resource (evidence: `Sources/General/ImageSource/Source.swift`)
- Image sources → Data providers: uses provider (evidence: `Sources/General/ImageSource/Source.swift`)
- Image manager → Image downloader: downloads image (evidence: `Sources/General/KingfisherManager.swift`)
- Image manager → Hybrid image cache: checks and stores (evidence: `Sources/General/KingfisherManager.swift`)
- Image manager → Image processors: processes image (evidence: `Sources/General/KingfisherManager.swift`)
- Image downloader → URLSession network: fetches data (evidence: `README.md`)
- Image downloader → Session task: manages task
- Image prefetcher → Hybrid image cache: warms cache (evidence: `README.md`)
- Hybrid image cache → Memory storage: uses memory (evidence: `Sources/Cache/ImageCache.swift`)
- Hybrid image cache → Disk storage: uses disk (evidence: `Sources/Cache/ImageCache.swift`)
- Hybrid image cache → Cache serializer: serializes entries (evidence: `Sources/Cache/ImageCache.swift`)
- Image processors → Image formats: handles formats
- View extensions → Image transitions: animates setting (evidence: `README.md`)
- Host app → Image prefetcher: prefetches images (evidence: `README.md`)
- Host app → Animated image view: shows animation (evidence: `README.md`)
- Host app → Live Photo loading: loads Live Photo (evidence: `README.md`)
