# maitrungduc1410/react-native-loader-kit architecture

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

- Interactive diagram: https://gitdiagram.com/maitrungduc1410/react-native-loader-kit
- Repository: https://github.com/maitrungduc1410/react-native-loader-kit

## Overview

##### Project type and purpose
- This is a React Native UI component library (“react-native-loader-kit”) that exposes a cross-platform LoaderKitView component.
- It provides various loading animations by bridging from JavaScript/TypeScript into native Android (Kotlin) and iOS (Objective-C++) code.
- The “example” folder is a sample React Native app that consumes the library to demonstrate usage.

##### File structure
- Top-level files: configuration for Yarn, ESLint, Babel, TypeScript, GitHub Actions, Podspec, Turbo.
- android/: Kotlin code under android/src/main/java/com/loaderkit:
– LoaderKitPackage.kt (module registration)
– LoaderKitViewManager.kt (ViewManager)
– LoaderKitView.kt (custom native view wrapping an Android animation library)
- ios/: LoaderKitView.h/.mm (Objective-C++ implementation of the native view)
- src/: JavaScript/TypeScript wrapper:
– LoaderKitViewNativeComponent.ts (JS-side native component)
– index.tsx (exports)
– types.ts (API typings)
– __tests__ (unit tests)
- example/: A full React Native app scaffold (Android + iOS folders, App.tsx, config files) to demonstrate the library.

##### README for additional insights
- It mentions underlying inspirations (AVLoadingIndicatorView, NVActivityIndicatorView) which are likely pulled in by the native code.

a. Main components:
- Consumer App (example or any RN app)
- JavaScript/TypeScript layer (src/index.tsx, NativeComponent)
- React Native Bridge
- Android native module (LoaderKitPackage → LoaderKitViewManager → LoaderKitView → Android animation library)
- iOS native module (LoaderKitView.h/.mm → iOS animation library)
- Build & toolchain components (Metro, Babel, TypeScript compiler, Gradle, CocoaPods)
b. Relationships & interactions:
1. App JS imports LoaderKitView API → calls into JS wrapper.
2. JS wrapper uses React Native’s UIManager to dispatch commands via the Bridge.
3. On Android, the bridge invokes LoaderKitViewManager.createViewInstance(), which instantiates LoaderKitView (backed by NVActivityIndicatorView).
4. On iOS, the bridge invokes the native view factory in LoaderKitView.mm, which uses AVLoadingIndicatorView.
6. Build tools compile TS → JS bundle (Metro), compile native code (Gradle, Xcode), and package artifacts (npm).
c. Architectural patterns & design principles:
- React Native Native Module / Native UI Component pattern (bridge + ViewManager).
- Separation of concerns: JS API layer vs. platform-specific implementations.
- Single Responsibility: each component does one job (JS exports, bridge, view creation, animation rendering).
d. Key technologies:
- React Native (Bridge, UIManager)
- TypeScript, Babel, Metro bundler
- Kotlin for Android native modules
- Objective-C++ for iOS native modules
- Gradle & CocoaPods for native builds

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Consumer App
    subgraph "Consumer App" 
        direction TB
        ExampleApp["Example React Native App"]:::consumer
    end

    %% JS/TS Layer
    subgraph "JS/TS Layer"
        direction TB
        Index["src/index.tsx"]:::js
        NativeWrapper["src/LoaderKitViewNativeComponent.ts"]:::js
        Types["src/types.ts"]:::js
        Tests["src/__tests__"]:::js
    end

    %% React Native Bridge
    subgraph "React Native Bridge"
        direction TB
        RNBridge["React Native UIManager Bridge"]:::bridge
    end

    %% Android Native Module
    subgraph "Android Native Module"
        direction TB
        LoaderKitPackage["LoaderKitPackage.kt"]:::android
        LoaderKitViewManager["LoaderKitViewManager.kt"]:::android
        LoaderKitView["LoaderKitView.kt"]:::android
        NVLib["NVActivityIndicatorView"]:::external
    end

    %% iOS Native Module
    subgraph "iOS Native Module"
        direction TB
        IOSh["ios/LoaderKitView.h"]:::ios
        IOSmm["ios/LoaderKitView.mm"]:::ios
        AVLib["AVLoadingIndicatorView"]:::external
    end

    %% Build & Toolchain
    subgraph "Build & Toolchain"
        direction TB
        TSConfig["tsconfig.json\n tsconfig.build.json"]:::tool
        BabelConfig["babel.config.js"]:::tool
        Metro["example/metro.config.js"]:::tool
        GradleRoot["android/build.gradle"]:::tool
        GradleExample["example/android/app/build.gradle"]:::tool
        CocoaPods["LoaderKit.podspec"]:::tool
        XcodeProj["example/ios/LoaderKitExample.xcodeproj"]:::tool
        CI[".github/workflows/ci.yml"]:::tool
    end

    %% Flow connections
    ExampleApp -->|"imports API"| Index
    Types -->|"provides typings"| Index
    Index -->|"calls NativeComponent"| NativeWrapper
    NativeWrapper -->|"dispatches commands"| RNBridge
    RNBridge -->|"createViewInstance() on Android"| LoaderKitViewManager
    LoaderKitViewManager -->|"instantiates"| LoaderKitView
    LoaderKitView -->|"renders via"| NVLib
    RNBridge -->|"view factory on iOS"| IOSmm
    IOSmm -->|"exposes interface"| IOSh
    IOSmm -->|"renders via"| AVLib

    %% Build tool flows
    Index -->|"compiled by"| TSConfig
    Tests -->|"run by"| TSConfig
    TSConfig -->|"transpile via"| BabelConfig
    BabelConfig -->|"bundle via"| Metro
    NativeWrapper -->|"packaged into",| BabelConfig
    LoaderKitViewManager -->|"build via"| GradleRoot
    LoaderKitView -->|"build via"| GradleExample
    IOSmm -->|"pod install via"| CocoaPods
    XcodeProj -->|"build iOS example"| CocoaPods
    CI -->|"runs workflows"| TSConfig
    CI -->|"runs workflows"| GradleRoot
    CI -->|"runs workflows"| CocoaPods

    %% Click Events
    click ExampleApp "https://github.com/maitrungduc1410/react-native-loader-kit/tree/master/example/"
    click Index "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/src/index.tsx"
    click NativeWrapper "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/src/LoaderKitViewNativeComponent.ts"
    click Types "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/src/types.ts"
    click Tests "https://github.com/maitrungduc1410/react-native-loader-kit/tree/master/src/__tests__"
    click LoaderKitPackage "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/android/src/main/java/com/loaderkit/LoaderKitPackage.kt"
    click LoaderKitViewManager "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/android/src/main/java/com/loaderkit/LoaderKitViewManager.kt"
    click LoaderKitView "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/android/src/main/java/com/loaderkit/LoaderKitView.kt"
    click IOSh "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/ios/LoaderKitView.h"
    click IOSmm "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/ios/LoaderKitView.mm"
    click CocoaPods "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/LoaderKit.podspec"
    click TSConfig "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/tsconfig.json"
    click BabelConfig "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/babel.config.js"
    click Metro "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/example/metro.config.js"
    click GradleRoot "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/android/build.gradle"
    click GradleExample "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/example/android/app/build.gradle"
    click XcodeProj "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/example/ios/LoaderKitExample.xcodeproj"
    click CI "https://github.com/maitrungduc1410/react-native-loader-kit/blob/master/.github/workflows/ci.yml"

    %% Styles
    classDef consumer fill:#D6EAF8,stroke:#2980B9,color:#154360
    classDef js fill:#D0E1F9,stroke:#1976D2,color:#0D47A1
    classDef bridge fill:#FCF3CF,stroke:#F1C40F,color:#7D6608
    classDef android fill:#D5F5E3,stroke:#28B463,color:#1D8348
    classDef ios fill:#E8DAEF,stroke:#8E44AD,color:#4A235A
    classDef external fill:#F5F5F5,stroke:#B3B6B7,color:#616A6B,stroke-dasharray: 5 5
    classDef tool fill:#F2F3F4,stroke:#99A3A4,color:#566573,stroke-dasharray: 2 2
```
