# laynz28/ytvancedx architecture

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

- Interactive diagram: https://gitdiagram.com/laynz28/ytvancedx
- Repository: https://github.com/laynz28/ytvancedx

## Overview

##### Project type & purpose
- This is a multi-module Android application plus a companion CLI tool, designed to produce and integrate “patches” into Google’s YouTube APK. The two primary modules are:
- vanced-patches-rvx: a Kotlin/Java CLI (command-line) application that reads patch definitions (fingerprints, bytecode/resource transforms, JSON metadata) and generates patch artifacts.
- vanced-integrations-rvx: an Android Gradle module (Java/Kotlin) that takes the original YouTube and YouTube Music APKs plus the generated patch artifacts, applies integrations (SponsorBlock, ReturnYouTubeDislike, swipe controls, UI tweaks, MicroG support, etc.), and builds final modded APKs.
- GitHub Actions drive CI (build/test) and releases.

##### High-level system components
- Developer environment (IDE/Terminal)
- GitHub repository (.github workflows, issue templates, funding)
- CI/CD: GitHub Actions → build CLI, build Android artifacts, publish to GitHub Releases
- vanced-patches-rvx (CLI)
- vanced-integrations-rvx (Android app + integrations)
- Upstream YouTube APKs (input binaries)
- External APIs/services:
- SponsorBlock API
- ReturnYouTubeDislike API
- MicroG authentication endpoints
- Output: patched YouTube APKs published as GitHub releases

##### Relationships & data flow
1. Developer commits code → pushes to GitHub
2. GitHub Actions workflow “android.yml” / “release.yml” triggers:
a. Build vanced-patches-rvx CLI (Gradle/Kotlin)
b. CLI reads patches.json + fingerprint/source directories → generates patch JARs/metadata
c. Build vanced-integrations-rvx (Android Gradle):
– Inputs: original YouTube APK (`base.apk`), generated patch JARs, resource overlays, integration code
– Applies all patch transforms via the CLI or ReVanced Core library
– Produces final modded APK(s)
d. Test artifacts on emulator/connected devices (optional)
e. Package and publish APK(s) + SHA sums to GitHub Releases
3. End users download microG APK + patched YouTube APK

##### Architectural patterns & design principles
- Modular separation:
- CLI module (patch generator) has no Android dependencies
- Android integration module depends on patch artifacts only as inputs
- Single pipeline for reproducible builds (infrastructure-as-code via GitHub Actions)
- Clear layering: patch definitions → patch generation → integration → final product
- Use of Gradle multi-project structure for isolated builds and dependency management

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Environment"
        Dev(["Developer"]):::user
    end

    Dev -->|push code| Repo["GitHub Repo"]:::infra

    subgraph "CI/CD Pipeline"
        AndroidWf["Android Workflow"]:::infra
        ReleaseWf["Release Workflow"]:::infra
    end

    Repo -->|trigger| AndroidWf
    Repo -->|trigger| ReleaseWf

    AndroidWf -->|build| CLI["vanced-patches-rvx CLI"]:::code
    AndroidWf -->|build| Integration["vanced-integrations-rvx Android Module"]:::code

    CLI -->|generate patches| PatchArtifacts["Patch Artifacts"]:::code
    Integration -->|input| OriginalAPK["Original YouTube APKs"]:::external
    Integration -->|apply patches| FinalAPK["Final Modded APKs"]:::release
    AndroidWf -->|publish| Release["GitHub Releases"]:::release

    subgraph "External Services"
        SB["SponsorBlock API"]:::external
        RYD["ReturnYouTubeDislike API"]:::external
        MG["MicroG OAuth"]:::external
    end

    Integration <-->|runtime call| SB
    Integration <-->|runtime call| RYD
    Integration <-->|runtime call| MG

    User["End User"]:::user
    User -->|download| Release

    %% Click Events
    click AndroidWf "https://github.com/laynz28/ytvancedx/blob/master/.github/workflows/android.yml"
    click ReleaseWf "https://github.com/laynz28/ytvancedx/blob/master/.github/workflows/release.yml"
    click CLI "https://github.com/laynz28/ytvancedx/tree/master/src/vanced-patches-rvx"
    click Integration "https://github.com/laynz28/ytvancedx/tree/master/src/vanced-integrations-rvx"
    click SB "https://github.com/laynz28/ytvancedx/tree/master/src/vanced-integrations-rvx/app/src/main/java/app/revanced/integrations/sponsorblock"
    click RYD "https://github.com/laynz28/ytvancedx/blob/master/src/vanced-integrations-rvx/app/src/main/java/app/revanced/integrations/returnyoutubedislike/ReturnYouTubeDislike.java"
    click MG "https://github.com/laynz28/ytvancedx/tree/master/src/vanced-patches-rvx/src/main/kotlin/app/revanced/patches/microg"
    click Repo "https://github.com/laynz28/ytvancedx/blob/master/.github"
    click PatchArtifacts "https://github.com/laynz28/ytvancedx/blob/master/src/vanced-patches-rvx/patches.json"

    %% Styles
    classDef code fill:#CCF,stroke:#333,stroke-width:1px
    classDef infra fill:#CFC,stroke:#333,stroke-width:1px
    classDef external fill:#FCC,stroke:#333,stroke-width:1px
    classDef release fill:#C9C,stroke:#333,stroke-width:1px
    classDef user fill:#EEE,stroke:#333,stroke-width:1px
```
