# xiu2/stateofdecay2modmanager architecture

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

- Interactive diagram: https://gitdiagram.com/xiu2/stateofdecay2modmanager
- Repository: https://github.com/xiu2/stateofdecay2modmanager

## Overview

1. **Project shape**
   - This is a small **Windows desktop utility** built as a **single WinForms application** in **C# on .NET Framework 4.5**.
   - The solution contains one main form (`Form.cs` / `Form.Designer.cs`) plus the standard `Program.cs` entry point and `App.config`.

2. **User-facing purpose**
   - The app is a **MOD manager for State of Decay 2: Juggernaut Edition**.
   - Its job is to **load MOD archives, catalog their files, detect conflicts, and track install state** so users can manage unpacked game MODs more safely.

3. **Application boundary**
   - The repository is not a multi-service system; architecture is centered on a **desktop UI + local filesystem operations**.
   - There is no evidence of a server, database, or cloud dependency. The main external boundary is the **game’s MOD directory structure** and the **user-provided archive files**.

4. **Startup and shell**
   - `Program.cs` is the app bootstrapper and launches the WinForms UI.
   - `Form` is the primary interaction surface; the README screenshot and instructions indicate most functionality is exposed from that single window.

5. **MOD archive ingestion**
   - The app accepts MOD packages in **ZIP/7Z-like archive formats**, with a strong preference for **.zip**.
   - It validates archive layout by searching for a required **`Content` directory** above the actual MOD assets; archives without that structure are rejected or behave incorrectly.
   - The README explicitly notes that some archive layouts are supported only when MOD files sit under `Content\...`, not at the archive root.

6. **Archive extraction/indexing subsystem**
   - The bundled dependency **SharpCompress** (`packages/SharpCompress.0.24.0`) is the key infrastructure piece for reading archives.
   - The app builds a **file index** for each loaded MOD, which later powers install-state detection, conflict checks, and duplicate-name handling.

7. **Install/uninstall workflow**
   - The core workflow is: **load archive → inspect files → install into the game MOD folder → track as installed**.
   - Uninstalling reverses that relationship by removing the files associated with the indexed MOD.
   - The app also supports recognizing MODs that were installed manually, but only if their archives are loaded first so the file index can be matched.

8. **Conflict detection model**
   - A major subsystem is **file conflict detection** between MODs and existing game files.
   - The app compares file paths to find collisions, then uses a **hash-based equality check** when all files appear to already exist, to distinguish “same MOD already installed” from “different MOD with overlapping files.”

9. **State tracking and local metadata**
   - The tool maintains local metadata in a **`Mods` folder** and a **`Mods.xml`** file inside the app’s working directory.
   - These files are treated as internal state; the README warns users not to edit them directly because they underpin the app’s catalog and installation bookkeeping.

10. **Filesystem boundaries**
   - There are two important filesystem domains:
     - the **app-local state directory** (`Mods`, `Mods.xml`)
     - the **game MOD install location** the tool reads from and writes to
   - The app’s correctness depends on these boundaries staying consistent, especially when detecting already-installed or manually installed MODs.

11. **Performance and format constraints**
   - The README calls out that **large `.7z` archives can be slow to unpack** because of the compression library’s limitations.
   - That constraint materially affects the UX: archive reading is synchronous enough to cause temporary freezes, so archive size/format is part of the architecture.

12. **Resources and packaging**
   - `Resources`, `img`, and the `.resx` files provide **UI assets, localized strings, and embedded resources**.
   - `packages.config` and the checked-in `packages/` folder show the app is built with **NuGet-managed dependencies** and a classic .NET Framework packaging model.

13. **Overall architecture**
   - In diagram terms, this is best drawn as a **single desktop client** with:
     - a WinForms UI layer,
     - a local archive/file indexing layer,
     - a conflict/install-state engine,
     - and filesystem integration to both app-local state and the game’s MOD directory.
   - The main business logic appears concentrated in the form code rather than separated into many classes or services.

Main entry points: [`Form.cs`](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs) (Main form), [`Program.cs`](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Program.cs) (Program), [`Form.Designer.cs`](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.Designer.cs) (Form layout), [`packages/SharpCompress.0.24.0`](https://github.com/xiu2/stateofdecay2modmanager/blob/master/packages/SharpCompress.0.24.0) (SharpCompress)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["WinForms client"]
  node_program["Program<br/>entry point<br/>[Program.cs]"]
  node_main_form["Main form<br/>ui shell<br/>[Form.cs]"]
  node_form_layout["Form layout<br/>ui layout<br/>[Form.Designer.cs]"]
  node_archive_loader["Archive loader<br/>ingestion<br/>[Form.cs]"]
  node_file_index["File index<br/>catalog<br/>[Form.cs]"]
  node_conflict_engine["Conflict engine<br/>comparison<br/>[Form.cs]"]
  node_install_manager["Install manager<br/>workflow<br/>[Form.cs]"]
end

subgraph group_state["Local state"]
  node_state_catalog[("State catalog<br/>metadata store")]
  node_mods_folder[("Mods folder<br/>app cache")]
  node_game_mod_dir[("Game mod dir<br/>filesystem boundary")]
end

subgraph group_deps["Dependencies"]
  node_archive_index["SharpCompress<br/>archive library"]
  node_ui_resources["UI assets<br/>resources"]
  node_img_assets["Image assets"]
  node_app_config["App config<br/>settings<br/>[App.config]"]
end

node_program -->|"launches"| node_main_form
node_main_form -->|"uses"| node_form_layout
node_main_form -->|"drives"| node_archive_loader
node_archive_loader -->|"reads"| node_archive_index
node_archive_loader -->|"builds"| node_file_index
node_archive_loader -->|"reports"| node_main_form
node_file_index -->|"feeds"| node_conflict_engine
node_conflict_engine -->|"checks"| node_game_mod_dir
node_conflict_engine -->|"annotates"| node_install_manager
node_install_manager -->|"writes"| node_game_mod_dir
node_install_manager -->|"records"| node_state_catalog
node_install_manager -->|"stores"| node_mods_folder
node_state_catalog -->|"backed by"| node_mods_folder
node_main_form -->|"renders"| node_ui_resources
node_main_form -->|"renders"| node_img_assets
node_main_form -->|"reads"| node_app_config
node_archive_loader -->|"validates"| node_file_index

click node_program "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Program.cs"
click node_main_form "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs"
click node_form_layout "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.Designer.cs"
click node_archive_loader "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs"
click node_file_index "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs"
click node_conflict_engine "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs"
click node_install_manager "https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs"
click node_archive_index "https://github.com/xiu2/stateofdecay2modmanager/blob/master/packages/SharpCompress.0.24.0"
click node_ui_resources "https://github.com/xiu2/stateofdecay2modmanager/tree/master/Resources"
click node_img_assets "https://github.com/xiu2/stateofdecay2modmanager/tree/master/img"
click node_app_config "https://github.com/xiu2/stateofdecay2modmanager/blob/master/App.config"

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_program,node_main_form,node_form_layout,node_archive_loader,node_file_index,node_conflict_engine,node_install_manager toneBlue
class node_state_catalog,node_mods_folder,node_game_mod_dir toneAmber
class node_archive_index,node_ui_resources,node_img_assets,node_app_config toneMint
```

## Components

### WinForms client

Single desktop application and its main UI/logic surface.

- [Program](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Program.cs): entry point · Bootstraps the WinForms app. · `Program.cs`
- [Main form](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs): ui shell · Primary window and interaction surface. · `Form.cs`
- [Form layout](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.Designer.cs): ui layout · Designer-defined controls and window composition. · `Form.Designer.cs`
- [Archive loader](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs): ingestion · Opens supported MOD archives and validates layout. · `Form.cs`
- [File index](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs): catalog · Indexed view of archive contents used by later checks. · `Form.cs`
- [Conflict engine](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs): comparison · Detects overlapping file paths and same-file equality. · `Form.cs`
- [Install manager](https://github.com/xiu2/stateofdecay2modmanager/blob/master/Form.cs): workflow · Installs, uninstalls, and reconciles MOD install state. · `Form.cs`

### Local state

App-local catalog files and the game install boundary.

- **State catalog**: metadata store · Tracks known MODs and their bookkeeping state.
- **Mods folder**: app cache · App-local storage for indexed MOD data.
- **Game mod dir**: filesystem boundary · State of Decay 2 MOD installation location.

### Dependencies

Bundled library and packaged resources used by the client.

- [SharpCompress](https://github.com/xiu2/stateofdecay2modmanager/blob/master/packages/SharpCompress.0.24.0): archive library · Reads ZIP/7Z-like archives for MOD ingestion. · `packages/SharpCompress.0.24.0`
- [UI assets](https://github.com/xiu2/stateofdecay2modmanager/tree/master/Resources): resources · Embedded strings, images, and form resources. · `Resources`
- [Image assets](https://github.com/xiu2/stateofdecay2modmanager/tree/master/img): assets · Packaged UI imagery. · `img`
- [App config](https://github.com/xiu2/stateofdecay2modmanager/blob/master/App.config): settings · Runtime configuration for the desktop app. · `App.config`

## Connections

- Program → Main form: launches · Starts the WinForms shell.
- Main form → Form layout: uses · Composes the visible window and controls.
- Main form → Archive loader: drives · UI actions trigger archive loading.
- Archive loader → SharpCompress: reads · Uses SharpCompress to inspect archives.
- Archive loader → File index: builds · Creates a per-MOD file catalog.
- Archive loader → Main form: reports · Validation and load status surface in the UI.
- File index → Conflict engine: feeds · Indexed paths are compared for collisions.
- Conflict engine → Game mod dir: checks · Compares against files already present in the game install.
- Conflict engine → Install manager: annotates · Conflict results influence install decisions.
- Install manager → Game mod dir: writes · Installs and removes MOD files.
- Install manager → State catalog: records · Persists install and catalog metadata.
- Install manager → Mods folder: stores · Keeps local indexed MOD data.
- State catalog → Mods folder: backed by · Working state is maintained in the app-local Mods directory.
- Main form → UI assets: renders · Uses embedded assets and strings.
- Main form → Image assets: renders · Uses packaged imagery.
- Main form → App config: reads · Loads runtime settings.
- Archive loader → File index: validates · Requires the expected Content-based archive layout.
