# videre-project/mtgosdk architecture

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

- Interactive diagram: https://gitdiagram.com/videre-project/mtgosdk
- Repository: https://github.com/videre-project/mtgosdk

## Overview

##### Core Architecture Layer
- MTGOSDK (Core Package)
- MTGOSDK.MSBuild (Build Tools)
- MTGOSDK.Win32 (Native Interface)

##### Runtime Integration Layer
- ClrMD debugger interface connection between MTGOSDK and the MTGO client
- Injection process flow:
- Process attachment
- Memory inspection
- Object reflection
- ScubaDiver component that handles remote communication

##### API Services Layer
- Chat System
- Collection Manager
- Event System
- Play System
- Trade System
- Settings Manager
- User Management
To show their interactions with the core runtime

##### External Integration Layer
Integration points with:
- MTGO Client Process
- Win32 API
- .NET Runtime
- Reference Assembly Generation

Key Elements to Include:

##### Process Flow
- Bootstrapping process
- Remote procedure calls
- Event subscription paths
- Memory inspection routes

##### Security Boundaries
- Process boundaries
- Privilege levels
- Security context transitions

##### Data Flow
- Primary data paths
- State management routes
- Event propagation

Special Considerations:

##### Remoting Architecture
- Client-server architecture between SDK and MTGO
- RemoteNET-based communication
- Snapshot runtime components

##### Build System
- MSBuild pipeline
- Reference assembly generation
- Code generation paths

##### Win32 Integration
- Native API integration points
- Process manipulation paths
- Memory access routes

- Component types (Core, Build, Native)
- Connection types (Dependencies, Events, Data Flow)
- Process boundaries
- Security contexts
- Data flow directions

Layout Guidelines:
##### Win32 components on the side

Use clear visual hierarchy:
- Different line styles for different types of connections

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client ["MTGO Client Process"]
        MTGO[".NET Runtime & Objects"]
    end

    subgraph Core ["Core Architecture Layer"]
        SDK["MTGOSDK Core"]:::core
        MSBuild["MTGOSDK.MSBuild"]:::build
        Win32["MTGOSDK.Win32"]:::native
        
        SDK <--> MSBuild
        SDK <--> Win32
    end

    subgraph Runtime ["Runtime Integration"]
        ClrMD["ClrMD Debugger"]:::runtime
        Scuba["ScubaDiver"]:::runtime
        Remote["Remote Communication"]:::runtime
        
        ClrMD <--> Scuba
        Scuba <--> Remote
    end

    subgraph API ["API Services Layer"]
        Chat["Chat System"]:::api
        Collection["Collection Manager"]:::api
        Events["Event System"]:::api
        Play["Play System"]:::api
        Trade["Trade System"]:::api
        Settings["Settings Manager"]:::api
        Users["User Management"]:::api
    end

    subgraph Integration ["External Integration"]
        RefGen["Reference Assembly Generation"]:::integration
        Win32API["Win32 API Integration"]:::integration
        ProcMgmt["Process Management"]:::integration
        Runtime["Runtime Reflection"]:::integration
    end

    %% Connections
    MTGO <-.->|Process Attachment| ClrMD
    ClrMD --> SDK
    SDK --> Remote
    Remote --> API
    Win32 --> Win32API
    Win32 --> ProcMgmt
    MSBuild --> RefGen
    SDK --> Runtime

    %% Click Events
    click SDK "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/Core/"
    click MSBuild "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK.MSBuild/"
    click Win32 "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK.Win32/"
    click Scuba "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/lib/ScubaDiver/"
    click Chat "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Chat/"
    click Collection "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Collection/"
    click Events "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Events/"
    click Play "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Play/"
    click Trade "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Trade/"
    click Settings "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Settings/"
    click Users "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/API/Users/"
    click Remote "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/Core/Remoting/"
    click RefGen "https://github.com/videre-project/MTGOSDK/blob/main/MTGOSDK.MSBuild/src/ReferenceAssemblyGenerator.cs"
    click Win32API "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK.Win32/src/API/"
    click Runtime "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK/src/Core/Reflection/"
    click ProcMgmt "https://github.com/videre-project/MTGOSDK/tree/main/MTGOSDK.Win32/src/API/Kernel32/ProcessThreadsAPI/"

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef build fill:#2ecc71,stroke:#27ae60,color:white
    classDef native fill:#e67e22,stroke:#d35400,color:white
    classDef runtime fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#1abc9c,stroke:#16a085,color:white
    classDef integration fill:#f1c40f,stroke:#f39c12,color:black

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Build Tools]:::build
        L3[Native Interface]:::native
        L4[Runtime Components]:::runtime
        L5[API Services]:::api
        L6[Integration Points]:::integration
    end
```
