# gronxb/hot-updater architecture

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

- Interactive diagram: https://gitdiagram.com/gronxb/hot-updater
- Repository: https://github.com/gronxb/hot-updater

## Overview

- Web Console UI: (look in packages/console) – provides an intuitive update management interface.
- Update Management Core: (packages/core) – encapsulates the core update logic, version management (using semantic versioning), and utility functions.
- Hot Updater CLI/Logic: (packages/hot-updater) – handles commands such as initialization, deployment, building and triggering command flows.
- React Native Integration: (packages/react-native) – delivers native module integrations for both Android and iOS to trigger updates on client devices.
- Plugin System: (plugins/…) – houses various plugins for extending functionality:
- Build Plugins (e.g., Metro integration in plugins/metro)
- Storage Plugins (e.g., AWS S3, Cloudflare R2, Supabase Storage, JS-based implementations)
- Database Plugins (e.g., Supabase Database, PostgreSQL, Cloudflare D1 via plugins/aws, plugins/supabase, plugins/postgres, etc.)
- Additional plugins (e.g., plugin-core for helper functions, mock plugins for testing, standalone plugins, etc.)
- Examples and Documentation: (examples/ and docs/) – provide concrete usage examples for different versions and platforms (v0.71, v0.74, v0.77, etc.) as well as extensive user guidance.

##### Out the relationships and interactions
- The Web Console interacts with the Core and Hot Updater backend to trigger deployments and manage OTA updates.
- The Hot Updater CLI uses the core update logic and then delegates specific tasks (build processes, fetching updates, package integrity, etc.) to various plugins.
- The React Native package integrates with mobile apps by consuming update info from the backend, triggering native update processes via methods (e.g., checkForUpdate, runUpdateProcess).
- The Plugin System acts as an abstraction layer. The updater core is connected to different storage and database services (using plugins) that can be interchangeably swapped with configuration (as shown in the README examples for Supabase, Cloudflare, and AWS).
- The configuration file (hot-updater.config.ts) and similar entry points in packages/console and in examples show how users define the plugin configurations for their specific environments.

##### Architectural patterns and design principles
- Modular and extensible design: The separation into distinct packages and plugins indicates adherence to the separation of concerns principle.
- Plugin-based architecture: Extensibility is achieved by abstracting the build, storage, and database concerns into configurable, interchangeable plugins.
- Monorepo structure: Multiple packages coexist with shared configurations (tsconfig.base.json, pnpm-workspace.yaml) ensuring consistency across various components.
- Multi-platform support: There are explicit components for React Native integration as well as separate examples for Android and iOS demonstrating platform-specific builds.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global System Node
    SYS["OTA Update System"]:::backend

    %% Frontend Layer
    subgraph "Frontend Layer"
        WC["Web Console UI"]:::ui
    end

    %% Backend Layer (Core, CLI, Mobile Integration)
    subgraph "Backend Layer"
        Core["Update Management Core"]:::backend
        CLI["Hot Updater CLI/Logic"]:::backend
        RN["React Native Integration"]:::mobile
    end

    %% Plugin System Layer with Sub-Plugins
    subgraph "Plugin System"
        %% Build Plugins
        subgraph "Build Plugins"
            Metro["Metro Integration"]:::plugin
        end
        %% Storage Plugins
        subgraph "Storage Plugins"
            AWS["AWS S3 Plugin"]:::plugin
            Cloudflare["Cloudflare R2 Plugin"]:::plugin
            SupabaseStorage["Supabase Storage Plugin"]:::plugin
            JSPlugins["JS-based Plugin"]:::plugin
            Mock["Mock Implementation"]:::plugin
        end
        %% Database Plugins
        subgraph "Database Plugins"
            Postgres["PostgreSQL Plugin"]:::plugin
            SupabaseDB["Supabase Database Plugin"]:::plugin
            PluginCore["Plugin-Core Helper"]:::plugin
            Standalone["Standalone Plugin"]:::plugin
        end
    end

    %% Examples and Documentation
    subgraph "Examples & Docs"
        Examples["Examples"]:::docs
        Documentation["Documentation"]:::docs
    end

    %% Connections between layers
    SYS --> WC
    WC -->|"API_call"| Core
    WC -->|"API_call"| CLI
    Core -->|"OTA_Update_Flow"| RN
    CLI -->|"build/deploy"| Metro
    CLI -->|"update_deploy"| AWS
    CLI -->|"update_deploy"| Cloudflare
    CLI -->|"update_deploy"| SupabaseStorage
    CLI -->|"update_deploy"| JSPlugins
    CLI -->|"update_deploy"| Mock
    CLI -->|"db_operations"| Postgres
    CLI -->|"db_operations"| SupabaseDB
    CLI -->|"helper_calls"| PluginCore
    CLI -->|"helper_calls"| Standalone
    Core -->|"config_import"| Examples
    Core -->|"config_import"| Documentation
    WC -->|"config_import"| Examples

    %% Click Events for Mapped Components
    click WC "https://github.com/gronxb/hot-updater/tree/main/packages/console"
    click Core "https://github.com/gronxb/hot-updater/tree/main/packages/core"
    click CLI "https://github.com/gronxb/hot-updater/tree/main/packages/hot-updater"
    click RN "https://github.com/gronxb/hot-updater/tree/main/packages/react-native"
    click Metro "https://github.com/gronxb/hot-updater/tree/main/plugins/metro"
    click AWS "https://github.com/gronxb/hot-updater/tree/main/plugins/aws"
    click Cloudflare "https://github.com/gronxb/hot-updater/tree/main/plugins/cloudflare"
    click SupabaseStorage "https://github.com/gronxb/hot-updater/tree/main/plugins/supabase"
    click JSPlugins "https://github.com/gronxb/hot-updater/tree/main/plugins/js"
    click Mock "https://github.com/gronxb/hot-updater/tree/main/plugins/mock"
    click Postgres "https://github.com/gronxb/hot-updater/tree/main/plugins/postgres"
    click PluginCore "https://github.com/gronxb/hot-updater/tree/main/plugins/plugin-core"
    click Standalone "https://github.com/gronxb/hot-updater/tree/main/plugins/standalone"
    click Examples "https://github.com/gronxb/hot-updater/tree/main/examples/"
    click Documentation "https://github.com/gronxb/hot-updater/tree/main/docs/"

    %% Style Definitions
    classDef ui fill:#a0c4ff,stroke:#000,stroke-width:2px;
    classDef backend fill:#ffadad,stroke:#000,stroke-width:2px;
    classDef mobile fill:#ffd6a5,stroke:#000,stroke-width:2px;
    classDef plugin fill:#caffbf,stroke:#000,stroke-width:2px;
    classDef docs fill:#9bf6ff,stroke:#000,stroke-width:2px;
```
