# trycatchx/rocketx architecture

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

- Interactive diagram: https://gitdiagram.com/trycatchx/rocketx
- Repository: https://github.com/trycatchx/rocketx

## Overview

##### Project type and purpose
- This is an Android‑focused open‑source tool consisting of two main parts:
a) A Gradle plugin (“rocketx”) that speeds up multi‑module Android builds by automatically packaging unchanged modules into AARs and reusing them.
b) An Android Studio (IntelliJ) plugin (“rocketX‑studio‑plugin”) providing a UI button to toggle the Gradle plugin and clean/rebuild actions.

##### File structure
- Top‑level modules:
- app — your main Android application module (applies the rocketx Gradle plugin).
- projectA, libbz/projectB, projectC — sample or additional Android modules demonstrating multi‑module setups.
- libAnnotations — a pure‑Java/Kotlin annotations library used by the build plugin.
- buildSrc — the Kotlin‑based code that implements the Gradle plugin (dependency injection, module‑change detection, local Maven publishing).
- rocketX‑studio‑plugin — the IntelliJ/Android Studio plugin (actions, plugin.xml).
- libs, common.gradle, config.gradle, maven‑publish.gradle — support files for plugin dependencies and publishing.

##### README for additional insights
- The plugin intercepts the Gradle build pipeline, identifies unchanged modules, publishes them as AARs to a local Maven repository, and substitutes module dependencies to speed up compilation.
- The Studio plugin provides UI toggles to activate/deactivate the rocketx plugin or run a “clean + rebuild” action.
- Configuration options such as openLog, excludeModule, dexMergeIncremental, and excludeTransForms control the behavior.

##### Main components and interactions
a. Components
- Developer’s IDE (Android Studio)
- RocketX Studio plugin (IDE extension)
- Gradle build engine
- RocketX Gradle plugin (applied in app module via buildscript/classpath)
- buildSrc plugin code (Kotlin classes: RocketXPlugin, listeners, utils, localMaven)
- Android modules (app, projectA, projectB, projectC, etc.)
- Local Maven repository (on the file system) for intermediate AAR artifacts
- Android SDK & Build Tools
- Final APK packaging task (assemble)

b. Relationships & data flow
1. Developer clicks “RocketX” button in Android Studio → RocketX Studio plugin triggers an IntelliJ action.
2. IDE passes a flag or property to the Gradle invocation (–Drocketx.enabled).
3. Gradle starts, loads buildSrc, applies the RocketXPlugin to the app module.
4. During the transform phase, the plugin inspects timestamps / Git changes to detect unchanged modules.
5. Unchanged modules are compiled once into AARs and published into local Maven.
6. The plugin rewrites module dependencies so that unchanged modules point to their AAR versions.
7. Gradle compiles only the changed modules and merges dex/APK → final APK.
8. Developer runs/install as usual.

c. Architectural patterns & principles
- Plugin-based extension (both IDE & build).
- Incremental compilation by isolating modules.
- Local Maven repository pattern for artifact reuse.
- Listener/callback registration in Gradle’s lifecycle (beforePreBuild, transforms).
- Clear separation: IDE controls vs. build logic.

d. Key technologies
- Kotlin DSL for Gradle (buildSrc, plugin code).
- Gradle Plugin API (Transforms, build listeners).
- IntelliJ Platform SDK for Android Studio plugin (plugin.xml, AnAction).
- AAR packaging & Maven publishing tasks.
- Android SDK/AGP integration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layer 1: Developer & IDE
    Dev["Developer"]:::external
    IDE["Android Studio"]:::ui
    StudioPlugin["RocketX Studio Plugin"]:::ui

    %% Layer 2: Build System
    Gradle["Gradle Build Engine"]:::build
    subgraph "buildSrc Plugin Code"
        direction TB
        RXPlugin["RocketXPlugin"]:::build
        BuildListener["RocketXBuildListener"]:::build
        subgraph "Change Detection & Transforms"
            direction TB
            Utils["Utils & Transforms"]:::build
            Detector{"Module Changed?"}:::decision
        end
        subgraph "Local Maven Publisher"
            direction TB
            LocalMaven["LocalMaven Components"]:::storage
        end
        subgraph "Bean Definitions"
            direction TB
            Beans["Module State Beans"]:::build
        end
    end

    %% Layer 3: Modules & Local Maven
    subgraph "Android Modules"
        direction TB
        App["app Module"]:::module
        ProjectA["projectA Module"]:::module
        ProjectB["projectB (libbz)"]:::module
        ProjectC["projectC Module"]:::module
        Annotations["libAnnotations"]:::module
    end

    LocalRepo["Local Maven Repository"]:::storage

    %% Layer 4: SDK & APK
    SDK["Android SDK & Build Tools"]:::external
    APK["Final APK Packaging"]:::build

    %% Data Flows
    Dev -->|uses| IDE
    IDE -->|click RocketX button| StudioPlugin
    StudioPlugin -->|sets rocketx.enabled| Gradle
    Gradle -->|loads buildSrc| RXPlugin
    RXPlugin --> BuildListener
    BuildListener --> Utils
    Utils --> Detector
    Detector -->|No| LocalMaven
    Detector -->|Yes| GradleCompile["Compile Module"]:::build
    LocalMaven --> LocalRepo
    LocalRepo --> GradleCompile
    GradleCompile --> APK
    Gradle --> Beans
    APK -->|uses| SDK

    %% Click Events
    click RXPlugin "https://github.com/trycatchx/rocketx/blob/master/buildSrc/src/main/kotlin/plugin/RocketXPlugin.kt"
    click BuildListener "https://github.com/trycatchx/rocketx/blob/master/buildSrc/src/main/kotlin/plugin/listener/RocketXBuildListener.kt"
    click LocalMaven "https://github.com/trycatchx/rocketx/tree/master/buildSrc/src/main/kotlin/plugin/localmaven"
    click Utils "https://github.com/trycatchx/rocketx/tree/master/buildSrc/src/main/kotlin/plugin/utils"
    click Beans "https://github.com/trycatchx/rocketx/tree/master/buildSrc/src/main/kotlin/plugin/bean"
    click StudioPlugin "https://github.com/trycatchx/rocketx/tree/master/rocketX‑studio‑plugin"
    click App "https://github.com/trycatchx/rocketx/tree/master/app"
    click ProjectA "https://github.com/trycatchx/rocketx/tree/master/projectA"
    click ProjectB "https://github.com/trycatchx/rocketx/tree/master/libbz/projectB"
    click ProjectC "https://github.com/trycatchx/rocketx/tree/master/projectC"
    click Annotations "https://github.com/trycatchx/rocketx/tree/master/libAnnotations"
    click Gradle "https://github.com/trycatchx/rocketx/blob/master/common.gradle"
    click Gradle "https://github.com/trycatchx/rocketx/blob/master/config.gradle"
    click Gradle "https://github.com/trycatchx/rocketx/blob/master/maven-publish.gradle"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000;
    classDef build fill:#90EE90,stroke:#000;
    classDef module fill:#FFA500,stroke:#000;
    classDef storage fill:#DDA0DD,stroke:#000;
    classDef external fill:#D3D3D3,stroke:#000;
    classDef decision fill:#FFFFE0,stroke:#000,stroke-dasharray: 3 3;
```
