# samuelscheit/react-native-skia-list architecture

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

- Interactive diagram: https://gitdiagram.com/samuelscheit/react-native-skia-list
- Repository: https://github.com/samuelscheit/react-native-skia-list

## Overview

Based on our analysis of the file structure and README, this project is a React Native library focused on providing a high-performance list component (specifically a “Skia” based FlatList and ScrollView component) that leverages the Shopify react-native-skia graphics layer. The library exposes components (SkiaFlatList and SkiaScrollView) designed to integrate seamlessly with React Native’s ecosystem, while also utilizing modern libraries for gesture handling, reanimated behaviors, and keyboard input management.

##### Main Components
- Library API Layer: This includes the public exports (e.g., SkiaFlatList, SkiaScrollView) that app developers use.
- Core List Components:
– FlatList Module: Located in src/FlatList (with its Render, State, and index modules).
– ScrollView Module: Located in src/ScrollView (which further breaks down into Render, State, gesture support, scrollbar, and platform-specific SkiaDomView components).
- Utility Functions: Found in src/Util (modules for DOM handling, interpolation, timing, touch events, etc.).
- Testing & Validation: Represent the src/__tests__ directory where the integration tests reside.
- Documentation: The docs directory (using Docusaurus configuration and static assets) that supports project documentation.
- External Dependencies: Include key external libraries such as:
- @shopify/react-native-skia (the underlying 2D graphics engine).
- react-native-gesture-handler (for gesture input).
- react-native-keyboard-controller (for keyboard management).
- react-native-reanimated (for animations).
- Any other React Native dependencies implicitly used.

##### Relationships and Interactions
- Data Flow: Start with the consumer (the host React Native app) which uses the public API (SkiaFlatList). This API accepts properties like initialData, transformItem, and renderItem.
- Rendering Pipeline: Describe how the library interacts with the React Native Skia engine to generate the actual on-screen render nodes (using SkiaDomApi) – this becomes an important directional data flow.

##### Architectural Patterns & Design Principles
- Modular Design: Emphasize how the project separates core list functionalities (FlatList, ScrollView) from utility functions, following a modular approach.
- Worklet/Thread Management: Highlight the use of worklet functions to perform layout and render calculations off the main thread for performance.
- Separation of Concerns: Clearly separate the “rendering” logic from “state” and “utility” logic, as seen in the dedicated directories and file naming.
- Configuration and Documentation: Note the importance of configuration (babel.config.js, tsconfig files) and extensive docs (docusaurus config, custom CSS) that guide project usage.

##### Detail Priority
- Annotations clarifying that worklets are executed on a separate thread for performance and that the library is built on existing external libraries which handle rendering, gestures, and keyboard events.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    A["React Native App (Consumer)"]:::consumer
    B["Skia Library Public API"]:::core
    U["Utility Functions"]:::util
    T["Testing & Validation"]:::test
    D["Documentation (Docusaurus)"]:::doc

    %% External Dependencies
    E1["Shopify React Native Skia"]:::external
    E2["react-native-gesture-handler"]:::external
    E3["react-native-keyboard-controller"]:::external
    E4["react-native-reanimated"]:::external
    E5["Other RN Dependencies"]:::external

    %% FlatList Module Subgraph
    subgraph "FlatList Module"
        FInterface["FlatList Interface"]:::core
        FRender["FlatList Render"]:::core
        FState["FlatList State"]:::core
    end

    %% ScrollView Module Subgraph
    subgraph "ScrollView Module"
        SInterface["ScrollView Interface"]:::core
        SRender["ScrollView Render"]:::core
        SState["ScrollView State"]:::core
        SGesture["ScrollView Gesture"]:::core
        Scrollbar["Scrollbar Component"]:::core
        SDom["Platform-specific SkiaDomView"]:::core
        SDomWeb["Platform-specific SkiaDomView (Web)"]:::core
    end

    %% Connections
    A -->|"uses"| B

    %% Public API to Modules
    B -->|"delegates to"| FInterface
    B -->|"delegates to"| SInterface

    %% FlatList internal flow
    FInterface -->|"manages state"| FState
    FInterface -->|"triggers render (worklet)"| FRender
    FRender -->|"calls utility (worklet)"| U
    FRender -->|"renders via"| E1

    %% ScrollView internal flow
    SInterface -->|"manages state"| SState
    SInterface -->|"initiates render (worklet)"| SRender
    SInterface -->|"handles gestures"| SGesture
    SInterface -->|"includes"| Scrollbar
    SInterface -->|"integrates"| SDom
    SDom -->|"web support"| SDomWeb
    SRender -->|"calls utility (worklet)"| U
    SRender -->|"renders via"| E1

    %% Gesture and keyboard external integration
    SGesture -->|"enhances gestures"| E2
    SGesture -->|"integrates keyboard events"| E3
    SRender -->|"animations"| E4

    %% Utility influences both modules
    FState ---|"uses"| U
    SState ---|"uses"| U

    %% Testing & Documentation connections
    B -->|"validated by"| T
    B -->|"documented in"| D

    %% External common dependency arrow
    FRender ---|"animation support"| E4
    SRender ---|"animation support"| E4
    SInterface ---|"other RN deps"| E5

    %% Styles
    class A consumer
    class B,FInterface,FRender,FState,SInterface,SRender,SState,SGesture,Scrollbar,SDom,SDomWeb core
    class U util
    class T test
    class D doc
    class E1,E2,E3,E4,E5 external

    %% Click Events
    click B "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/index.ts"
    click FInterface "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/FlatList/index.ts"
    click FRender "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/FlatList/Render.tsx"
    click FState "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/FlatList/State.ts"
    click SInterface "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/index.ts"
    click SRender "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/Render.tsx"
    click SState "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/State.ts"
    click SGesture "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/ScrollGesture.ts"
    click Scrollbar "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/Scrollbar.tsx"
    click SDom "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/SkiaDomView.ts"
    click SDomWeb "https://github.com/samuelscheit/react-native-skia-list/blob/main/src/ScrollView/SkiaDomView.web.ts"
    click U "https://github.com/samuelscheit/react-native-skia-list/tree/main/src/Util"
    click T "https://github.com/samuelscheit/react-native-skia-list/tree/main/src/__tests__"
    click D "https://github.com/samuelscheit/react-native-skia-list/tree/main/docs"
```
