# biggerstar/wedecode architecture

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

- Interactive diagram: https://gitdiagram.com/biggerstar/wedecode
- Repository: https://github.com/biggerstar/wedecode

## Overview

Wedecode restores WeChat mini-program and game wxapkg packages into readable source and project files. The main workflow accepts package paths through the CLI or guided scanning, then coordinates unpacking and app/game decompilation into an output directory; users can also operate a local visual workspace. The README documents support for split packages and plugins, multiple source formats, asset recovery, beautified output, automatic decryption, and unpack-only mode. Some workspace internals and format-specific implementations were not fully sampled, so their unverified connections are omitted.

Main entry points: [`src/decompilation-controller.ts`](https://github.com/biggerstar/wedecode/blob/main/src/decompilation-controller.ts) (Decompilation controller), [`src/interface/app-decompilation.ts`](https://github.com/biggerstar/wedecode/blob/main/src/interface/app-decompilation.ts) (Mini-program restore), [`src/bin/wedecode/main-commander-process.ts`](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/main-commander-process.ts) (CLI arguments), [`src/bin/wedecode/scan.ts`](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/scan.ts) (Package scanning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and discovery"]
  node_cli_entry["CLI entry<br/>[wedecode.ts]"]
  node_cli_args["CLI arguments"]
  node_cli_prompts["Guided prompts<br/>[inquirer.ts]"]
  node_package_scan["Package scanning<br/>[scan.ts]"]
  node_cli_common["CLI utilities<br/>[common.ts]"]
end

subgraph group_decode["Package conversion"]
  node_controller["Decompilation controller"]
  node_unpack["wxapkg unpacking<br/>[unpack-wxapkg.ts]"]
  node_app_decode["Mini-program restore"]
  node_game_decode["Mini-game restore"]
  node_base_decode["Shared decompiler"]
end

subgraph group_runtime["Decompilation internals"]
  node_file_io["File operations<br/>[fs-process.ts]"]
  node_decrypt["Package decryption<br/>[decrypt-wxapkg.ts]"]
  node_wxml["WXML reconstruction<br/>[decompile-wxml.ts]"]
  node_vm["VM execution<br/>[create-vm.ts]"]
  node_pack_info["Package code analysis"]
  node_wxapp_info["Mini-program metadata<br/>[wxapp-info.ts]"]
  node_project_config["Project configuration<br/>[project-config.ts]"]
  node_default_files["Default file generation"]
  node_cleaner["Output cleanup<br/>[file-cleaner.ts]"]
  node_polyfill["Polyfill overrides<br/>[ployfill-cover.ts]"]
end

subgraph group_workspace["Visual workspace"]
  node_workspace_cli["Workspace commands<br/>[workspace-cli.ts]"]
  node_workspace_server["Workspace server"]
  node_ui["Browser UI<br/>[app.js]"]
end

node_user(("User"))
node_package_input["wxapkg input"]
node_output["Restored output"]
node_output_dir["Workspace files"]

node_user -->|"starts"| node_cli_entry
node_user -->|"provides"| node_package_input
node_package_input -->|"specifies path"| node_cli_args
node_cli_entry -->|"dispatches"| node_cli_args
node_cli_entry -->|"starts UI"| node_workspace_server
node_cli_args -->|"invokes scan"| node_package_scan
node_cli_args -->|"requests input"| node_cli_prompts
node_cli_args -->|"starts conversion"| node_controller
node_package_scan -->|"selects package"| node_cli_prompts
node_package_scan -->|"fetches metadata"| node_wxapp_info
node_package_scan -->|"uses path helpers"| node_cli_common
node_controller -->|"unpacks packages"| node_unpack
node_controller -->|"runs app restore"| node_app_decode
node_controller -->|"runs game restore"| node_game_decode
node_controller -->|"updates metadata"| node_wxapp_info
node_controller -->|"generates config"| node_project_config
node_controller -->|"generates defaults"| node_default_files
node_controller -->|"cleans output"| node_cleaner
node_unpack -->|"decrypts package"| node_decrypt
node_unpack -->|"reads and writes"| node_file_io
node_unpack -.->|"extracts files"| node_output
node_app_decode -->|"extends"| node_base_decode
node_game_decode -->|"extends"| node_base_decode
node_app_decode -->|"analyzes code"| node_pack_info
node_app_decode -->|"reconstructs markup"| node_wxml
node_app_decode -.->|"executes modules"| node_vm
node_app_decode -->|"saves restored files"| node_file_io
node_base_decode -->|"applies overrides"| node_polyfill
node_base_decode -->|"uses file operations"| node_file_io
node_game_decode -->|"analyzes code"| node_pack_info
node_workspace_cli -->|"controls server"| node_workspace_server
node_workspace_server -.->|"manages workspace"| node_output_dir
node_ui -.->|"communicates with"| node_workspace_server

click node_cli_entry "https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/wedecode.ts"
click node_cli_args "https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/main-commander-process.ts"
click node_cli_prompts "https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/inquirer.ts"
click node_package_scan "https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/scan.ts"
click node_cli_common "https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/common.ts"
click node_controller "https://github.com/biggerstar/wedecode/blob/main/src/decompilation-controller.ts"
click node_unpack "https://github.com/biggerstar/wedecode/blob/main/src/interface/unpack-wxapkg.ts"
click node_app_decode "https://github.com/biggerstar/wedecode/blob/main/src/interface/app-decompilation.ts"
click node_game_decode "https://github.com/biggerstar/wedecode/blob/main/src/interface/game-decompilation.ts"
click node_base_decode "https://github.com/biggerstar/wedecode/blob/main/src/interface/base-decompilation.ts"
click node_file_io "https://github.com/biggerstar/wedecode/blob/main/src/utils/fs-process.ts"
click node_decrypt "https://github.com/biggerstar/wedecode/blob/main/src/utils/decrypt-wxapkg.ts"
click node_wxml "https://github.com/biggerstar/wedecode/blob/main/src/utils/decompile-wxml.ts"
click node_vm "https://github.com/biggerstar/wedecode/blob/main/src/utils/create-vm.ts"
click node_pack_info "https://github.com/biggerstar/wedecode/blob/main/src/utils/get-pack-codeInfo.ts"
click node_wxapp_info "https://github.com/biggerstar/wedecode/blob/main/src/utils/wxapp-info.ts"
click node_project_config "https://github.com/biggerstar/wedecode/blob/main/src/utils/project-config.ts"
click node_default_files "https://github.com/biggerstar/wedecode/blob/main/src/utils/default-files-generator.ts"
click node_cleaner "https://github.com/biggerstar/wedecode/blob/main/src/utils/file-cleaner.ts"
click node_polyfill "https://github.com/biggerstar/wedecode/blob/main/src/interface/ployfill-cover.ts"
click node_workspace_cli "https://github.com/biggerstar/wedecode/blob/main/src/workspace/workspace-cli.ts"
click node_workspace_server "https://github.com/biggerstar/wedecode/blob/main/src/workspace/workspace-server.ts"
click node_ui "https://github.com/biggerstar/wedecode/blob/main/public/app.js"

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_entry,node_cli_args,node_cli_prompts,node_package_scan,node_cli_common,node_user toneBlue
class node_controller,node_unpack,node_app_decode,node_game_decode,node_base_decode toneAmber
class node_file_io,node_decrypt,node_wxml,node_vm,node_pack_info,node_wxapp_info,node_project_config,node_default_files,node_cleaner,node_polyfill toneMint
class node_workspace_cli,node_workspace_server,node_ui toneRose
class node_package_input,node_output,node_output_dir toneIndigo
```

## Components

### Entry and discovery

- [CLI entry](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/wedecode.ts): `src/bin/wedecode/wedecode.ts`
- [CLI arguments](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/main-commander-process.ts): `src/bin/wedecode/main-commander-process.ts`
- [Guided prompts](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/inquirer.ts): `src/bin/wedecode/inquirer.ts`
- [Package scanning](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/scan.ts): `src/bin/wedecode/scan.ts`
- [CLI utilities](https://github.com/biggerstar/wedecode/blob/main/src/bin/wedecode/common.ts): `src/bin/wedecode/common.ts`

### Package conversion

- [Decompilation controller](https://github.com/biggerstar/wedecode/blob/main/src/decompilation-controller.ts): `src/decompilation-controller.ts`
- [wxapkg unpacking](https://github.com/biggerstar/wedecode/blob/main/src/interface/unpack-wxapkg.ts): `src/interface/unpack-wxapkg.ts`
- [Mini-program restore](https://github.com/biggerstar/wedecode/blob/main/src/interface/app-decompilation.ts): `src/interface/app-decompilation.ts`
- [Mini-game restore](https://github.com/biggerstar/wedecode/blob/main/src/interface/game-decompilation.ts): `src/interface/game-decompilation.ts`
- [Shared decompiler](https://github.com/biggerstar/wedecode/blob/main/src/interface/base-decompilation.ts): `src/interface/base-decompilation.ts`

### Decompilation internals

- [File operations](https://github.com/biggerstar/wedecode/blob/main/src/utils/fs-process.ts): `src/utils/fs-process.ts`
- [Package decryption](https://github.com/biggerstar/wedecode/blob/main/src/utils/decrypt-wxapkg.ts): `src/utils/decrypt-wxapkg.ts`
- [WXML reconstruction](https://github.com/biggerstar/wedecode/blob/main/src/utils/decompile-wxml.ts): `src/utils/decompile-wxml.ts`
- [VM execution](https://github.com/biggerstar/wedecode/blob/main/src/utils/create-vm.ts): `src/utils/create-vm.ts`
- [Package code analysis](https://github.com/biggerstar/wedecode/blob/main/src/utils/get-pack-codeInfo.ts): `src/utils/get-pack-codeInfo.ts`
- [Mini-program metadata](https://github.com/biggerstar/wedecode/blob/main/src/utils/wxapp-info.ts): `src/utils/wxapp-info.ts`
- [Project configuration](https://github.com/biggerstar/wedecode/blob/main/src/utils/project-config.ts): `src/utils/project-config.ts`
- [Default file generation](https://github.com/biggerstar/wedecode/blob/main/src/utils/default-files-generator.ts): `src/utils/default-files-generator.ts`
- [Output cleanup](https://github.com/biggerstar/wedecode/blob/main/src/utils/file-cleaner.ts): `src/utils/file-cleaner.ts`
- [Polyfill overrides](https://github.com/biggerstar/wedecode/blob/main/src/interface/ployfill-cover.ts): `src/interface/ployfill-cover.ts`

### Visual workspace

- [Workspace commands](https://github.com/biggerstar/wedecode/blob/main/src/workspace/workspace-cli.ts): `src/workspace/workspace-cli.ts`
- [Workspace server](https://github.com/biggerstar/wedecode/blob/main/src/workspace/workspace-server.ts): `src/workspace/workspace-server.ts`
- [Browser UI](https://github.com/biggerstar/wedecode/blob/main/public/app.js): `public/app.js`

### Other components

- **User**
- **wxapkg input**
- **Restored output**
- **Workspace files**

## Connections

- User → CLI entry: starts (evidence: `README.md`)
- User → wxapkg input: provides (evidence: `README.md`)
- wxapkg input → CLI arguments: specifies path (evidence: `README.md`)
- CLI entry → CLI arguments: dispatches (evidence: `src/bin/wedecode/wedecode.ts`)
- CLI entry → Workspace server: starts UI (evidence: `src/bin/wedecode/wedecode.ts`)
- CLI arguments → Package scanning: invokes scan (evidence: `src/bin/wedecode/main-commander-process.ts`)
- CLI arguments → Guided prompts: requests input (evidence: `src/bin/wedecode/main-commander-process.ts`)
- CLI arguments → Decompilation controller: starts conversion (evidence: `src/bin/wedecode/main-commander-process.ts`)
- Package scanning → Guided prompts: selects package (evidence: `src/bin/wedecode/scan.ts`)
- Package scanning → Mini-program metadata: fetches metadata (evidence: `src/bin/wedecode/scan.ts`)
- Package scanning → CLI utilities: uses path helpers (evidence: `src/bin/wedecode/scan.ts`)
- Decompilation controller → wxapkg unpacking: unpacks packages (evidence: `src/decompilation-controller.ts`)
- Decompilation controller → Mini-program restore: runs app restore (evidence: `src/decompilation-controller.ts`)
- Decompilation controller → Mini-game restore: runs game restore (evidence: `src/decompilation-controller.ts`)
- Decompilation controller → Mini-program metadata: updates metadata (evidence: `src/decompilation-controller.ts`)
- Decompilation controller → Project configuration: generates config (evidence: `src/decompilation-controller.ts`)
- Decompilation controller → Default file generation: generates defaults (evidence: `src/decompilation-controller.ts`)
- Decompilation controller → Output cleanup: cleans output (evidence: `src/decompilation-controller.ts`)
- wxapkg unpacking → Package decryption: decrypts package (evidence: `src/interface/unpack-wxapkg.ts`)
- wxapkg unpacking → File operations: reads and writes (evidence: `src/interface/unpack-wxapkg.ts`)
- wxapkg unpacking → Restored output: extracts files (evidence: `README.md`)
- Mini-program restore → Shared decompiler: extends (evidence: `src/interface/app-decompilation.ts`)
- Mini-game restore → Shared decompiler: extends (evidence: `src/interface/game-decompilation.ts`)
- Mini-program restore → Package code analysis: analyzes code (evidence: `src/interface/app-decompilation.ts`)
- Mini-program restore → WXML reconstruction: reconstructs markup (evidence: `src/interface/app-decompilation.ts`)
- Mini-program restore → VM execution: executes modules (evidence: `src/interface/app-decompilation.ts`)
- Mini-program restore → File operations: saves restored files (evidence: `src/interface/app-decompilation.ts`)
- Shared decompiler → Polyfill overrides: applies overrides (evidence: `src/interface/base-decompilation.ts`)
- Shared decompiler → File operations: uses file operations (evidence: `src/interface/base-decompilation.ts`)
- Mini-game restore → Package code analysis: analyzes code (evidence: `src/interface/game-decompilation.ts`)
- Workspace commands → Workspace server: controls server (evidence: `src/workspace/workspace-cli.ts`)
- Workspace server → Workspace files: manages workspace
- Browser UI → Workspace server: communicates with
