# daangn/karrotlistkit architecture

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

- Interactive diagram: https://gitdiagram.com/daangn/karrotlistkit
- Repository: https://github.com/daangn/karrotlistkit

## Overview

##### Main Components

a. Core Components Layer:
- Component System
- Base Component Protocol
- AnyComponent (Type Erasure)
- IdentifiableComponent
- PrefetchableComponent

b. Adapter Layer:
- CollectionViewAdapter (Central Coordinator)
- Layout Adapter System
- Component Size Storage

c. Builder Layer:
- Sections Builder
- Cells Builder

d. Event Handling System:
- Events
- Cell Events
- Common Events
- Event Storage

e. Layout System:
- Compositional Layout Factory
- Layout Variations (Vertical, Horizontal, Grid)

**┌─────────────────────────────────────────────────────┐**
- Client Application                  │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Public API Layer                  │
- ┌─────────────┐  ┌──────────┐  ┌───────────────┐  │
- List     │  │ Section  │  │     Cell      │  │
- ┘  └──────────┘  └───────────────┘  │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Adapter Layer                      │
- ┌─────────────────────┐  ┌────────────────────┐   │
- CollectionViewAdapter│  │LayoutAdapter       │   │
- ┘  └────────────────────┘   │
- ┘
- ↓
**┌─────────────────────────────────────────────────────┐**
- Component System                     │
- ┌─────────────┐  ┌──────────┐  ┌───────────────┐  │
- Component  │  │Prefetching│  │Event Handling │  │
- ┘  └──────────┘  └───────────────┘  │
- ┘

##### Important Relationships

- How the Event System integrates with both Components and the Adapter
- Relationship between Layout System and UICollectionView
- Demonstrate the Prefetching system's integration

##### Implementation Details

Specific technical details:
- Component lifecycle
- Layout computation flow
- Event propagation paths
- Prefetching mechanism

##### Additional Elements

- Different component types
- Event flow indicators
- Layout system options
- Integration points with UIKit

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Application"]
        App[Client Implementation]
    end

    subgraph PublicAPI["Public API Layer"]
        List["List"]:::api
        Section["Section"]:::api
        Cell["Cell"]:::api
    end

    subgraph AdapterLayer["Adapter Layer"]
        CVA["CollectionViewAdapter"]:::adapter
        LA["Layout Adapter"]:::adapter
        CSStorage["Component Size Storage"]:::adapter
    end

    subgraph ComponentSystem["Component System"]
        BaseComponent["Base Component"]:::component
        AnyComponent["AnyComponent"]:::component
        IdentifiableComponent["IdentifiableComponent"]:::component
        PrefetchableComponent["PrefetchableComponent"]:::component
    end

    subgraph BuilderLayer["Builder Layer"]
        SectionsBuilder["Sections Builder"]:::builder
        CellsBuilder["Cells Builder"]:::builder
    end

    subgraph EventSystem["Event Handling System"]
        ListEvents["List Events"]:::event
        CellEvents["Cell Events"]:::event
        CommonEvents["Common Events"]:::event
        EventStorage["Event Storage"]:::event
        EventHandler["Event Handler"]:::event
    end

    subgraph LayoutSystem["Layout System"]
        CompLayout["Compositional Layout Factory"]:::layout
        VerticalLayout["Vertical Layout"]:::layout
        HorizontalLayout["Horizontal Layout"]:::layout
        GridLayout["Grid Layout"]:::layout
    end

    subgraph PrefetchingSystem["Prefetching System"]
        PrefetchPlugins["Prefetching Plugins"]:::prefetch
        RemoteImagePrefetch["Remote Image Prefetching"]:::prefetch
    end

    subgraph SwiftUISupport["SwiftUI Support"]
        ComponentBridge["Component Bridge"]:::swiftui
    end

    %% Relationships
    App --> List
    List --> Section
    Section --> Cell
    
    List --> CVA
    CVA --> LA
    CVA --> CSStorage
    
    Cell --> BaseComponent
    BaseComponent --> AnyComponent
    BaseComponent --> IdentifiableComponent
    BaseComponent --> PrefetchableComponent
    
    Section --> SectionsBuilder
    Cell --> CellsBuilder
    
    CVA --> EventHandler
    EventHandler --> ListEvents
    EventHandler --> CellEvents
    EventHandler --> CommonEvents
    EventHandler --> EventStorage
    
    LA --> CompLayout
    CompLayout --> VerticalLayout
    CompLayout --> HorizontalLayout
    CompLayout --> GridLayout
    
    PrefetchableComponent --> PrefetchPlugins
    PrefetchPlugins --> RemoteImagePrefetch
    
    BaseComponent --> ComponentBridge

    %% Click Events
    click List "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/List.swift"
    click Section "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Section.swift"
    click Cell "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Cell.swift"
    click CVA "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Adapter/CollectionViewAdapter.swift"
    click LA "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Adapter/CollectionViewLayoutAdaptable.swift"
    click CSStorage "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Adapter/ComponentSizeStorage.swift"
    click BaseComponent "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Component/Component.swift"
    click AnyComponent "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Component/AnyComponent.swift"
    click IdentifiableComponent "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Component/IdentifiableComponent.swift"
    click PrefetchableComponent "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Prefetching/PrefetchableComponent.swift"
    click SectionsBuilder "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Builder/SectionsBuilder.swift"
    click CellsBuilder "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Builder/CellsBuilder.swift"
    click ListEvents "https://github.com/daangn/KarrotListKit/tree/main/Sources/KarrotListKit/Event/List"
    click CellEvents "https://github.com/daangn/KarrotListKit/tree/main/Sources/KarrotListKit/Event/Cell"
    click CommonEvents "https://github.com/daangn/KarrotListKit/tree/main/Sources/KarrotListKit/Event/Common"
    click EventStorage "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Event/ListingViewEventStorage.swift"
    click EventHandler "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Event/ListingViewEventHandler.swift"
    click CompLayout "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Layout/CompositionalLayoutSectionFactory.swift"
    click VerticalLayout "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Layout/VerticalLayout.swift"
    click HorizontalLayout "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Layout/HorizontalLayout.swift"
    click GridLayout "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Layout/VerticalGridLayout.swift"
    click PrefetchPlugins "https://github.com/daangn/KarrotListKit/tree/main/Sources/KarrotListKit/Prefetching/Plugins"
    click RemoteImagePrefetch "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/Prefetching/RemoteImagePrefetching.swift"
    click ComponentBridge "https://github.com/daangn/KarrotListKit/blob/main/Sources/KarrotListKit/SwiftUISupport/ComponentRepresented.swift"

    %% Styles
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef api fill:#e1f5fe,stroke:#0288d1,stroke-width:2px
    classDef adapter fill:#c8e6c9,stroke:#388e3c,stroke-width:2px
    classDef component fill:#bbdefb,stroke:#1976d2,stroke-width:2px
    classDef builder fill:#fff3e0,stroke:#f57c00,stroke-width:2px
    classDef event fill:#ffecb3,stroke:#ffa000,stroke-width:2px
    classDef layout fill:#e1bee7,stroke:#7b1fa2,stroke-width:2px
    classDef prefetch fill:#b2dfdb,stroke:#00796b,stroke-width:2px
    classDef swiftui fill:#f8bbd0,stroke:#c2185b,stroke-width:2px
```
