# mensonones/rnsplash architecture

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

- Interactive diagram: https://gitdiagram.com/mensonones/rnsplash
- Repository: https://github.com/mensonones/rnsplash

## Overview

##### Project Type & Purpose
- RNSplash is a React Native module focused on providing customizable splash screen animations.
- The module includes both JavaScript (React Native) layers and native components for Android (and iOS) to integrate an animated splash experience.
- Key features include support for diverse animation types (fade, scale, none), configurable duration and delay, and integration with native lifecycle events.

##### Main Components
a. JavaScript Layer:
- App.tsx: Entry point where the splash is hidden via the native module.
- NativeSplash.ts: Contains the abstraction that calls the native code.
- Package.json, tsconfig.json, etc: Configuration for the React Native project.
b. Android Native Module:
- Files under android/app/src/main/java/com/rnsplash/ (SplashModule.kt, RCTSplashScreen.kt, SplashPackage.kt, MainActivity.kt, etc.) implementing the native splash functionality.
- Android resource files (AndroidManifest.xml, drawable assets) for styling and configuring the native splash screen.
c. iOS Native Module:
- Contained under the ios directory (RNSplash.xcodeproj, AppDelegate, Info.plist, LaunchScreen.storyboard, etc.) which provides the iOS counterpart for the splash functionality.
d. Assets & Configurations:
- assets directory, image resources (e.g., splash.png), and configuration files (babel.config.js, metro.config.js) that support project build and runtime behavior.

##### Relationships & Interactions
- The JavaScript code (NativeSplash.ts) exposes a hideSplashScreen function to the rest of the application.
- When invoked (e.g., in App.tsx), this function triggers native code via the React Native bridge.
- On Android, this bridges into the native module (SplashModule.kt) via package registration (SplashPackage.kt) and is hooked into the activity lifecycle (MainActivity.kt) to display/close the splash screen.
- In parallel, the iOS side (managed in Xcode) similarly utilizes native components to handle splash display logic.
- The assets (images, configuration files) support both native environments and inform the build process.

##### Architectural Patterns & Design Principles
- Bridge Pattern: Emphasize that the React Native bridge facilitates communication between JavaScript and native code.
- Modular Design: Highlight the encapsulated modules for splash functionality that can be customized via configuration options (animationType, duration, delay).

- One toward the Android module:
- MainActivity.kt, which initializes the splash on app startup.
- RCTSplashScreen.kt and SplashModule.kt managing the Android-specific splash screen.
- The drawable assets and resource configuration.
- One toward the iOS module:
- Xcode project layout with AppDelegate, LaunchScreen.storyboard, etc.
- How configuration settings (animationType, duration, delay) are passed throughout the system.
- Finally, include external build/process descriptors like Gradle, npm/yarn, and configuration tools (ESLint, Prettier, etc.) as ancillary components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% React Native Layer
    subgraph "React Native Layer"
        RN1["App.tsx"]
        RN2["NativeSplash.ts"]
        subgraph "Config Files"
            C1["package.json"]
            C2["tsconfig.json"]
            C3["babel.config.js"]
            C4["metro.config.js"]
            C5[".eslintrc.js"]
            C6[".prettierrc.js"]
        end
    end

    %% React Native Bridge
    subgraph "React Native Bridge"
        RNBridge["Bridge"]
    end

    %% Android Native Module
    subgraph "Android Native Module"
        A1["MainActivity.kt"]
        A2["RCTSplashScreen.kt"]
        A3["SplashModule.kt"]
        A4["SplashPackage.kt"]
        A5["AndroidManifest.xml & Resources"]
    end

    %% iOS Native Module
    subgraph "iOS Native Module"
        I1["RNSplash.xcodeproj"]
        I2["AppDelegate"]
        I3["Info.plist"]
        I4["LaunchScreen.storyboard"]
        I5["Images.xcassets"]
    end

    %% Assets
    subgraph "Assets & Resources"
        Assets["assets directory"]
    end

    %% Build Tools (Ancillary)
    subgraph "Build Tools"
        B1["npm/yarn"]
        B2["Gradle"]
        B3["Xcode"]
    end

    %% Connections in React Native Flow
    RN1 -->|"callsHideSplash"| RN2
    RN2 -->|"invokes"| RNBridge

    %% Bridge triggers native modules
    RNBridge -->|"triggers"| A1
    RNBridge -->|"triggers"| A2
    RNBridge -->|"triggers"| A3
    RNBridge -->|"triggers"| A4
    RNBridge -->|"configures"| A5

    RNBridge -->|"triggers"| I1
    RNBridge -->|"triggers"| I2
    RNBridge -->|"triggers"| I3
    RNBridge -->|"triggers"| I4
    RNBridge -->|"configures"| I5

    %% Assets feed into native modules
    Assets -->|"providesAssets"| A5
    Assets -->|"providesAssets"| I5

    %% Build Tools relationships
    B1 -->|"builds"| RN1
    B2 -->|"builds"&nbsp;Android| A5
    B3 -->|"builds"&nbsp;iOS| I1

    %% Class Definitions for styling
    classDef js fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef nativeAndroid fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef nativeIOS fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef bridge fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef build fill:#E6E6FA,stroke:#000,stroke-width:2px;

    %% Applying styles
    class RN1,RN2 js;
    class C1,C2,C3,C4,C5,C6,Assets config;
    class RNBridge bridge;
    class A1,A2,A3,A4,A5 nativeAndroid;
    class I1,I2,I3,I4,I5 nativeIOS;
    class B1,B2,B3 build;

    %% Click Events for React Native Layer
    click RN1 "https://github.com/mensonones/rnsplash/blob/main/App.tsx"
    click RN2 "https://github.com/mensonones/rnsplash/blob/main/NativeSplash.ts"
    click C1 "https://github.com/mensonones/rnsplash/blob/main/package.json"
    click C2 "https://github.com/mensonones/rnsplash/blob/main/tsconfig.json"
    click C3 "https://github.com/mensonones/rnsplash/blob/main/babel.config.js"
    click C4 "https://github.com/mensonones/rnsplash/blob/main/metro.config.js"
    click C5 "https://github.com/mensonones/rnsplash/blob/main/.eslintrc.js"
    click C6 "https://github.com/mensonones/rnsplash/blob/main/.prettierrc.js"

    %% Click Events for Android Native Module
    click A1 "https://github.com/mensonones/rnsplash/blob/main/android/app/src/main/java/com/rnsplash/MainActivity.kt"
    click A2 "https://github.com/mensonones/rnsplash/blob/main/android/app/src/main/java/com/rnsplash/splashscreen/RCTSplashScreen.kt"
    click A3 "https://github.com/mensonones/rnsplash/blob/main/android/app/src/main/java/com/rnsplash/splashscreen/SplashModule.kt"
    click A4 "https://github.com/mensonones/rnsplash/blob/main/android/app/src/main/java/com/rnsplash/splashscreen/SplashPackage.kt"
    click A5 "https://github.com/mensonones/rnsplash/blob/main/android/app/src/main/AndroidManifest.xml"

    %% Click Events for iOS Native Module
    click I1 "https://github.com/mensonones/rnsplash/blob/main/ios/RNSplash.xcodeproj"
    click I2 "https://github.com/mensonones/rnsplash/blob/main/ios/RNSplash/AppDelegate.h"
    click I3 "https://github.com/mensonones/rnsplash/blob/main/ios/RNSplash/Info.plist"
    click I4 "https://github.com/mensonones/rnsplash/blob/main/ios/RNSplash/LaunchScreen.storyboard"
    click I5 "https://github.com/mensonones/rnsplash/blob/main/ios/RNSplash/Images.xcassets"

    %% Click Event for Assets
    click Assets "https://github.com/mensonones/rnsplash/tree/main/assets"
```
