# aaron-zhlg/react-native-snap-carousel architecture

> Architecture diagram of the GitHub repository aaron-zhlg/react-native-snap-carousel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aaron-zhlg/react-native-snap-carousel
- Repository: https://github.com/aaron-zhlg/react-native-snap-carousel

## Overview

##### Project type and purpose
- This is a React Native UI component library (react-native-snap-carousel). Its purpose is to provide customizable carousel, pagination and parallax-image components for Android and iOS apps. It ships as an NPM package and includes an `/example` React Native app showing integration and usage.

##### File structure
- Top-level:
- src/ – the library’s source modules (Carousel, Pagination, ParallaxImage, utils)
- example/ – a standalone React Native project demonstrating the library (with Android/Gradle and iOS/Xcode subfolders, Metro bundler, Babel config, sample JS code under example/src)
- doc/ – markdown docs for props, custom layouts, known issues, etc.
- config files & CI (package.json, .eslintrc, .gitignore, README.md)
- Patterns:
- Modular React components under src/
- Example app structured as a typical RN monorepo (native Android & iOS projects + JS entry points)
- Babel/Metro build pipeline for both library and example

##### Key points from README
- React Native components interacting with Animated, FlatList/ScrollView
- Supports different layouts (“default,” “stack,” “tinder”) via custom interpolation functions
- Provides `<Carousel>`, `<Pagination>`, `<ParallaxImage>` components
- Example folder is a live demo, replicating a real RN app

##### Elements
- Clear labels:
- “Carousel module,” “Pagination module,” “ParallaxImage module,” “animations utils”
- “Babel transpiler,” “Metro bundler,” “NPM registry,” “React Native runtime,” “Android native,” “iOS native”
- From src/ modules → build pipeline → NPM registry → example/node_modules
- From example JS → Metro bundler → device emulator/simulator
- From Carousel → Animated API → FlatList/ScrollView
- Rectangles for JS modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Library Internals
    subgraph "Library Internals"
        direction TB
        Entry["src/index.js"]:::jsModule
        Carousel["Carousel module"]:::jsModule
        Pagination["Pagination module"]:::jsModule
        ParallaxImage["ParallaxImage module"]:::jsModule
        AnimUtils["Animation utils"]:::jsModule
        subgraph "Documentation"
            PROPS["PROPS_METHODS_AND_GETTERS.md"]:::doc
            PAGINATION_DOC["PAGINATION.md"]:::doc
            PARALLAX_DOC["PARALLAX_IMAGE.md"]:::doc
            CUSTOM_INT["CUSTOM_INTERPOLATIONS.md"]:::doc
            ISSUES["KNOWN_ISSUES.md"]:::doc
            TIPS["TIPS_AND_TRICKS.md"]:::doc
            VERSION["VERSION_4.md"]:::doc
        end
    end

    %% Build & Packaging Pipeline
    Babel["Babel transpiler"]:::build
    Dist["dist/ (transpiled)"]:::jsModule
    NPM["NPM registry"]:::registry

    %% Demo App
    subgraph "Demo App"
        direction TB
        ExEntry["example/src/index.js"]:::jsModule
        ExSliderEntry["SliderEntry.js"]:::jsModule
        ExUtils["example/src/utils/animations.js"]:::jsModule
        subgraph "Styles"
            ExStyle1["SliderEntry.style.js"]:::jsModule
            ExStyle2["index.style.js"]:::jsModule
        end
        subgraph "Build & Bundler Configs"
            BabelCfg["babel.config.js"]:::build
            MetroCfg["metro.config.js"]:::build
            ExPkg["example/package.json"]:::jsModule
            GradleWrapper["gradle-wrapper.properties"]:::build
        end
        subgraph "Android Native" 
            MA["MainActivity.java"]:::nativeAndroid
            MApp["MainApplication.java"]:::nativeAndroid
            BuildGradle["build.gradle"]:::nativeAndroid
            SettingsGradle["settings.gradle"]:::nativeAndroid
        end
        subgraph "iOS Native"
            ADH["AppDelegate.h"]:::nativeIos
            ADM["AppDelegate.m"]:::nativeIos
            MM["main.m"]:::nativeIos
            PBX["project.pbxproj"]:::nativeIos
        end
    end

    %% External Dependencies & Runtime
    RNRuntime["React Native runtime"]:::external
    AnimatedAPI["Animated API"]:::external
    FlatList["FlatList/ScrollView"]:::external
    Emu["Device Emulator/Simulator"]:::external

    %% Connections: Library build and publish
    Carousel --> Entry
    Pagination --> Entry
    ParallaxImage --> Entry
    AnimUtils --> Entry
    Entry --> Babel
    Babel --> Dist
    Dist -->|publish| NPM

    %% Example app install & bundle
    NPM -->|install| ExPkg
    ExEntry --> MetroCfg
    ExPkg --> MetroCfg
    MetroCfg --> RNRuntime
    ExEntry --> MetroCfg
    MetroCfg --> Emu

    %% Example app components usage
    ExEntry --> ExSliderEntry
    ExEntry --> ExUtils
    ExEntry --> ExStyle1
    ExEntry --> ExStyle2
    ExEntry --> MA
    ExEntry --> ADH

    %% Native run flow
    MA --> MetroCfg
    MApp --> MetroCfg
    ADH --> MetroCfg
    ADM --> MetroCfg
    MM --> MetroCfg
    PBX --> MetroCfg
    BuildGradle --> MetroCfg
    SettingsGradle --> MetroCfg

    %% Runtime interactions
    Carousel -->|uses| AnimatedAPI
    Carousel -->|renders| FlatList
    Pagination -->|subscribes to scroll| Carousel
    ParallaxImage -->|consumes scroll offset| Carousel
    ExEntry -->|imports| Carousel
    ExEntry -->|imports| Pagination
    ExEntry -->|imports| ParallaxImage

    %% Click Events
    click Carousel "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/carousel/Carousel.js"
    click Pagination "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/pagination/Pagination.js"
    click PaginationDot "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/pagination/PaginationDot.js"
    click PaginationStyle "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/pagination/Pagination.style.js"
    click ParallaxImage "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/parallaximage/ParallaxImage.js"
    click ParallaxImageStyle "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/parallaximage/ParallaxImage.style.js"
    click AnimUtils "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/utils/animations.js"
    click Entry "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/src/index.js"
    click PROPS "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/PROPS_METHODS_AND_GETTERS.md"
    click PAGINATION_DOC "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/PAGINATION.md"
    click PARALLAX_DOC "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/PARALLAX_IMAGE.md"
    click CUSTOM_INT "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/CUSTOM_INTERPOLATIONS.md"
    click ISSUES "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/KNOWN_ISSUES.md"
    click TIPS "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/TIPS_AND_TRICKS.md"
    click VERSION "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/doc/VERSION_4.md"
    click ExEntry "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/src/index.js"
    click ExSliderEntry "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/src/components/SliderEntry.js"
    click ExUtils "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/src/utils/animations.js"
    click ExStyle1 "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/src/styles/SliderEntry.style.js"
    click ExStyle2 "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/src/styles/index.style.js"
    click MA "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/android/app/src/main/java/com/example/MainActivity.java"
    click MApp "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/android/app/src/main/java/com/example/MainApplication.java"
    click BuildGradle "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/android/app/build.gradle"
    click SettingsGradle "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/android/settings.gradle"
    click ADH "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/ios/example/AppDelegate.h"
    click ADM "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/ios/example/AppDelegate.m"
    click MM "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/ios/example/main.m"
    click PBX "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/ios/example.xcodeproj/project.pbxproj"
    click BabelCfg "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/babel.config.js"
    click MetroCfg "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/metro.config.js"
    click ExPkg "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/package.json"
    click GradleWrapper "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/example/android/gradle/wrapper/gradle-wrapper.properties"
    click RootESLint "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/.eslintrc"
    click Gitignore "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/.gitignore"
    click NPMIgnore "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/.npmignore"
    click RootPkg "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/package.json"
    click README "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/README.md"
    click Changelog "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/CHANGELOG.md"
    click Contrib "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/CONTRIBUTING.md"
    click PRTemplate "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/PULL_REQUEST_TEMPLATE.md"
    click IssueTemplate "https://github.com/aaron-zhlg/react-native-snap-carousel/blob/master/ISSUE_TEMPLATE.md"
    click License "https://github.com/aaron-zhlg/react-native-snap-carousel/tree/master/LICENSE"

    %% Styles
    classDef jsModule fill:#f9f,stroke:#333
    classDef build fill:#ff9,stroke:#333,stroke-dasharray: 5 5
    classDef registry fill:#9ff,stroke:#333,stroke-width:2,stroke-dasharray: 1 0
    classDef nativeAndroid fill:#ccf,stroke:#333
    classDef nativeIos fill:#cfc,stroke:#333
    classDef external fill:#fcf,stroke:#333
    classDef doc fill:#cff,stroke:#333,stroke-dasharray: 2 2
```
