# sjoblomj/mpqdraft architecture

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

- Interactive diagram: https://gitdiagram.com/sjoblomj/mpqdraft
- Repository: https://github.com/sjoblomj/mpqdraft

## Overview

MPQDraft has two user workflows: configure and launch a locally patched game, or create a distributable self-executing MPQ (SEMPQ). Users enter through the GUI or CLI; both workflows use supported-game and plugin concepts, while the patching runtime injects into the target and loads archives and modules. SEMPQ creation packages a stub, patcher, plugins, and mod data. The README documents the product modes and options; several frontend and runtime implementation files were not sampled, so some workflow links are shown as unverified rather than asserted.

Main entry points: [`src/app/gui/patchwizard.cpp`](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/patchwizard.cpp) (Patch wizard), [`src/dll/Patcher.cpp`](https://github.com/sjoblomj/mpqdraft/blob/main/src/dll/Patcher.cpp) (Patcher DLL), [`src/core/PatcherApi.h`](https://github.com/sjoblomj/mpqdraft/blob/main/src/core/PatcherApi.h) (Patcher contract), [`src/app/MPQDraft.cpp`](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/MPQDraft.cpp) (Application entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontends["User interfaces"]
  node_app["Application entry<br/>[MPQDraft.cpp]"]
  node_cli["CLI commands<br/>[CommandParser.cpp]"]
  node_cli_exec["CLI execution<br/>[MPQDraftCLI.cpp]"]
  node_gui["GUI windows<br/>[mainwindow.cpp]"]
  node_patch_wizard["Patch wizard<br/>[patchwizard.cpp]"]
  node_sempq_wizard["SEMPQ wizard<br/>[sempqwizard.cpp]"]
  node_plugin_config["Plugin configuration<br/>[pluginpage.cpp]"]
end

subgraph group_domain["Game and plugin setup"]
  node_game_data["Supported games<br/>[GameData.cpp]"]
  node_game_detection["Game detection<br/>[GameDetection.cpp]"]
  node_plugin_manager["Plugin lifecycle<br/>[PluginManager.cpp]"]
end

subgraph group_patching["Patching runtime"]
  node_patcher_api["Patcher contract<br/>[PatcherApi.h]"]
  node_patcher_dll["Patcher DLL<br/>[Patcher.cpp]"]
  node_dll_entry["DLL initialization<br/>[MPQDraftDLL.cpp]"]
  node_injection["Process injection<br/>[QInjectDLL.cpp]"]
  node_hook_api["API hooks<br/>[QHookAPI.cpp]"]
end

subgraph group_sempq["SEMPQ creation"]
  node_sempq_params["SEMPQ parameters"]
  node_sempq_creator["SEMPQ packaging<br/>[SEMPQCreator.cpp]"]
  node_sempq_stub["Executable stub<br/>[MPQStub.cpp]"]
  node_embedded_files["Embedded file system<br/>[QResource.cpp]"]
end

node_user(("Mod user"))

node_user -->|"starts"| node_app
node_app -->|"selects CLI"| node_cli
node_app -->|"selects GUI"| node_gui
node_cli -.->|"dispatches commands"| node_cli_exec
node_cli_exec -.->|"starts patch"| node_patcher_api
node_gui -.->|"opens patch flow"| node_patch_wizard
node_patch_wizard -->|"uses game data"| node_game_data
node_patch_wizard -->|"uses detection"| node_game_detection
node_patch_wizard -->|"manages plugins"| node_plugin_manager
node_patch_wizard -.->|"starts patch"| node_patcher_api
node_plugin_config -->|"uses plugin manager"| node_plugin_manager
node_patcher_api -->|"calls DLL"| node_patcher_dll
node_patcher_dll -->|"uses injection"| node_injection
node_patcher_dll -->|"uses hooks"| node_hook_api
node_dll_entry -->|"uses patcher"| node_patcher_dll
node_gui -.->|"opens creator"| node_sempq_wizard
node_sempq_wizard -->|"builds parameters"| node_sempq_params
node_sempq_wizard -->|"selects plugins"| node_plugin_manager
node_sempq_params -->|"supplies parameters"| node_sempq_creator
node_sempq_creator -->|"writes embedded files"| node_embedded_files
node_sempq_creator -.->|"packages stub data"| node_sempq_stub
node_sempq_stub -->|"invokes patcher"| node_patcher_api

click node_app "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/MPQDraft.cpp"
click node_cli "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/cli/CommandParser.cpp"
click node_cli_exec "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/cli/MPQDraftCLI.cpp"
click node_gui "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/mainwindow.cpp"
click node_patch_wizard "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/patchwizard.cpp"
click node_sempq_wizard "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/sempqwizard.cpp"
click node_game_data "https://github.com/sjoblomj/mpqdraft/blob/main/src/core/GameData.cpp"
click node_game_detection "https://github.com/sjoblomj/mpqdraft/blob/main/src/core/GameDetection.cpp"
click node_plugin_manager "https://github.com/sjoblomj/mpqdraft/blob/main/src/core/PluginManager.cpp"
click node_plugin_config "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/pluginpage.cpp"
click node_patcher_api "https://github.com/sjoblomj/mpqdraft/blob/main/src/core/PatcherApi.h"
click node_patcher_dll "https://github.com/sjoblomj/mpqdraft/blob/main/src/dll/Patcher.cpp"
click node_dll_entry "https://github.com/sjoblomj/mpqdraft/blob/main/src/dll/MPQDraftDLL.cpp"
click node_injection "https://github.com/sjoblomj/mpqdraft/blob/main/src/common/QInjectDLL.cpp"
click node_hook_api "https://github.com/sjoblomj/mpqdraft/blob/main/src/common/QHookAPI.cpp"
click node_sempq_params "https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/helpers/sempqparamsbuilder.cpp"
click node_sempq_creator "https://github.com/sjoblomj/mpqdraft/blob/main/src/sempq/SEMPQCreator.cpp"
click node_sempq_stub "https://github.com/sjoblomj/mpqdraft/blob/main/src/sempq/stub/MPQStub.cpp"
click node_embedded_files "https://github.com/sjoblomj/mpqdraft/blob/main/src/common/QResource.cpp"

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_app,node_cli,node_cli_exec,node_gui,node_patch_wizard,node_sempq_wizard,node_plugin_config,node_user toneBlue
class node_game_data,node_game_detection,node_plugin_manager toneAmber
class node_patcher_api,node_patcher_dll,node_dll_entry,node_injection,node_hook_api toneMint
class node_sempq_params,node_sempq_creator,node_sempq_stub,node_embedded_files toneRose
```

## Components

### User interfaces

- [Application entry](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/MPQDraft.cpp): `src/app/MPQDraft.cpp`
- [CLI commands](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/cli/CommandParser.cpp): `src/app/cli/CommandParser.cpp`
- [CLI execution](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/cli/MPQDraftCLI.cpp): `src/app/cli/MPQDraftCLI.cpp`
- [GUI windows](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/mainwindow.cpp): `src/app/gui/mainwindow.cpp`
- [Patch wizard](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/patchwizard.cpp): `src/app/gui/patchwizard.cpp`
- [SEMPQ wizard](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/sempqwizard.cpp): `src/app/gui/sempqwizard.cpp`
- [Plugin configuration](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/pluginpage.cpp): `src/app/gui/pluginpage.cpp`

### Game and plugin setup

- [Supported games](https://github.com/sjoblomj/mpqdraft/blob/main/src/core/GameData.cpp): `src/core/GameData.cpp`
- [Game detection](https://github.com/sjoblomj/mpqdraft/blob/main/src/core/GameDetection.cpp): `src/core/GameDetection.cpp`
- [Plugin lifecycle](https://github.com/sjoblomj/mpqdraft/blob/main/src/core/PluginManager.cpp): `src/core/PluginManager.cpp`

### Patching runtime

- [Patcher contract](https://github.com/sjoblomj/mpqdraft/blob/main/src/core/PatcherApi.h): `src/core/PatcherApi.h`
- [Patcher DLL](https://github.com/sjoblomj/mpqdraft/blob/main/src/dll/Patcher.cpp): `src/dll/Patcher.cpp`
- [DLL initialization](https://github.com/sjoblomj/mpqdraft/blob/main/src/dll/MPQDraftDLL.cpp): `src/dll/MPQDraftDLL.cpp`
- [Process injection](https://github.com/sjoblomj/mpqdraft/blob/main/src/common/QInjectDLL.cpp): `src/common/QInjectDLL.cpp`
- [API hooks](https://github.com/sjoblomj/mpqdraft/blob/main/src/common/QHookAPI.cpp): `src/common/QHookAPI.cpp`

### SEMPQ creation

- [SEMPQ parameters](https://github.com/sjoblomj/mpqdraft/blob/main/src/app/gui/helpers/sempqparamsbuilder.cpp): `src/app/gui/helpers/sempqparamsbuilder.cpp`
- [SEMPQ packaging](https://github.com/sjoblomj/mpqdraft/blob/main/src/sempq/SEMPQCreator.cpp): `src/sempq/SEMPQCreator.cpp`
- [Executable stub](https://github.com/sjoblomj/mpqdraft/blob/main/src/sempq/stub/MPQStub.cpp): `src/sempq/stub/MPQStub.cpp`
- [Embedded file system](https://github.com/sjoblomj/mpqdraft/blob/main/src/common/QResource.cpp): `src/common/QResource.cpp`

### Other components

- **Mod user**

## Connections

- Mod user → Application entry: starts
- Application entry → CLI commands: selects CLI (evidence: `src/app/MPQDraft.cpp`)
- Application entry → GUI windows: selects GUI (evidence: `src/app/MPQDraft.cpp`)
- CLI commands → CLI execution: dispatches commands
- CLI execution → Patcher contract: starts patch
- GUI windows → Patch wizard: opens patch flow
- Patch wizard → Supported games: uses game data (evidence: `src/app/gui/patchwizard.cpp`)
- Patch wizard → Game detection: uses detection (evidence: `src/app/gui/patchwizard.cpp`)
- Patch wizard → Plugin lifecycle: manages plugins (evidence: `src/app/gui/patchwizard.cpp`)
- Patch wizard → Patcher contract: starts patch (evidence: `src/app/gui/patchwizard.cpp`)
- Plugin configuration → Plugin lifecycle: uses plugin manager
- Patcher contract → Patcher DLL: calls DLL (evidence: `src/core/PatcherApi.h`)
- Patcher DLL → Process injection: uses injection (evidence: `src/dll/Patcher.cpp`)
- Patcher DLL → API hooks: uses hooks
- DLL initialization → Patcher DLL: uses patcher
- GUI windows → SEMPQ wizard: opens creator
- SEMPQ wizard → SEMPQ parameters: builds parameters (evidence: `src/app/gui/helpers/sempqparamsbuilder.cpp`)
- SEMPQ wizard → Plugin lifecycle: selects plugins (evidence: `src/app/gui/sempqwizard.cpp`)
- SEMPQ parameters → SEMPQ packaging: supplies parameters (evidence: `src/app/gui/helpers/sempqparamsbuilder.cpp`)
- SEMPQ packaging → Embedded file system: writes embedded files (evidence: `src/sempq/SEMPQCreator.cpp`)
- SEMPQ packaging → Executable stub: packages stub data
- Executable stub → Patcher contract: invokes patcher (evidence: `src/sempq/stub/MPQStub.cpp`)
