# j-hc/revanced-magisk-module architecture

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

- Interactive diagram: https://gitdiagram.com/j-hc/revanced-magisk-module
- Repository: https://github.com/j-hc/revanced-magisk-module

## Overview

##### Main Components
- CI/CD Pipeline:
– Represent the GitHub Actions workflows (found under .github/workflows, including build.yml and ci.yml). These handle both scheduled (daily) builds and triggered builds when changes occur.
- Build Scripts & Execution Environment:
– Include the build scripts (build.sh and build-termux.sh) that initiate the build process on different platforms (desktop vs. Termux).
- Configuration Management:
– Highlight key configuration files (config.toml and CONFIG.md), which allow customization (possibly generated/edited via rvmm-config-gen). They control which patches are applied and how the builder behaves.
- Binary Toolkit:
– Show the “bin” directory containing various executable tools and libraries (aapt2, apksigner.jar, dexlib2.jar, paccer.jar, htmlq, and toml binaries) that perform essential tasks such as parsing, signing, and assembling APKs.
- Magisk Module Packaging:
– Emphasize the “revanced-magisk” directory. This contains MAGISK-specific resources such as the META-INF (with updater-script and update-binary), and scripts (customize.sh, service.sh, uninstall.sh) that manage installation, updates, and removal within the Magisk ecosystem.
- External Dependencies and Integrations:
– Indicate external tools or services such as the rvmm-config-gen webpage, and reference the links in the README (e.g., zygisk-detach) that assist end users.
- Distribution:
– Note the GitHub Releases and the CI workflow that pushes the final APKs and modules after a successful build.

##### Relationships and Interactions
– The source repository (including configuration and build scripts) is continuously integrated via GitHub Actions. A code change or a timer-based trigger pushes the build into motion.
– The CI/CD pipeline first invokes the build script (either build.sh or build-termux.sh). In turn, these scripts invoke various tools from the “bin” folder.
– Configuration files (config.toml) feed customization parameters into the build process, determining which patches or app modules get processed.
– After building and patching, the project generates deliverables (APK files and/or Magisk modules) and uses the revanced-magisk folder structure for packaging. These deliverables are then pushed to GitHub Releases.
– The CI process also ensures that the modules integrate seamlessly with Magisk and do not trigger safety-net or root detections, relying on prescribed scripts in the module folder.

##### Architectural Patterns and Design Principles
– Modular Separation: Each major component (CI/CD, build scripts, toolkit, configuration, packaging) is logically separated. This helps in isolating concerns (for example, build tools and packaging logic).
– Extensibility: The configuration mechanism (via config.toml and using rvmm-config-gen) allows for easy inclusion/exclusion of patches, supporting future app and patch updates.
– Automation & Continuous Integration: GitHub Actions orchestrate the entire build process in a reproducible, automated manner.
– Platform Independence: Through different build scripts (Termux vs. Desktop) and platform-specific binaries in the “bin” directory, the project supports multiple environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Source Repository"]:::source

    B["CI/CD Pipeline\n(.github/workflows:\nbuild.yml, ci.yml)"]:::cd
    A -->|"triggers"| B

    subgraph "Build Process"
        E["build.sh"]:::build
        F["build-termux.sh"]:::build
        E -->|"initiates"| R["Build Artifacts"]:::build
        F -->|"initiates"| R
    end

    subgraph "Configuration Management"
        G["config.toml"]:::config
        H["CONFIG.md"]:::config
    end

    I["Binary Toolkit\n(bin directory:\naapt2, apksigner.jar,\ndexlib2.jar, paccer.jar,\nhtmlq, toml)"]:::toolkit

    %% Build Scripts interact with Configuration and Toolkit
    E -->|"uses"| G
    E -->|"uses"| H
    E -->|"calls"| I
    F -->|"uses"| G
    F -->|"uses"| H
    F -->|"calls"| I

    %% Build Artifacts passed to Packaging
    R -->|"packages into"| J["Magisk Module Packaging\n(revanced-magisk)"]:::pack

    subgraph "Magisk Module Contents"
        K["META-INF"]:::pack
        L["customize.sh"]:::pack
        M["service.sh"]:::pack
        N["uninstall.sh"]:::pack
    end
    J --> K
    J --> L
    J --> M
    J --> N

    O["Distribution\n(GitHub Releases)"]:::distrib
    J -->|"delivers"| O

    %% External Dependencies
    P["rvmm-config-gen"]:::external
    Q["zygisk-detach"]:::external
    P -->|"generates config for"| G
    Q -->|"integrates with"| J

    %% Connections from CI/CD to Build Process
    B -->|"triggers build scripts"| E
    B -->|"triggers build scripts"| F

    %% Class Definitions
    classDef source fill:#AED581,stroke:#333,stroke-width:2px;
    classDef cd fill:#FFD54F,stroke:#333,stroke-width:2px;
    classDef build fill:#81D4FA,stroke:#333,stroke-width:2px;
    classDef config fill:#FFF59D,stroke:#333,stroke-width:2px;
    classDef toolkit fill:#4FC3F7,stroke:#333,stroke-width:2px;
    classDef pack fill:#FFAB91,stroke:#333,stroke-width:2px;
    classDef distrib fill:#B3E5FC,stroke:#333,stroke-width:2px;
    classDef external fill:#CE93D8,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click B "https://github.com/j-hc/revanced-magisk-module/tree/main/.github/workflows"
    click E "https://github.com/j-hc/revanced-magisk-module/blob/main/build.sh"
    click F "https://github.com/j-hc/revanced-magisk-module/blob/main/build-termux.sh"
    click G "https://github.com/j-hc/revanced-magisk-module/blob/main/config.toml"
    click H "https://github.com/j-hc/revanced-magisk-module/blob/main/CONFIG.md"
    click I "https://github.com/j-hc/revanced-magisk-module/tree/main/bin"
    click J "https://github.com/j-hc/revanced-magisk-module/tree/main/revanced-magisk"
    click K "https://github.com/j-hc/revanced-magisk-module/tree/main/revanced-magisk/META-INF"
    click L "https://github.com/j-hc/revanced-magisk-module/blob/main/revanced-magisk/customize.sh"
    click M "https://github.com/j-hc/revanced-magisk-module/blob/main/revanced-magisk/service.sh"
    click N "https://github.com/j-hc/revanced-magisk-module/blob/main/revanced-magisk/uninstall.sh"
```
