# trixarian/nethersx2-classic architecture

> Architecture diagram of the GitHub repository trixarian/nethersx2-classic, 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/trixarian/nethersx2-classic
- Repository: https://github.com/trixarian/nethersx2-classic

## Overview

##### Main Components
- Input APK: The user’s original AetherSX2 3668 APK.
- Patch Control Scripts: The core scripts (e.g., patch-apk.bat, patch-apk.cmd, patch-apk.sh) that orchestrate the patching process.
- Decompilation Module: Located in the “decomp” folder, it contains batch scripts such as Extract.bat, Hackify.bat, and Pack.bat, which are responsible for decompiling the APK, applying hacks, and repackaging it.
- Build/Compilation Module: In the “builder” folder, which contains build scripts (build-nethersx2.cmd/.sh) and associated libraries (including xdelta and md5sum executables) to compile and integrate the patch changes.
- Assets Repository: The “assets” folder contains configuration files (e.g., GameIndex.yaml), cheats, documentation, and scripts for converting game databases.
- External Tool Integrations: Several tools provided under “lib”, “builder/lib”, and “decomp/lib”. These include:
– Executables such as aapt.exe, xdelta.exe, md5sum.exe, and cmdcolor.exe.
– Java components (e.g., apksigner.jar) and keystore files (android.jks, public.jks).
- Patch Distribution Artifacts: The final output, such as the signed patched APK and optionally an xdelta patch (nethersx2-classic.xdelta) for non-Windows systems.

##### Out Relationships and Data Flow
- From the main control node, branch into two parallel but coordinated flows:
– The Decompilation Module: Illustrating the extraction and hack injection process (using decomp scripts and external tools like apktool).
– The Build Module: Showing how patched data is brought back together—invoking builder scripts and calling build utilities (using xdelta utilities and md5sum for validation).
- Integration of asset/configuration data (from “assets”) which informs the patch’s modifications (e.g., updated GameDB, widescreen and no-interlace patches).
- The output flows from the build module into the final APK creation followed by APK signing using keystore data from “lib” and “decomp/lib”.

##### Architectural Patterns and Principles
- Modular Design: Each directory—assets, decomp, builder, lib—is responsible for a distinct function in the patching process, making the system highly modular.
- Script-based Automation: The primary execution is controlled by batch/shell scripts, with clear demarcations between decompiling/hacking/decompiling and rebuilding/signing phases.
- Separation of Concerns: The architecture clearly separates the patch preparation (assets and configurations) from the core patch application, decompilation, and build-signing flow.
- External Tool Integration: Emphasize how third-party tools (xdelta, apktool, apksigner, aapt) are seamlessly embedded in the pipeline.

##### Relevant Technologies & Frameworks
- Scripting languages (Batch and Shell scripts) to manage the automated process.
- Java (via Java SE Development Kit) is implicitly needed since part of the toolchain (apksigner.jar and possibly parts of the APK building) depends on it.
- External utilities:
– xdelta (binary diff and patching)
– apktool (for reverse-engineering and rebuilding APKs)
– md5sum (for integrity checks)
– cmdcolor (for improved command line output)

## Diagram (Mermaid)

```mermaid
graph TD
    %% Input Layer
    inputAPK("Input APK (AetherSX2 3668)"):::input

    %% Patch Controller Subgraph (Individual Scripts)
    subgraph "Patch Controller Scripts"
        direction TB
        Patch_B("Batch Script"):::script
        Patch_C("CMD Script"):::script
        Patch_S("Shell Script"):::script
    end

    %% Aggregator Node for Patch Controller
    PC("Patch Controller"):::script

    %% Decompilation Module Subgraph
    subgraph "Decompilation Module"
        direction TB
        D_Scripts("Decomp Scripts"):::script
        D_Tools("Decomp Tools"):::tool
    end

    %% Build & Signing Module Subgraph
    subgraph "Build & Signing Module"
        direction TB
        B_Scripts("Build Scripts"):::script
        B_Tools("Build Tools"):::tool
    end

    %% Assets & External Tools and Final Output
    Assets("Assets & Configurations"):::asset
    ExternalTools("External Tools"):::tool
    FinalOutput("Patched & Signed APK (Optional: xdelta patch)"):::output

    %% Connections:
    inputAPK -->|"provides"| Patch_B
    inputAPK -->|"provides"| Patch_C
    inputAPK -->|"provides"| Patch_S

    %% Individual Patch Script nodes aggregate into the Patch Controller
    Patch_B --> PC
    Patch_C --> PC
    Patch_S --> PC

    %% Branching to Modules from Patch Controller
    PC -->|"initiates"| D_Scripts
    PC -->|"initiates"| B_Scripts

    %% Assets feed into both modules
    Assets -->|"configures"| D_Scripts
    Assets -->|"configures"| B_Scripts

    %% External Tools integrate with modules
    ExternalTools -->|"assists"| D_Tools
    ExternalTools -->|"assists"| B_Tools

    %% Flow from Decompilation to Build Module
    D_Tools -->|"provides PatchedData"| B_Scripts

    %% Final output from Build Module
    B_Scripts -->|"builds"| FinalOutput

    %% Click Events for Patch Controller Scripts
    click Patch_B "https://github.com/trixarian/nethersx2-classic/blob/main//patch-apk.bat"
    click Patch_C "https://github.com/trixarian/nethersx2-classic/blob/main//patch-apk.cmd"
    click Patch_S "https://github.com/trixarian/nethersx2-classic/blob/main//patch-apk.sh"

    %% Click Events for Decompilation Module
    click D_Scripts "https://github.com/trixarian/nethersx2-classic/tree/main//decomp"
    click D_Tools "https://github.com/trixarian/nethersx2-classic/tree/main//decomp/lib"

    %% Click Events for Build Module
    click B_Scripts "https://github.com/trixarian/nethersx2-classic/tree/main//builder"
    click B_Tools "https://github.com/trixarian/nethersx2-classic/tree/main//builder/lib"

    %% Click Event for Assets Repository
    click Assets "https://github.com/trixarian/nethersx2-classic/tree/main//assets"

    %% Click Event for External Tools (/lib)
    click ExternalTools "https://github.com/trixarian/nethersx2-classic/tree/main//lib"

    %% Styles
    classDef script fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef tool fill:#9370DB,stroke:#000,stroke-width:1px;
    classDef asset fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef output fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef input fill:#FFB6C1,stroke:#000,stroke-width:1px;
```
