# raytwo/cobalt architecture

> Architecture diagram of the GitHub repository raytwo/cobalt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/raytwo/cobalt
- Repository: https://github.com/raytwo/cobalt

## Overview

##### Main Components

a) Core System Components:
- Loader System (crates/loader)
- Mod Management System (crates/mods)
- Game Data Handler (crates/gamedata)
- Cobalt Core (crates/cobalt)
- Update System (crates/updater)
- Logging System (src/logger)

b) Feature Modules:
- File System Virtualization
- XML/MSBT Merging System
- Vibration System
- Script Extension System
- Configuration Management
- Sequence Handlers

##### Connection and Flow Representation

- Data flow (→)
- Dependencies (⇢)
- Event triggers (⇨)
- File system operations (⇥)

##### Component Details

a) Mod Management:
**VFS (Virtual File System)**
- Mod Provider
- Bucket Map
- Resource Management

b) Core Features:
**Cobalt Core**
- API Layer
- Configuration System
- Event Handling
- Game Integration

c) Runtime Systems:
**Runtime Handlers**
- Script Extensions
- Resource Reloading
- Vibration System

##### Implementation Notes

- Use UML or similar notation for clarity
- Clear boundaries between game code and mod systems
- Error handling and logging paths
- Configuration flow paths
- Auto-update system integration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef ui fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef feature fill:#FF9800,stroke:#F57C00,color:white
    classDef resource fill:#4CAF50,stroke:#388E3C,color:white
    classDef system fill:#607D8B,stroke:#455A64,color:white

    subgraph "User Interface Layer"
        MainMenu["Main Menu Integration"]:::ui
        Settings["Settings Interface"]:::ui
        ModUI["Mod Management Interface"]:::ui
    end

    subgraph "Core Services Layer"
        Cobalt["Cobalt Core"]:::core
        Loader["Loader System"]:::core
        ModManager["Mod Management System"]:::core
        Updater["Update System"]:::core
        Logger["Logging System"]:::system
        Config["Configuration Management"]:::core
        VFS["File System Virtualization"]:::core
    end

    subgraph "Feature Modules Layer"
        Combat["Combat System"]:::feature
        Vibration["Vibration System"]:::feature
        Scripts["Script Extension System"]:::feature
        ResourceMerger["XML/MSBT Merger"]:::feature
        Sequences["Sequence Handlers"]:::feature
    end

    subgraph "Integration Layer"
        GameData["Game Data Handler"]:::resource
        Events["Event System"]:::system
        Resources["Resource Management"]:::resource
        Plugins["Plugin System"]:::system
    end

    %% Connections
    MainMenu --> Cobalt
    Settings --> Config
    ModUI --> ModManager
    
    Cobalt --> Events
    Cobalt --> GameData
    Cobalt --> Config
    
    ModManager --> VFS
    ModManager --> Resources
    
    Loader --> ModManager
    Loader --> GameData
    
    VFS --> Resources
    
    Events --> Scripts
    Events --> Sequences
    Events --> Combat
    
    Config --> Plugins
    
    ResourceMerger --> Resources
    
    %% Click events
    click Loader "https://github.com/Raytwo/Cobalt/blob/master/crates/loader/src/lib.rs"
    click ModManager "https://github.com/Raytwo/Cobalt/blob/master/crates/mods/src/manager.rs"
    click GameData "https://github.com/Raytwo/Cobalt/blob/master/crates/gamedata/src/gamedata.rs"
    click Cobalt "https://github.com/Raytwo/Cobalt/blob/master/crates/cobalt/src/lib.rs"
    click Updater "https://github.com/Raytwo/Cobalt/blob/master/crates/updater/src/lib.rs"
    click Logger "https://github.com/Raytwo/Cobalt/tree/master/src/logger/"
    click VFS "https://github.com/Raytwo/Cobalt/blob/master/crates/mods/src/vfs.rs"
    click ResourceMerger "https://github.com/Raytwo/Cobalt/blob/master/crates/cobalt/src/msbt.rs"
    click Vibration "https://github.com/Raytwo/Cobalt/tree/master/crates/cobalt/src/vibrations/"
    click Scripts "https://github.com/Raytwo/Cobalt/blob/master/crates/cobalt/src/script.rs"
    click Config "https://github.com/Raytwo/Cobalt/tree/master/crates/cobalt/src/config/"
    click Sequences "https://github.com/Raytwo/Cobalt/tree/master/crates/cobalt/src/sequences/"
    click Combat "https://github.com/Raytwo/Cobalt/blob/master/crates/cobalt/src/combatui.rs"
    click MainMenu "https://github.com/Raytwo/Cobalt/tree/master/crates/cobalt/src/sequences/mainmenu/"
    click Settings "https://github.com/Raytwo/Cobalt/tree/master/crates/cobalt/src/sequences/mainmenu/cobaltmenu/sequences/settings/"
    click Resources "https://github.com/Raytwo/Cobalt/blob/master/crates/mods/src/bucket_map.rs"
    click Events "https://github.com/Raytwo/Cobalt/tree/master/crates/cobalt/src/api/events/"
    click Plugins "https://github.com/Raytwo/Cobalt/blob/master/crates/cobalt/src/config/plugins.rs"

    %% Legend
    classDef legendClass fill:#fff,stroke:#ccc
    subgraph Legend
        L1[Core Components]:::core
        L2[UI Elements]:::ui
        L3[Feature Modules]:::feature
        L4[Resource Handlers]:::resource
        L5[System Services]:::system
    end
```
