# calvin-ll/reorderable architecture

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

- Interactive diagram: https://gitdiagram.com/calvin-ll/reorderable
- Repository: https://github.com/calvin-ll/reorderable

## Overview

##### Main Components and Architecture

**[Core Library Components]**
- Reorderable Base Layer
- Common Interfaces
- Drag & Drop Logic

- Collection Types
- LazyList Implementation (Column/Row)
- LazyGrid Implementation
- LazyStaggeredGrid Implementation

- Platform-Specific Implementations
- Android
- iOS
- Desktop/JVM
- Web/JS
- WebAssembly

- Demo Application
- UI Screens
- Platform-Specific Examples

##### Component Relationships

a) Data Flow:
- User Input → Drag Handle → Reorder Logic → Collection Update
- Collection Update → UI Refresh → Animation System

b) Dependencies:
- Platform Implementations → Core Components
- Collection Types → Reorderable Base Layer
- Demo App → All Components

##### Detailed Component Breakdown

**[Reorderable Base Layer]**
- ReorderableCollectionItemScope
- Draggable Handle Modifiers
- Animation Coordination
- State Management

**[Collection Types]**
- LazyList (Column/Row)
- * State Management
- * Item Reordering
- * Scroll Handling
- LazyGrid
- * Grid-specific Layout
- * Multi-dimensional Reordering
- LazyStaggeredGrid
- * Staggered Layout Support
- * Variable Size Handling

**[Platform Integration]**
- Native Touch Handling
- Platform-specific Animations
- Haptic Feedback

##### Implementation Details

Technical notes for key features:
- Drag Detection System
- Reorder Animation Control
- Scroll Behavior Management
- State Synchronization
- Platform-specific Optimizations

##### Integration Points

Integration interfaces:
- Public APIs
- State Holders
- Event Callbacks
- Modifier Extensions

##### Integration points for consuming applications

Use standardized symbols:
- Rectangles: Components
- Double Lines: API Boundaries

- Component types
- Platform-specific markers

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Library Components
    subgraph Core["Core Library Components"]
        BaseLayer["Reorderable Base Layer"]
        CommonInt["Common Interfaces"]
        DragLogic["Drag & Drop Logic"]
        BaseLayer --> CommonInt
        BaseLayer --> DragLogic
        
        Collections["Collection Types"]
        LazyList["LazyList Implementation"]
        LazyGrid["LazyGrid Implementation"]
        LazyStaggered["LazyStaggeredGrid Implementation"]
        Collections --> LazyList
        Collections --> LazyGrid
        Collections --> LazyStaggered
        
        Scroll["Scrolling Logic"]
        Utils["Utility Functions"]
    end
    
    %% Platform-Specific Implementations
    subgraph Platforms["Platform-Specific Implementations"]
        Android["Android"]
        iOS["iOS"]
        Desktop["Desktop/JVM"]
        Web["Web/JS"]
        WASM["WebAssembly"]
    end
    
    %% Demo Application
    subgraph Demo["Demo Application"]
        UIScreens["UI Screens"]
        PlatformExamples["Platform-Specific Examples"]
        UIScreens --> PlatformExamples
    end
    
    %% Relationships
    BaseLayer --> Collections
    Collections --> Platforms
    Platforms --> Demo
    
    %% Technical Components
    DragDetection["Drag Detection System"]
    AnimControl["Reorder Animation Control"]
    ScrollBehavior["Scroll Behavior Management"]
    StateSync["State Synchronization"]
    
    BaseLayer --> DragDetection
    BaseLayer --> AnimControl
    BaseLayer --> ScrollBehavior
    BaseLayer --> StateSync
    
    %% Click Events
    click BaseLayer "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/ReorderableLazyCollection.kt"
    click CommonInt "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/draggable.kt"
    click DragLogic "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/draggable.kt"
    click LazyList "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/ReorderableLazyList.kt"
    click LazyGrid "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/ReorderableLazyGrid.kt"
    click LazyStaggered "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/ReorderableLazyStaggeredGrid.kt"
    click Scroll "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/Scroller.kt"
    click Utils "https://github.com/Calvin-LL/Reorderable/blob/main/reorderable/src/commonMain/kotlin/sh/calvin/reorderable/util.kt"
    click Android "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/androidMain"
    click iOS "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/iosMain"
    click Desktop "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/jvmMain"
    click Web "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/jsMain"
    click WASM "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/wasmJsMain"
    click UIScreens "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/commonMain/kotlin/sh/calvin/reorderable/demo/ui"
    click PlatformExamples "https://github.com/Calvin-LL/Reorderable/tree/main/demoApp/composeApp/src/androidMain/kotlin/sh/calvin/reorderable/demo"
    
    %% Styling
    classDef core fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef platform fill:#90EE90,stroke:#333,stroke-width:2px
    classDef demo fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef technical fill:#FFE4B5,stroke:#333,stroke-width:2px
    
    class BaseLayer,CommonInt,DragLogic,Collections,LazyList,LazyGrid,LazyStaggered,Scroll,Utils core
    class Android,iOS,Desktop,Web,WASM platform
    class UIScreens,PlatformExamples demo
    class DragDetection,AnimControl,ScrollBehavior,StateSync technical
```
