# justanotherdot/cobolcraft architecture

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

- Interactive diagram: https://gitdiagram.com/justanotherdot/cobolcraft
- Repository: https://github.com/justanotherdot/cobolcraft

## Overview

##### Main Components

a) Core Server Components:
- Network Layer (Socket Management)
- Protocol Handler
- World Management
- Player Management
- Command System
- Data Storage

b) External Dependencies:
- CBL_GC_SOCKET Library
- C++ Utilities
- Minecraft Protocol Data

**┌─ Client Interface Layer ─────────────────────┐**
- Socket Management (CBL_GC_SOCKET)          │
- Protocol Encoding/Decoding                 │
- ┬───────────────────────────┘
- ↕
**┌─ Game Logic Layer ───────────────────────────┐**
- ┌─ World Management ─┐ ┌─ Player Management ─┐│
- Chunk Loading    │ │ - Inventory         ││
- Block States     │ │ - Position Tracking ││
- World Generation │ │ - Player States     ││
- ┘ └───────────────────────┘│
- ┌─ Command System ───┐ ┌─ Game Rules ────────┐│
- Command Parser   │ │ - Whitelist         ││
- Command Registry │ │ - Server Properties ││
- ┘ └───────────────────────┘│
- ┬───────────────────────────┘
- ↕
**┌─ Data Layer ──────────────────────────────────┐**
- Region File Management                      │
- NBT Encoding/Decoding                       │
- JSON Processing                             │
- Configuration Storage                       │
- ┘

##### Key Relationships to Highlight

- How the socket library interfaces with the main server
- Packet processing pipeline
- Demonstrate the relationship between world management and storage
- Command flow from input to execution
- How configuration affects various components

##### Important Implementation Details

- Packet processing system (src/packets/)
- Block and item handling (src/blocks/ and src/items/)
- Callback system (src/callbacks.cob)
- Data format handlers (NBT, JSON)

##### External Interfaces

- Minecraft client connection points
- Configuration file interactions
- World data storage points

##### Specific Notes

- Multiplayer support (up to 10 players)
- Whitelist system
- Creative mode inventory system
- World persistence mechanisms

For this specific project, focus on showing how the COBOL components interact with the C++ utilities and external libraries, as this is a crucial architectural consideration for a COBOL-based game server.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Interface Layer"]
        Socket["Socket Management"]:::network
        Protocol["Protocol Handler"]:::network
        Socket --> Protocol
    end

    subgraph GameLogic["Game Logic Layer"]
        direction TB
        subgraph WorldSystem["World Management"]
            World["World Manager"]:::game
            Blocks["Block System"]:::game
            WorldGen["World Generation"]:::game
            World --> Blocks
            World --> WorldGen
        end

        subgraph PlayerSystem["Player Management"]
            Players["Player Manager"]:::game
            Inventory["Inventory System"]:::game
            Position["Position Tracking"]:::game
            Players --> Inventory
            Players --> Position
        end

        subgraph CommandSystem["Command System"]
            Commands["Command Parser"]:::game
            CmdReg["Command Registry"]:::game
            Commands --> CmdReg
        end

        subgraph Rules["Game Rules"]
            ServerProps["Server Properties"]:::game
            Whitelist["Whitelist System"]:::game
        end
    end

    subgraph DataLayer["Data Layer"]
        RegionFiles["Region File Management"]:::data
        NBT["NBT Processing"]:::data
        JSON["JSON Processing"]:::data
        Config["Configuration Storage"]:::data
    end

    subgraph External["External Dependencies"]
        CBLSocket["CBL_GC_SOCKET"]:::external
        CPPUtils["C++ Utilities"]:::external
        MCProtocol["Minecraft Protocol Data"]:::external
    end

    %% Connections between layers
    Socket --> CBLSocket
    Protocol --> MCProtocol
    World --> RegionFiles
    Players --> NBT
    ServerProps --> JSON
    CPPUtils --> NBT
    CPPUtils --> JSON

    %% Style definitions
    classDef network fill:#a8d1ff,stroke:#333,stroke-width:1px
    classDef game fill:#90EE90,stroke:#333,stroke-width:1px
    classDef data fill:#FFE5B4,stroke:#333,stroke-width:1px
    classDef external fill:#DDA0DD,stroke:#333,stroke-width:1px

    %% Click events
    click Socket "https://github.com/justanotherdot/cobolcraft/blob/main/src/socket.cob"
    click Protocol "https://github.com/justanotherdot/cobolcraft/tree/main/src/packets/"
    click World "https://github.com/justanotherdot/cobolcraft/blob/main/src/world.cob"
    click Blocks "https://github.com/justanotherdot/cobolcraft/tree/main/src/blocks/"
    click Players "https://github.com/justanotherdot/cobolcraft/blob/main/src/players.cob"
    click Commands "https://github.com/justanotherdot/cobolcraft/blob/main/src/commands.cob"
    click CmdReg "https://github.com/justanotherdot/cobolcraft/tree/main/src/commands/"
    click ServerProps "https://github.com/justanotherdot/cobolcraft/blob/main/src/server-properties.cob"
    click Whitelist "https://github.com/justanotherdot/cobolcraft/blob/main/src/whitelist.cob"
    click RegionFiles "https://github.com/justanotherdot/cobolcraft/blob/main/src/region.cob"
    click NBT "https://github.com/justanotherdot/cobolcraft/blob/main/src/nbt-encode.cob"
    click JSON "https://github.com/justanotherdot/cobolcraft/blob/main/src/json-encode.cob"
    click CBLSocket "https://github.com/justanotherdot/cobolcraft/tree/main/CBL_GC_SOCKET/"
    click CPPUtils "https://github.com/justanotherdot/cobolcraft/blob/main/cpp/cobolcraft_util.cpp"
```
