# aurirex/gtfo_thearchive architecture

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

- Interactive diagram: https://gitdiagram.com/aurirex/gtfo_thearchive
- Repository: https://github.com/aurirex/gtfo_thearchive

## Overview

#### Purpose and deliverables
TheArchive is a Windows/.NET mod suite for GTFO. It is split into three mod assemblies: shared runtime/framework (`TheArchive.Core`), player-facing QoL/cosmetic features (`TheArchive.Essentials`), and Discord/Steam presence integration (`TheArchive.RichPresence`). The solution entry point is `TheArchive.sln`; each assembly has its own module entry class:
- `TheArchive.Core/MainArchiveModule.cs`
- `TheArchive.Essentials/ArchiveEssentialsModule.cs`
- `TheArchive.RichPresence/ArchiveRichPresenceModule.cs`

#### Bootstrap and loader boundary
Core owns startup and abstracts game-mod loader integration. Bootstrap code discovers/loads modules and types, while loader adapters isolate BepInEx and MelonLoader-specific concerns:
- `TheArchive.Core/ArchiveBootstrap.cs`
- `TheArchive.Core/Core/Bootstrap/ArchiveModuleChainloader.cs`
- `TheArchive.Core/Loader/BIE_LoaderWrapper.cs`
- `TheArchive.Core/Loader/ML_LoaderWrapper.cs`

The game/loader invokes the mod assembly; Core then establishes logging, module loading, initialization timing, and shared services before feature modules run.

#### Module discovery and lifecycle
Modules implement Core contracts and are annotated with dependency, incompatibility, and initialization metadata. The chainloader/type loader is the principal reflection boundary; it converts discovered assemblies/types into module metadata and schedules initialization based on game readiness interfaces.
- `TheArchive.Core/Core/IArchiveModule.cs`
- `TheArchive.Core/Core/Bootstrap/TypeLoader.cs`
- `TheArchive.Core/Core/Bootstrap/ModuleInfo.cs`
- `TheArchive.Core/Interfaces/IInitAfterGameDataInitialized.cs`

This design permits Essentials and RichPresence to remain separate products while sharing Core’s lifecycle and compatibility rules.

#### Feature and patch framework
Core supplies an attribute-driven feature system. Feature classes declare enablement, settings, update hooks, and game-method patches; `FeatureManager` centrally activates/deactivates them and applies runtime behavior. Patch attributes define prefixes, postfixes, transpilers, constructors, and IL manipulation, forming the boundary to GTFO/Unity internals.
- `TheArchive.Core/Core/FeaturesAPI/FeatureManager.cs`
- `TheArchive.Core/Core/FeaturesAPI/Feature.cs`
- `TheArchive.Core/Core/Attributes/Feature/Patches/ArchivePatch.cs`
- `TheArchive.Core/Core/Attributes/Feature/Patches/IsPrefix.cs`

Essentials is primarily a catalog of these features across accessibility, audio, HUD, fixes, progression, QoL, security, and special behavior, e.g.:
- `TheArchive.Essentials/Features/Hud/HudToggle.cs`
- `TheArchive.Essentials/Features/Fixes/InteractionFix.cs`
- `TheArchive.Essentials/Features/Security/AntiGearHack.cs`

#### Settings, persistence, and UI
Feature settings are modeled by Core and exposed through reusable settings/component abstractions. Enabled-feature state and archive settings are persisted locally; the documented default storage is under LocalLow, with a configurable save location. Settings UI is an internal mod/game UI integration, not a web interface.
- `TheArchive.Core/Core/ArchiveSettings.cs`
- `TheArchive.Core/Core/Settings/EnabledFeatures.cs`
- `TheArchive.Core/Core/FeaturesAPI/FeatureSettingsHelper.cs`
- `TheArchive.Core/Core/FeaturesAPI/Settings/FeatureSetting.cs`

#### Localization and game data integration
Localization is a Core service layer with module- and feature-scoped data, backed by checked-in JSON assets. Core also centralizes GTFO data-block access, build/rundown constraints, interop, and implementation selection—key compatibility boundaries against changing game builds.
- `TheArchive.Core/Core/Localization/LocalizationCoreService.cs`
- `TheArchive.Core/Core/Localization/ModuleLocalizationService.cs`
- `TheArchive.Core/Core/Managers/DataBlockManager.cs`
- `TheArchive.Core/Core/Interop/Interop.cs`

#### Rich presence and external services
RichPresence is an optional module built on Core’s feature/settings model. It manages Discord client state and GTFO/Steam presence changes, using bundled Discord Game SDK material rather than a server-side service in this repository.
- `TheArchive.RichPresence/Core/Managers/ArchiveDiscordManager.cs`
- `TheArchive.RichPresence/Core/Managers/PresenceManager.cs`
- `TheArchive.RichPresence/Features/Presence/DiscordRichPresence.cs`
- `TheArchive.RichPresence/DiscordGameSDK/README.md`

#### Build and distribution
Projects target game-profile references configured outside source (`GameFolder.props`) and require generated interop assemblies from a mod-manager profile. A separate MSBuild solution generates Thunderstore manifests from project metadata:
- `TheArchive.Core/TheArchive.Core.csproj`
- `TheArchive.Essentials/TheArchive.Essentials.csproj`
- `TheArchive.RichPresence/TheArchive.RichPresence.csproj`
- `BuildTasks/ManifestGenerator/ManifestGeneratorTask.cs`

Main entry points: [`TheArchive.Core/TheArchive.Core.csproj`](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/TheArchive.Core.csproj) (Mod projects), [`TheArchive.Core/Core/Bootstrap/ArchiveModuleChainloader.cs`](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Bootstrap/ArchiveModuleChainloader.cs) (Module chainloader), [`TheArchive.Core/Core/FeaturesAPI/FeatureManager.cs`](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/FeaturesAPI/FeatureManager.cs) (Feature manager), [`TheArchive.RichPresence/Core/Managers/PresenceManager.cs`](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/Core/Managers/PresenceManager.cs) (Discord presence manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Core Runtime"]
  node_core_module["Core module entry"]
  node_bootstrap["Bootstrap<br/>startup"]
  node_chainloader["Module chainloader<br/>lifecycle scheduler"]
  node_module_contracts["Module contracts &amp; metadata<br/>[IArchiveModule.cs]"]
  node_type_loader["Reflection type loader<br/>discovery<br/>[TypeLoader.cs]"]
  node_feature_manager["Feature manager<br/>feature runtime<br/>[FeatureManager.cs]"]
  node_patch_api{{"Patch attributes<br/>patch API<br/>[ArchivePatch.cs]"}}
  node_settings["Settings &amp; enabled state<br/>settings model<br/>[ArchiveSettings.cs]"]
  node_local_storage[("Local settings storage<br/>persistence")]
  node_localization["Localization services"]
end

subgraph group_modules["Mod Modules"]
  node_essentials_module["Essentials module entry"]
  node_essentials_features["QoL feature catalog<br/>[HudToggle.cs]"]
  node_richpresence_module["RichPresence module entry"]
  node_presence_manager["Discord presence manager<br/>presence runtime<br/>[PresenceManager.cs]"]
end

subgraph group_external["Game &amp; External SDK"]
  node_loader_adapters{{"Loader adapters<br/>loader boundary"}}
  node_game_interop{{"GTFO data &amp; interop<br/>game compatibility"}}
  node_discord_sdk{{"Discord Game SDK<br/>bundled SDK<br/>[README.md]"}}
end

subgraph group_build["Build &amp; Distribution"]
  node_solution["TheArchive solution<br/>[TheArchive.sln]"]
  node_projects["Mod projects<br/>project files"]
  node_manifest_generator["Thunderstore manifest generator<br/>MSBuild task"]
end

node_solution -->|"builds"| node_projects
node_projects -->|"produces"| node_core_module
node_projects -->|"produces"| node_essentials_module
node_projects -->|"produces"| node_richpresence_module
node_projects -->|"supplies metadata"| node_manifest_generator
node_loader_adapters -->|"invokes"| node_core_module
node_core_module -->|"starts"| node_bootstrap
node_bootstrap -->|"initializes"| node_chainloader
node_chainloader -->|"discovers through"| node_type_loader
node_type_loader -->|"builds metadata from"| node_module_contracts
node_chainloader -->|"loads"| node_essentials_module
node_chainloader -->|"loads"| node_richpresence_module
node_module_contracts -.->|"governs lifecycle"| node_chainloader
node_essentials_module -->|"registers"| node_essentials_features
node_essentials_features -->|"uses"| node_feature_manager
node_richpresence_module -->|"registers"| node_presence_manager
node_presence_manager -->|"uses feature model"| node_feature_manager
node_feature_manager -->|"applies"| node_patch_api
node_feature_manager -->|"reads settings"| node_settings
node_settings -->|"persists to"| node_local_storage
node_feature_manager -->|"uses"| node_localization
node_patch_api -->|"targets game internals via"| node_game_interop
node_presence_manager -->|"observes game state via"| node_game_interop
node_presence_manager -->|"updates client presence"| node_discord_sdk

click node_solution "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.sln"
click node_core_module "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/MainArchiveModule.cs"
click node_loader_adapters "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Loader/BIE_LoaderWrapper.cs"
click node_bootstrap "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/ArchiveBootstrap.cs"
click node_chainloader "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Bootstrap/ArchiveModuleChainloader.cs"
click node_module_contracts "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/IArchiveModule.cs"
click node_type_loader "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Bootstrap/TypeLoader.cs"
click node_feature_manager "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/FeaturesAPI/FeatureManager.cs"
click node_patch_api "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Attributes/Feature/Patches/ArchivePatch.cs"
click node_settings "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/ArchiveSettings.cs"
click node_localization "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Localization/LocalizationCoreService.cs"
click node_game_interop "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Managers/DataBlockManager.cs"
click node_essentials_module "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Essentials/ArchiveEssentialsModule.cs"
click node_essentials_features "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Essentials/Features/Hud/HudToggle.cs"
click node_richpresence_module "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/ArchiveRichPresenceModule.cs"
click node_presence_manager "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/Core/Managers/PresenceManager.cs"
click node_discord_sdk "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/DiscordGameSDK/README.md"
click node_projects "https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/TheArchive.Core.csproj"
click node_manifest_generator "https://github.com/aurirex/gtfo_thearchive/blob/main/BuildTasks/ManifestGenerator/ManifestGeneratorTask.cs"

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_core_module,node_bootstrap,node_chainloader,node_module_contracts,node_type_loader,node_feature_manager,node_patch_api,node_settings,node_local_storage,node_localization toneBlue
class node_essentials_module,node_essentials_features,node_richpresence_module,node_presence_manager toneAmber
class node_loader_adapters,node_game_interop,node_discord_sdk toneMint
class node_solution,node_projects,node_manifest_generator toneRose
```

## Components

### Core Runtime

Shared lifecycle, feature, and game integration framework.

- [Core module entry](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/MainArchiveModule.cs): module entry · `TheArchive.Core/MainArchiveModule.cs`
- [Bootstrap](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/ArchiveBootstrap.cs): startup · Establishes shared services and initialization timing. · `TheArchive.Core/ArchiveBootstrap.cs`
- [Module chainloader](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Bootstrap/ArchiveModuleChainloader.cs): lifecycle scheduler · `TheArchive.Core/Core/Bootstrap/ArchiveModuleChainloader.cs`
- [Module contracts & metadata](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/IArchiveModule.cs): contracts · Defines module dependencies, compatibility, and readiness rules. · `TheArchive.Core/Core/IArchiveModule.cs`
- [Reflection type loader](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Bootstrap/TypeLoader.cs): discovery · `TheArchive.Core/Core/Bootstrap/TypeLoader.cs`
- [Feature manager](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/FeaturesAPI/FeatureManager.cs): feature runtime · Activates and deactivates attribute-driven features. · `TheArchive.Core/Core/FeaturesAPI/FeatureManager.cs`
- [Patch attributes](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Attributes/Feature/Patches/ArchivePatch.cs): patch API · Declares runtime patches against GTFO and Unity methods. · `TheArchive.Core/Core/Attributes/Feature/Patches/ArchivePatch.cs`
- [Settings & enabled state](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/ArchiveSettings.cs): settings model · Models feature settings and persisted enablement. · `TheArchive.Core/Core/ArchiveSettings.cs`
- **Local settings storage**: persistence · Defaults to LocalLow with configurable save location.
- [Localization services](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Localization/LocalizationCoreService.cs): localization · Provides module- and feature-scoped localized data. · `TheArchive.Core/Core/Localization/LocalizationCoreService.cs`

### Mod Modules

Separately shipped feature assemblies.

- [Essentials module entry](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Essentials/ArchiveEssentialsModule.cs): module entry · `TheArchive.Essentials/ArchiveEssentialsModule.cs`
- [QoL feature catalog](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Essentials/Features/Hud/HudToggle.cs): feature catalog · Accessibility, HUD, fixes, progression, security, and QoL features. · `TheArchive.Essentials/Features/Hud/HudToggle.cs`
- [RichPresence module entry](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/ArchiveRichPresenceModule.cs): module entry · `TheArchive.RichPresence/ArchiveRichPresenceModule.cs`
- [Discord presence manager](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/Core/Managers/PresenceManager.cs): presence runtime · Synchronizes GTFO and Steam state with Discord presence. · `TheArchive.RichPresence/Core/Managers/PresenceManager.cs`

### Game & External SDK

Loader, game, and Discord integration boundaries.

- [Loader adapters](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Loader/BIE_LoaderWrapper.cs): loader boundary · Isolates BepInEx and MelonLoader concerns. · `TheArchive.Core/Loader/BIE_LoaderWrapper.cs`
- [GTFO data & interop](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/Core/Managers/DataBlockManager.cs): game compatibility · Centralizes data-block access, build constraints, and interop. · `TheArchive.Core/Core/Managers/DataBlockManager.cs`
- [Discord Game SDK](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.RichPresence/DiscordGameSDK/README.md): bundled SDK · Client SDK material; no server-side service. · `TheArchive.RichPresence/DiscordGameSDK/README.md`

### Build & Distribution

- [TheArchive solution](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.sln): solution · `TheArchive.sln`
- [Mod projects](https://github.com/aurirex/gtfo_thearchive/blob/main/TheArchive.Core/TheArchive.Core.csproj): project files · Target game-profile references and generated interop assemblies. · `TheArchive.Core/TheArchive.Core.csproj`
- [Thunderstore manifest generator](https://github.com/aurirex/gtfo_thearchive/blob/main/BuildTasks/ManifestGenerator/ManifestGeneratorTask.cs): MSBuild task · `BuildTasks/ManifestGenerator/ManifestGeneratorTask.cs`

## Connections

- TheArchive solution → Mod projects: builds
- Mod projects → Core module entry: produces
- Mod projects → Essentials module entry: produces
- Mod projects → RichPresence module entry: produces
- Mod projects → Thunderstore manifest generator: supplies metadata
- Loader adapters → Core module entry: invokes
- Core module entry → Bootstrap: starts
- Bootstrap → Module chainloader: initializes
- Module chainloader → Reflection type loader: discovers through
- Reflection type loader → Module contracts & metadata: builds metadata from
- Module chainloader → Essentials module entry: loads
- Module chainloader → RichPresence module entry: loads
- Module contracts & metadata → Module chainloader: governs lifecycle
- Essentials module entry → QoL feature catalog: registers
- QoL feature catalog → Feature manager: uses
- RichPresence module entry → Discord presence manager: registers
- Discord presence manager → Feature manager: uses feature model
- Feature manager → Patch attributes: applies
- Feature manager → Settings & enabled state: reads settings
- Settings & enabled state → Local settings storage: persists to
- Feature manager → Localization services: uses
- Patch attributes → GTFO data & interop: targets game internals via
- Discord presence manager → GTFO data & interop: observes game state via
- Discord presence manager → Discord Game SDK: updates client presence
