# jnietzsche/wemod-pro-unlocker architecture

> Architecture diagram of the GitHub repository jnietzsche/wemod-pro-unlocker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jnietzsche/wemod-pro-unlocker
- Repository: https://github.com/jnietzsche/wemod-pro-unlocker

## Overview

1. This repository is a Windows-only patcher for the WeMod desktop app. Its purpose is entirely local: detect the installed WeMod files, modify the app’s packaged JavaScript/resources, and make the client behave as if the user has Pro.

2. The codebase is split into three main deliverables:
   - a Rust CLI in `cli/`
   - a .NET/WPF GUI in `gui/`
   - a separate Go-based updater in `updater/`
   There is also a `static/` directory holding a prebuilt GUI installer (`gui-x64.msix`).

3. The core architectural boundary is “user interface vs. patching engine.”  
   The CLI and GUI are different front ends, but both ultimately perform the same class of work: operate on the local WeMod installation on disk and invoke patch/update logic.

4. The Rust CLI is the most explicit implementation of the patching pipeline. Its modules suggest these responsibilities:
   - `folders.rs`, `files.rs`: locate and manipulate the WeMod install tree
   - `versions.rs`: handle version-specific path/layout differences
   - `patches.rs`: apply the actual unlock modifications
   - `asar.rs`: unpack/repack Electron-style `asar` archives
   - `fetchIntercept.js`, `vendorPatch.js`: JavaScript patch payloads inserted into the app bundle
   - `updates.rs`: check or fetch updates for the unlocker itself

5. The CLI ships with native helper binaries in `cli/bin/`, including `asar.exe` and `wemod-pro-unlocker-updater.exe`. That indicates the Rust code orchestrates external executables for archive editing and self-update/distribution support rather than implementing everything in pure Rust.

6. The GUI is a separate WPF application under `gui/WMPU-GUI/`. Its main runtime pieces are:
   - `MainWindow.xaml/.cs`: the user-facing control surface
   - `Utils/UnlockManager.cs`: coordinates the unlock/patch flow
   - `Utils/UpdateManager.cs`: handles updater interactions
   - `Assets/asar.exe`: bundled helper used to edit the WeMod archive
   The GUI is a thin orchestration layer over the same local patching workflow.

7. The GUI’s Windows packaging matters architecturally: `WMPU-GUI.csproj`, `Package.appxmanifest`, and `app.manifest` show it is intended to be installed and run as a Windows desktop app, not as a browser app or service. `WindowsSystemDispatcherQueueHelper.cs` suggests it also contains some Windows-specific UI/runtime plumbing.

8. The updater is its own standalone component in `updater/`, written in Go. Since it has a separate module (`go.mod`) and compiled binary, it is likely used for release/update distribution or self-update logic, independent of the main patching UI. The presence of `wemod-pro-unlocker-updater.exe` in both CLI-related trees reinforces that updater execution is a first-class part of the system.

9. `crates.io-wrapper/` looks like a packaging shim around the updater binary for Rust distribution. In architecture terms, it is not part of the unlock flow itself; it exists to publish or bundle the updater in a form suitable for the Rust ecosystem.

10. The data flow is simple and local:
    user launches CLI or GUI → tool discovers the installed WeMod directory and version → helper binary and patch scripts modify the WeMod app bundle/ASAR contents → the local app is left in a patched state → optional update path checks for a newer unlocker build, likely via GitHub releases.

11. The main external dependency boundary is the filesystem plus Windows process/runtime behavior. Network access appears secondary and only for update distribution, not for the unlock behavior itself. The repository does not contain any backend server or persistent service.

12. For an architecture diagram, the most important boxes are:
    - End-user entry points: CLI, GUI
    - Local patching engine: version/file discovery, ASAR manipulation, JS patch payloads
    - Native helpers: `asar.exe`, updater executable
    - Distribution/update path: Go updater, release artifacts, MSIX installer
    - Target system: installed WeMod app on Windows

Main entry points: [`cli/src/main.rs`](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/main.rs) (CLI), [`cli/src/patches.rs`](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/patches.rs) (Patch core), [`gui/WMPU-GUI/MainWindow.xaml.cs`](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/MainWindow.xaml.cs) (GUI), [`gui/WMPU-GUI/Utils/UnlockManager.cs`](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/Utils/UnlockManager.cs) (Unlock manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontends["Front ends"]
  node_cli_main["CLI<br/>Rust entrypoint<br/>[main.rs]"]
  node_gui_window["GUI<br/>WPF entrypoint<br/>[MainWindow.xaml.cs]"]
  node_unlock_manager["Unlock manager<br/>Orchestrator<br/>[UnlockManager.cs]"]
  node_update_manager["Update manager<br/>Updater bridge<br/>[UpdateManager.cs]"]
end

subgraph group_engine["Patch engine"]
  node_install_discovery["Install discovery<br/>Filesystem locator<br/>[folders.rs]"]
  node_file_ops["File ops<br/>Filesystem adapter<br/>[files.rs]"]
  node_version_rules["Version rules<br/>Layout compat<br/>[versions.rs]"]
  node_archive_tool["ASAR tool<br/>Archive editor<br/>[asar.rs]"]
  node_patch_core["Patch core<br/>Unlock logic<br/>[patches.rs]"]
  node_js_fetch_patch["Fetch patch<br/>JS payload<br/>[fetchIntercept.js]"]
  node_js_vendor_patch["Vendor patch<br/>JS payload<br/>[vendorPatch.js]"]
  node_self_update["Self update<br/>Update flow<br/>[updates.rs]"]
  node_asar_helper["asar.exe<br/>Native helper<br/>[asar.exe]"]
end

subgraph group_distribution["Update and distribution"]
  node_updater_bin["Updater exe<br/>Native helper"]
  node_go_updater["Go updater<br/>Go service<br/>[main.go]"]
  node_crates_wrapper["Crates wrapper<br/>Rust package shim<br/>[main.rs]"]
  node_msix_package["MSIX package<br/>Installer artifact<br/>[gui-x64.msix]"]
end

subgraph group_target["Target system"]
  node_wemod_app[("WeMod app<br/>Windows target")]
  node_windows_runtime(("Windows runtime<br/>OS boundary"))
end

node_cli_main -->|"finds install"| node_install_discovery
node_cli_main -->|"reads/writes"| node_file_ops
node_cli_main -->|"edits archive"| node_archive_tool
node_cli_main -->|"applies unlock"| node_patch_core
node_cli_main -->|"checks updates"| node_self_update
node_install_discovery -->|"resolves layout"| node_version_rules
node_version_rules -->|"guides paths"| node_file_ops
node_patch_core -->|"injects"| node_js_fetch_patch
node_patch_core -->|"injects"| node_js_vendor_patch
node_patch_core -->|"repackages"| node_archive_tool
node_archive_tool -->|"delegates"| node_asar_helper
node_patch_core -->|"modifies"| node_wemod_app
node_gui_window -->|"drives"| node_unlock_manager
node_unlock_manager -->|"finds install"| node_install_discovery
node_unlock_manager -->|"applies unlock"| node_patch_core
node_gui_window -->|"updates"| node_update_manager
node_update_manager -->|"launches"| node_updater_bin
node_updater_bin -->|"implements"| node_go_updater
node_crates_wrapper -->|"packages"| node_updater_bin
node_msix_package -->|"installs"| node_gui_window
node_windows_runtime -->|"hosts"| node_wemod_app
node_cli_main -->|"runs on"| node_windows_runtime
node_gui_window -->|"runs on"| node_windows_runtime

click node_cli_main "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/main.rs"
click node_gui_window "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/MainWindow.xaml.cs"
click node_unlock_manager "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/Utils/UnlockManager.cs"
click node_update_manager "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/Utils/UpdateManager.cs"
click node_install_discovery "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/folders.rs"
click node_file_ops "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/files.rs"
click node_version_rules "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/versions.rs"
click node_archive_tool "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/asar.rs"
click node_patch_core "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/patches.rs"
click node_js_fetch_patch "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/fetchIntercept.js"
click node_js_vendor_patch "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/vendorPatch.js"
click node_self_update "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/updates.rs"
click node_asar_helper "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/bin/asar.exe"
click node_updater_bin "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/bin/wemod-pro-unlocker-updater.exe"
click node_go_updater "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/updater/main.go"
click node_crates_wrapper "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/crates.io-wrapper/src/main.rs"
click node_msix_package "https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/static/gui-x64.msix"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli_main,node_gui_window,node_unlock_manager,node_update_manager toneBlue
class node_install_discovery,node_file_ops,node_version_rules,node_archive_tool,node_patch_core,node_js_fetch_patch,node_js_vendor_patch,node_self_update,node_asar_helper toneAmber
class node_updater_bin,node_go_updater,node_crates_wrapper,node_msix_package toneMint
class node_wemod_app,node_windows_runtime toneRose
```

## Components

### Front ends

User-facing entry points for local unlock/patch workflows.

- [CLI](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/main.rs): Rust entrypoint · Command-line front end that drives the local patching workflow. · `cli/src/main.rs`
- [GUI](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/MainWindow.xaml.cs): WPF entrypoint · Desktop control surface for the unlock flow. · `gui/WMPU-GUI/MainWindow.xaml.cs`
- [Unlock manager](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/Utils/UnlockManager.cs): Orchestrator · Coordinates GUI-side patch and unlock actions. · `gui/WMPU-GUI/Utils/UnlockManager.cs`
- [Update manager](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/gui/WMPU-GUI/Utils/UpdateManager.cs): Updater bridge · Handles GUI-side interaction with update and distribution logic. · `gui/WMPU-GUI/Utils/UpdateManager.cs`

### Patch engine

Shared discovery, archive editing, version handling, and payload application logic.

- [Install discovery](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/folders.rs): Filesystem locator · Finds the installed WeMod tree and relevant files. · `cli/src/folders.rs`
- [File ops](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/files.rs): Filesystem adapter · Reads, writes, and reshapes local application files. · `cli/src/files.rs`
- [Version rules](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/versions.rs): Layout compat · Handles version-specific path and layout differences. · `cli/src/versions.rs`
- [ASAR tool](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/asar.rs): Archive editor · Unpacks and repacks Electron-style application archives. · `cli/src/asar.rs`
- [Patch core](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/patches.rs): Unlock logic · Applies the main unlock modifications to the app bundle. · `cli/src/patches.rs`
- [Fetch patch](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/fetchIntercept.js): JS payload · Injected JavaScript patch content for request interception. · `cli/src/fetchIntercept.js`
- [Vendor patch](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/vendorPatch.js): JS payload · Injected JavaScript patch content for app behavior changes. · `cli/src/vendorPatch.js`
- [Self update](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/src/updates.rs): Update flow · Checks or fetches newer unlocker builds. · `cli/src/updates.rs`
- [asar.exe](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/bin/asar.exe): Native helper · Bundled executable used to edit archives from CLI or GUI. · `cli/bin/asar.exe`

### Update and distribution

Standalone updater and packaging artifacts used to ship or refresh the tool.

- [Updater exe](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/cli/bin/wemod-pro-unlocker-updater.exe): Native helper · Standalone updater binary used by the CLI and packaging paths. · `cli/bin/wemod-pro-unlocker-updater.exe`
- [Go updater](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/updater/main.go): Go service · Standalone updater component built from its own module. · `updater/main.go`
- [Crates wrapper](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/crates.io-wrapper/src/main.rs): Rust package shim · Packaging layer around the updater binary for Rust distribution. · `crates.io-wrapper/src/main.rs`
- [MSIX package](https://github.com/jnietzsche/wemod-pro-unlocker/blob/master/static/gui-x64.msix): Installer artifact · Prebuilt GUI installer used for Windows deployment. · `static/gui-x64.msix`

### Target system

The installed WeMod application and its local Windows runtime environment.

- **WeMod app**: Windows target · Installed local WeMod desktop application being modified on disk.
- **Windows runtime**: OS boundary · Local Windows filesystem, process, and packaging environment.

## Connections

- CLI → Install discovery: finds install · CLI starts by locating the installed WeMod tree.
- CLI → File ops: reads/writes · CLI performs local filesystem manipulation.
- CLI → ASAR tool: edits archive · CLI invokes archive unpack/repack operations.
- CLI → Patch core: applies unlock · CLI drives the main patch sequence.
- CLI → Self update: checks updates · CLI can trigger unlocker update logic.
- Install discovery → Version rules: resolves layout · Discovery consults version-specific rules.
- Version rules → File ops: guides paths · Version handling informs file selection and edits.
- Patch core → Fetch patch: injects · Patch core applies the fetch interception payload.
- Patch core → Vendor patch: injects · Patch core applies the vendor behavior payload.
- Patch core → ASAR tool: repackages · Patch core relies on archive editing to rewrite app resources.
- ASAR tool → asar.exe: delegates · Archive work is offloaded to the bundled helper executable.
- Patch core → WeMod app: modifies · The unlock flow changes the installed WeMod app on disk.
- GUI → Unlock manager: drives · GUI actions are coordinated through the unlock manager.
- Unlock manager → Install discovery: finds install · GUI uses the same local discovery path as the CLI.
- Unlock manager → Patch core: applies unlock · GUI orchestration feeds the shared patching workflow.
- GUI → Update manager: updates · GUI routes update actions through the update manager.
- Update manager → Updater exe: launches · GUI-side update handling uses the standalone updater executable.
- Updater exe → Go updater: implements · The executable is produced by the Go updater project.
- Crates wrapper → Updater exe: packages · Rust packaging shim wraps the updater binary for distribution.
- MSIX package → GUI: installs · The MSIX artifact distributes the WPF GUI.
- Windows runtime → WeMod app: hosts · The target app and all patching activity live within Windows.
- CLI → Windows runtime: runs on · The CLI depends on Windows process and filesystem behavior.
- GUI → Windows runtime: runs on · The GUI depends on Windows packaging and UI runtime behavior.
