# obsidianmc/obsidian architecture

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

- Interactive diagram: https://gitdiagram.com/obsidianmc/obsidian
- Repository: https://github.com/obsidianmc/obsidian

## Overview

##### Main Components

a. Core Server Infrastructure:
- Server Core (Server.cs)
- Network Layer (Net directory)
- World Management System (WorldData directory)
- Plugin System (Plugins directory)

b. Client Handling:
- Client Connections
- Packet Processing
- State Management (Login, Play, Configuration states)

c. Game Systems:
- Entity Management
- World Generation
- Block Updates
- Inventory System
- Command System

**┌─ External Interface Layer ─────────────────────┐**
- Minecraft Client Connections                 │
- RCON Interface                              │
- Plugin API                                  │
- Network Protocol Layer ──────────────────────┤
- Packet Handling                             │
- Encryption                                  │
- State Management                            │
- Core Game Systems ───────────────────────────┤
- World Management                            │
- Entity System                               │
- Physics Engine                              │
- Command Processing                          │
- Data & Storage Layer ──────────────────────┤
- World Data                                │
- Player Data                               │
- Configuration                             │
- ┘

##### Connection Types

Different types of connections:

##### Key Components to Highlight

a. Server Core:
- Connection management
- Game loop
- Event dispatch system

b. Network Layer:
- Packet serialization/deserialization
- Protocol version handling
- State management (Login/Play/etc.)

c. World System:
- Chunk management
- World generation
- Physics simulation

d. Plugin Framework:
- Plugin loading/unloading
- Event system
- API interfaces

##### Implementation Details

Use symbols to indicate:
- Interfaces (diamond)
- Abstract classes (hexagon)
- Concrete implementations (rectangle)
- Services (circle)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef external fill:#gray,stroke:#333
    classDef network fill:#blue,stroke:#333
    classDef game fill:#green,stroke:#333
    classDef data fill:#yellow,stroke:#333
    classDef plugin fill:#purple,stroke:#333
    classDef core fill:#red,stroke:#333

    %% External Interface Layer
    subgraph External
        MC[Minecraft Clients]:::external
        RCON[RCON Interface]:::external
        PluginAPI[Plugin API]:::external
    end

    %% Network Protocol Layer
    subgraph Network
        PacketHandler[Packet Handler]:::network
        StateManager[State Manager]:::network
        Protocol[Protocol Implementation]:::network
    end

    %% Core Layer
    subgraph Core
        ServerCore[Server Core]:::core
        EventSystem[Event System]:::core
    end

    %% Game Systems Layer
    subgraph GameSystems
        WorldManager[World Manager]:::game
        EntitySystem[Entity System]:::game
        Physics[Physics Engine]:::game
        Commands[Command System]:::game
        Inventory[Inventory System]:::game
        BlockSystem[Block System]:::game
    end

    %% Plugin Layer
    subgraph Plugins
        PluginManager[Plugin Manager]:::plugin
        EventDispatcher[Event Dispatcher]:::plugin
    end

    %% Data Layer
    subgraph Data
        WorldData[World Data]:::data
        PlayerData[Player Data]:::data
        Config[Configuration]:::data
    end

    %% Connections
    MC --> PacketHandler
    PacketHandler --> StateManager
    StateManager --> ServerCore
    Protocol --> PacketHandler

    ServerCore --> EventSystem
    EventSystem --> EventDispatcher
    
    ServerCore --> WorldManager
    ServerCore --> EntitySystem
    ServerCore --> Commands
    
    WorldManager --> WorldData
    EntitySystem --> PlayerData
    
    PluginManager --> EventDispatcher
    PluginAPI --> PluginManager
    
    WorldManager --> Physics
    EntitySystem --> Physics
    
    Commands --> EventSystem
    Inventory --> EventSystem
    BlockSystem --> WorldManager

    %% Click Events
    click ServerCore "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/Server.cs"
    click EventSystem "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/Services/EventDispatcher.cs"
    click PacketHandler "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian/Net/Packets"
    click StateManager "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian/Net/ClientHandlers"
    click WorldManager "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/WorldData/WorldManager.cs"
    click WorldData "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian/WorldData"
    click PluginManager "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/Plugins/PluginManager.cs"
    click EntitySystem "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian/Entities"
    click Physics "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian/WorldData/Generators"
    click BlockSystem "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/Registries/BlocksRegistry.cs"
    click Inventory "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian.API/Inventory"
    click Commands "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian/Commands"
    click Protocol "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/Net/MinecraftStream.cs"
    click PluginAPI "https://github.com/ObsidianMC/Obsidian/tree/1.21.x/Obsidian.API/Plugins"
    click EventDispatcher "https://github.com/ObsidianMC/Obsidian/blob/1.21.x/Obsidian/Services/EventDispatcher.cs"

    %% Legend
    subgraph Legend
        L1[External Interface]:::external
        L2[Network Component]:::network
        L3[Game System]:::game
        L4[Data Storage]:::data
        L5[Plugin System]:::plugin
        L6[Core System]:::core
    end
```
