# kerema14/startasanyone architecture

> Architecture diagram of the GitHub repository kerema14/startasanyone, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kerema14/startasanyone
- Repository: https://github.com/kerema14/startasanyone

## Overview

##### Project Type and Purpose
- This is a game mod (plugin) for Mount & Blade II: Bannerlord. Its purpose is to allow players to start as any existing lord by integrating with the game’s character-creation flow.
- It is written in C# (.cs files, .csproj, Solution) and uses Harmony for runtime patching plus XML data for GUI/layout and localization.

##### File-Structure Analysis
- Top-level C# files:
- CharacterCreation*.cs, HeroInfoPageVM.cs, KingdomInfoPageVM.cs, etc. — these implement new view-models and actions injected into the game UI.
- DestroyClanAction2.cs, ReflectionHelper.cs — utility and action-patch classes.
- StartAsAnyone.csproj(.user), StartAsAnyone.sln — build and solution definitions.
- `_Module` directory:
- GUI/Prefabs/*.xml — UI definitions for new screens in Bannerlord’s XML‐based layout system.
- ModuleData/Languages/* — language packs (EN, DE, FR, etc.).
- SubModule.xml — Bannerlord’s module descriptor (metadata, assemblies to load, dependencies like Harmony).
- No separate backend/frontend; instead:
- Game Engine (Bannerlord) hosts the mod assembly.
- Harmony dependency (external mod) required for patching game methods.

##### README Insights
- Describes features, installation steps, dependencies (Harmony), and integration points (main menu → character creation screen).

##### Diagramming the Architecture
a. Main Components
- Bannerlord Game Engine
- Harmony Patcher (external mod dependency)
- StartAsAnyone Mod Assembly (C# DLL)
- Patches & Hooks (ReflectionHelper, Harmony patches)
- ViewModels & Actions (CharacterCreationHeroVM, DestroyClanAction2, etc.)
- XML GUI Prefabs (CharacterCreationStartAsAnyoneOrNewStage.xml)
- Localization ModuleData (language_data.xml, strings.xml)
- SubModule Descriptor (SubModule.xml)
b. Relationships & Interactions
- Bannerlord loads SubModule.xml → identifies and loads the mod’s DLL and XML resources.
- Harmony initializes first: injects patch methods (via ReflectionHelper) into game’s character creation code paths.
- When user opens Character Creation:
- Game calls patched methods → instantiates mod’s ViewModels and Actions.
- XML Prefabs render additional UI controls.
- Localization: UI strings loaded from ModuleData/Languages based on game locale.
c. Architectural Patterns & Principles
- Plugin/Patch architecture using Harmony AOP (Aspect-Oriented Programming).
- MVVM pattern for UI integration (ViewModels + XML Views/Prefabs).
- Resource modularization: separate ASM, GUI, and language packs.
d. Key Technologies
- C#, .NET Core (Bannerlord modding API)
- Harmony for method patching
- Bannerlord XML UI system
- Git for source/version control

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global Entities
    Engine["Bannerlord Game Engine"]:::external
    Harmony["Harmony Patcher"]:::external

    %% SubModule Descriptor
    SubModuleDesc["SubModule.xml"]:::config
    click SubModuleDesc "https://github.com/kerema14/startasanyone/blob/main/_Module/SubModule.xml"
    SubModuleCS["SubModule.cs"]:::config
    click SubModuleCS "https://github.com/kerema14/startasanyone/blob/main/SubModule.cs"

    %% Mod Assembly
    subgraph "StartAsAnyone Mod Assembly" 
        SLA_SLN["StartAsAnyone.sln"]:::config
        click SLA_SLN "https://github.com/kerema14/startasanyone/blob/main/StartAsAnyone.sln"
        SLA_CSPROJ["StartAsAnyone.csproj"]:::config
        click SLA_CSPROJ "https://github.com/kerema14/startasanyone/blob/main/StartAsAnyone.csproj"

        subgraph "Patches & Hooks" 
            ReflectionHelper["ReflectionHelper.cs"]:::logic
            click ReflectionHelper "https://github.com/kerema14/startasanyone/blob/main/ReflectionHelper.cs"
            DestroyClan["DestroyClanAction2.cs"]:::logic
            click DestroyClan "https://github.com/kerema14/startasanyone/blob/main/DestroyClanAction2.cs"
        end

        subgraph "ViewModels & Actions (MVVM)" 
            CharHeroVM["CharacterCreationHeroVM.cs"]:::logic
            click CharHeroVM "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationHeroVM.cs"
            CharHeroFamilyVM["CharacterCreationHeroFamilyVM.cs"]:::logic
            click CharHeroFamilyVM "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationHeroFamilyVM.cs"
            KingdomVM["CharacterCreationKingdomVM.cs"]:::logic
            click KingdomVM "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationKingdomVM.cs"
            KingdomBrush["CharacterCreationKingdomVisualBrushWidget.cs"]:::logic
            click KingdomBrush "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationKingdomVisualBrushWidget.cs"
            StartStageVM["CharacterCreationStartAsAnyoneOrNewStageVM.cs"]:::logic
            click StartStageVM "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationStartAsAnyoneOrNewStageVM.cs"
            HeroInfoVM["HeroInfoPageVM.cs"]:::logic
            click HeroInfoVM "https://github.com/kerema14/startasanyone/blob/main/HeroInfoPageVM.cs"
            KingdomInfoPageVM["KingdomInfoPageVM.cs"]:::logic
            click KingdomInfoPageVM "https://github.com/kerema14/startasanyone/blob/main/KingdomInfoPageVM.cs"
            KingdomInfoVM["KingdomInfoVM.cs"]:::logic
            click KingdomInfoVM "https://github.com/kerema14/startasanyone/blob/main/KingdomInfoVM.cs"
        end

        subgraph "Patch Integration & Views"
            StartStagePatch["CharacterCreationStartAsAnyoneOrNewStage.cs"]:::logic
            click StartStagePatch "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationStartAsAnyoneOrNewStage.cs"
            StartStageView["CharacterCreationStartAsAnyoneOrNewStageView.cs"]:::logic
            click StartStageView "https://github.com/kerema14/startasanyone/blob/main/CharacterCreationStartAsAnyoneOrNewStageView.cs"
        end

        subgraph "Resources" 
            PrefabXML["CharacterCreationStartAsAnyoneOrNewStage.xml"]:::resource
            click PrefabXML "https://github.com/kerema14/startasanyone/blob/main/_Module/GUI/Prefabs/CharacterCreationStartAsAnyoneOrNewStage.xml"
            Languages["ModuleData/Languages"]:::resource
            click Languages "https://github.com/kerema14/startasanyone/tree/main/_Module/ModuleData/Languages"
        end
    end

    %% Interactions
    Engine -->|"loads SubModule.xml"| SubModuleDesc
    SubModuleDesc -->|"loads DLL & resources"| SLA_CSPROJ
    SLA_CSPROJ -->|"references Harmony"| Harmony
    Harmony -->|"injects patches via ReflectionHelper"| ReflectionHelper
    ReflectionHelper -->|"patch methods in"| Engine
    Engine -->|"character creation event"| StartStagePatch
    StartStagePatch -->|"instantiates"| StartStageVM
    StartStageVM -->|"binds to view"| PrefabXML
    Engine -->|"locale setting"| Languages

    %% Styles
    classDef external fill:#cfe2f3,stroke:#6fa8dc,color:#0b5394;
    classDef logic fill:#d9ead3,stroke:#6aa84f,color:#274e13;
    classDef resource fill:#fff2cc,stroke:#f1c232,color:#b45f06;
    classDef config fill:#ead1dc,stroke:#dd7e6b,color:#980000;
```
