# saket/swipe architecture

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

- Interactive diagram: https://gitdiagram.com/saket/swipe
- Repository: https://github.com/saket/swipe

## Overview

##### Project Type & Purpose
- This is a Kotlin-based library project (with a sample Android module) that provides customizable swipe composables for Jetpack Compose. It differentiates itself from regular “swipe-to-dismiss” functionality by focusing on swipe actions that reveal options rather than dismiss a view.
- The README clearly shows code samples for creating SwipeAction objects and using a SwipeableActionsBox, indicating that the library’s primary purpose is to offer UI components and behavior for swipe interactions.

##### File Structure
- The project is organized into multiple modules:
- The “library” module contains the core of the swipe functionality. Under library/src/commonMain/kotlin, you see the primary source files (for example, SwipeAction.kt, SwipeableActionsBox.kt, etc.) that implement the composables.
- The “sample” module serves as an Android sample app. It demonstrates how the library can be incorporated into an actual application. The presence of AndroidManifest.xml and corresponding resource folders under sample/src/main confirms this.
- The “library/src/test” directory contains tests (and snapshot images) ensuring the correct functionality of the swipe components.
- Build and configuration files (like build.gradle.kts, gradle.properties, gradle wrapper files, etc.) show the project uses Gradle for building the modules.

##### Main Components
- Core Swipe Library: Represents the reusable composables:
- SwipeAction: Defines the properties of individual swipe actions.
- SwipeableActionsBox: The container composable that uses one or more SwipeAction objects.
- Supporting files (such as defaults.kt, horizontalDraggable.kt, etc.) that implement the internal logic.
- Test Suite: Unit tests and snapshot tests housed in library/src/test. These ensure the core functionality is robust.
- Sample Application: An Android application module demonstrating how to integrate and use the swipe library.
- Build System & Configuration: The build.gradle.kts and Gradle wrapper components that handle dependencies, compilation, and module integration.

##### Relationships and Interactions
- The Sample App module uses APIs from the Core Swipe Library to render swipeable actions in an Android context.
- The Test Suite is connected directly to the Core Swipe Library to validate behavior and catch regressions.
- The Gradle build scripts orchestrate the compilation, testing, and packaging of both the library and sample modules.
- External clients (developers integrating the library) depend on the published library artifact (e.g., via the dependency implementation "me.saket.swipe:swipe:1.3.0").

##### Architectural Patterns & Technologies
- Modular Design: The clear separation between the reusable library, sample application, and tests.
- API Encapsulation: The library exposes composable functions/components that can be integrated by external applications.
- Use of Kotlin and (implied) Jetpack Compose for UI design.
- Gradle for build automation.
- Android-specific components in the sample module (e.g., AndroidManifest.xml, resource files).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Core Swipe Library Module
    subgraph "Core Swipe Library"
        A1["SwipeAction.kt"]:::libraryModule
        A2["SwipeableActionsBox.kt"]:::libraryModule
        A3["SwipeableActionsState.kt"]:::libraryModule
        A4["defaults.kt"]:::libraryModule
        A5["horizontalDraggable.kt"]:::libraryModule
        A6["ActionFinder.kt"]:::libraryModule
        A7["SwipeRipple.kt"]:::libraryModule
    end

    %% Test Suite Module
    subgraph "Test Suite"
        T1["SwipeableActionsBoxTest.kt"]:::testModule
        T2["Snapshots"]:::testModule
    end

    %% Sample Application Module
    subgraph "Sample Application"
        S1["AndroidManifest.xml"]:::sampleModule
        S2["SampleActivity.kt"]:::sampleModule
        S3["Theme.kt"]:::sampleModule
        S4["Resources"]:::sampleModule
    end

    %% Build System & Configuration Module
    subgraph "Build System & Configuration"
        B1["build.gradle.kts"]:::buildModule
        B2["gradle.properties"]:::buildModule
        B3["settings.gradle"]:::buildModule
        B4[".gitignore"]:::buildModule
        subgraph "Gradle Wrapper"
            G1["gradle-wrapper.jar"]:::buildModule
            G2["gradle-wrapper.properties"]:::buildModule
        end
        B5["library/build.gradle.kts"]:::buildModule
        B6["sample/build.gradle.kts"]:::buildModule
    end

    %% Relationships
    S2 -->|"usesAPI"| A1
    T1 -->|"validates"| A1
    B1 -->|"builds"| A1
    B1 -->|"builds"| S2

    %% Click Events for Core Swipe Library
    click A1 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/SwipeAction.kt"
    click A2 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsBox.kt"
    click A3 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/SwipeableActionsState.kt"
    click A4 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/defaults.kt"
    click A5 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/horizontalDraggable.kt"
    click A6 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/ActionFinder.kt"
    click A7 "https://github.com/saket/swipe/blob/trunk/library/src/commonMain/kotlin/me/saket/swipe/SwipeRipple.kt"

    %% Click Events for Test Suite
    click T1 "https://github.com/saket/swipe/blob/trunk/library/src/test/kotlin/me/saket/swipe/SwipeableActionsBoxTest.kt"
    click T2 "https://github.com/saket/swipe/tree/trunk/library/src/test/snapshots"

    %% Click Events for Sample Application
    click S1 "https://github.com/saket/swipe/blob/trunk/sample/src/main/AndroidManifest.xml"
    click S2 "https://github.com/saket/swipe/blob/trunk/sample/src/main/kotlin/me/saket/swipe/sample/SampleActivity.kt"
    click S3 "https://github.com/saket/swipe/blob/trunk/sample/src/main/kotlin/me/saket/swipe/sample/theme/Theme.kt"
    click S4 "https://github.com/saket/swipe/tree/trunk/sample/src/main/res"

    %% Click Events for Build System & Configuration
    click B1 "https://github.com/saket/swipe/blob/trunk/build.gradle.kts"
    click B2 "https://github.com/saket/swipe/blob/trunk/gradle.properties"
    click B3 "https://github.com/saket/swipe/blob/trunk/settings.gradle"
    click B4 "https://github.com/saket/swipe/blob/trunk/.gitignore"
    click G1 "https://github.com/saket/swipe/blob/trunk/gradle/wrapper/gradle-wrapper.jar"
    click G2 "https://github.com/saket/swipe/blob/trunk/gradle/wrapper/gradle-wrapper.properties"
    click B5 "https://github.com/saket/swipe/blob/trunk/library/build.gradle.kts"
    click B6 "https://github.com/saket/swipe/blob/trunk/sample/build.gradle.kts"

    %% Styles
    classDef libraryModule fill:#fef9c3,stroke:#333,stroke-width:2px;
    classDef testModule fill:#c1f0c9,stroke:#333,stroke-width:2px;
    classDef sampleModule fill:#fddde6,stroke:#333,stroke-width:2px;
    classDef buildModule fill:#d1e7dd,stroke:#333,stroke-width:2px;
```
