# vantuan88291/react-native-ota-hot-update architecture

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

- Interactive diagram: https://gitdiagram.com/vantuan88291/react-native-ota-hot-update
- Repository: https://github.com/vantuan88291/react-native-ota-hot-update

## Overview

##### Main Components
- React Native Module Core – This is the heart of the project, which interfaces with the JavaScript (JS) layer via React Native’s bridge. It’s implemented in the “src” and “plugin” directories, which include TypeScript definitions and native interfaces.
- Native Code for Android – Found in the “android” directory (and mirrored in parts within the “example/android” folder), this includes Kotlin/Java files such as OtaHotUpdate.kt, OtaHotUpdateModule.kt, and native configuration (e.g., AndroidManifest.xml). Note the two architectures (“newarch” and “oldarch”) that the project supports.
- Update Sources – The system is built to fetch JS bundle updates either directly from a custom server (see DOC_OTA_SERVER.md) or from a Git repository (see DOC_OTA_GIT.md).
- Optional CMS/Administration Panel – Referenced in OTA_CMS.md, this component is used to build a custom admin panel (for example with Strapi) to manage versioning and control OTA updates.
- Example Application – Under the “example” directory, you have a complete demo application that shows how to integrate and use the module in real-world scenarios on both Android and iOS.

##### Relationships and Interactions
- The native iOS and Android components provide a method (e.g., getBundle() or bundleJS) that is called at runtime when the app starts, replacing the local JS bundle with the updated one.
- The update manager is integrated with external update sources: a server or Git repository, from which the JS bundle is downloaded.
- The CMS or admin panel (if implemented) serves as a control center for update management and versioning.
- In the case of background downloads (detailed in the README for both platforms), show how the native code initiates background tasks and then signals completion back to the app.

##### Architectural Patterns and Design Principles
- Separation of concerns: Divide components clearly into platform-specific native modules, the React Native bridge, and the external update management systems (server/Git).
- Backward compatibility: Note the dual support for “new architecture” and “old architecture” for Android.
- Modularity: The module’s layered design (separate folders for core JS logic, native integrations, and example apps) reflects clean extensibility and ease of integration.
- Clear abstraction boundaries: The interface provided to React Native apps is abstracted away from the underlying update retrieval and installation logic.

##### Relevant Technologies and Frameworks
- React Native for cross-platform mobile development.
- Android components built using Kotlin/Java.
- iOS components using Objective-C/Swift, along with bridging headers when needed.
- TypeScript for providing type definitions in the “plugin” and “src” directories.
- Tools like “react-native-blob-util” for download progress (as per the README) and potentially Strapi (or similar) for a CMS solution.
- Build tools include Gradle (Android), Xcode project files (iOS), and JavaScript tooling (babel.config.js, package.json, yarn).

##### Essential Elements
- Optionally, highlight the architectural pattern (separation of concerns, modular design, and support for multiple native architectures) using annotations or callouts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Update Management
    CMS["CMS/Admin Panel"]:::cms
    US["Update Sources (Server/Git)"]:::update

    CMS -->|"adminControl"| US

    %% Native Modules Subgraphs
    subgraph "Android Native Module"
        ANDROID_CORE["Native Code (android/src/main/java/com/otahotupdate/)"]:::native
        ANDROID_EX["Example Android (example/android)"]:::native
        ANDROID_CORE -->|"integrates"| ANDROID_EX
    end

    subgraph "iOS Native Module"
        IOS_CORE["Native Code (ios)"]:::native
        IOS_EX["Example iOS (example/ios)"]:::native
        IOS_CORE -->|"integrates"| IOS_EX
    end

    %% React Native Module Core Subgraph
    subgraph "React Native Module Core"
        RN_JS["JS Core (src)"]:::js
        RN_PLUGIN["Plugin Definitions (plugin)"]:::js
        RN_JS -->|"collaborates"| RN_PLUGIN
    end

    %% Example Application
    EXAMPLE_APP["Example Application"]:::app

    %% Connections between components
    US -->|"downloadBundle"| ANDROID_CORE
    US -->|"downloadBundle"| IOS_CORE

    ANDROID_CORE ---|"bridge"| RN_JS
    IOS_CORE ---|"bridge"| RN_JS

    RN_JS -->|"injectBundle"| EXAMPLE_APP

    %% Click Events
    click RN_JS "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/src/"
    click RN_PLUGIN "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/plugin/"
    click ANDROID_CORE "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/android/src/main/java/com/otahotupdate/"
    click ANDROID_EX "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/example/android/"
    click IOS_CORE "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/ios/"
    click IOS_EX "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/example/ios/"
    click US "https://github.com/vantuan88291/react-native-ota-hot-update/blob/main/DOC_OTA_SERVER.md"
    click CMS "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/cms/"
    click EXAMPLE_APP "https://github.com/vantuan88291/react-native-ota-hot-update/tree/main/example/"

    %% Styles
    classDef cms fill:#f9c,stroke:#333,stroke-width:2px;
    classDef update fill:#ff9,stroke:#333,stroke-width:2px;
    classDef native fill:#9ff,stroke:#333,stroke-width:2px;
    classDef js fill:#9f9,stroke:#333,stroke-width:2px;
    classDef app fill:#f99,stroke:#333,stroke-width:2px;
```
