# lluna4/jelly architecture

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

- Interactive diagram: https://gitdiagram.com/lluna4/jelly
- Repository: https://github.com/lluna4/jelly

## Overview

##### Project Type and Its Purpose
- The project is a Minecraft server implementation for Linux and macOS written in C++ (using C++23 with some C++26 features).
- Its goal is to provide a simple yet inclusive server experience, featuring unique commands (e.g., the /pronouns and /overwhelmed commands) and threaded world generation with Perlin noise-based terrain and trees.
- It integrates external dependencies such as nlohmann/json for JSON parsing, a custom packets library for Minecraft data, and OpenSSL, which are vital for its networking and data processing.

##### File Structure for Architectural Insights
- Top-level Files & Directories:
- .github: Contains GitHub Actions workflows (e.g., pre-release setup) which hint at an automated CI/CD pipeline.
- CMakeLists.txt: Indicates CMake is used to generate builds, tying components together.
- README.md: Offers a high-level description, build instructions, and dependency information.
- generated: Likely holds autogenerated reports (e.g., blocks.json, registries.json) that may serve as configuration or reference data for the server.
- The src Directory:
- main entry point (src/main.cpp) which boots the server.
- libs subdirectory: Contains a set of utility headers and source files that power many core aspects:
- PerlinNoise.hpp (essential for noise-based world-generation)
- chunks.hpp, comp_time_read/write.hpp, config.hpp, light_engine.hpp, localization.hpp, logging.hpp, netlib.h/ netlib.cpp, packet_processing.hpp, tokenize.hpp, and utils.hpp.
- This collection indicates a modular design that encapsulates functionality related to world generation, network communication, logging, configuration management, and likely more.
- tests subdirectory: Contains test files for various components ensuring functionality and stability.

- Main Components:
- Server Core: Illustrate the central component where src/main.cpp resides which initializes and orchestrates the server operations.
- World Generation Module: Represented by components like PerlinNoise, chunks, and light_engine. This part could be detailed to show threaded world generation, spline evaluation for noise mapping, and block height determination.
- Network & Packet Processing: Include modules like netlib and packet_processing which suggest inbound/outbound data handling and communication with Minecraft clients.
- Utility & Configuration Layer: Identify utility libraries (tokenize, localization, logging, config) that support overall system behavior.
- Build & CI/CD Pipeline: Optionally, include a component for the build system (CMake) and GitHub workflow (from the .github directory) to indicate automated testing/deployment processes.

- Relationships and Interactions:
- That the Server Core orchestrates calls into utility modules for configuration, logging, and localization.
- That the External Dependencies provide key functionalities, such as JSON parsing and secure communications.

##### Architectural Patterns & Design Principles
- Modular Design: Each functionality (networking, world generation, utilities) resides in its dedicated module/library. Highlight how this separation improves maintainability.
- Threaded Execution: Emphasize the threaded world generation, noting that it operates concurrently to ensure performance during terrain generation.
- Dependency Injection or Loose Coupling: While the file structure doesn’t directly show a full-blown dependency injection setup, it is advisable to note that components likely interact through well-defined interfaces (e.g., defined in headers).
- Build Automation: The use of CMake and GitHub workflows demonstrates automated builds and testing, ensuring consistency throughout development.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Build & CI/CD Pipeline"
        BS("Build System"):::build
        CI("CI/CD Workflows"):::build
    end

    subgraph "Server Core"
        SC("Server Core"):::core
    end

    subgraph "World Generation Module"
        PN("Perlin Noise"):::worldGen
        CM("Chunk Management"):::worldGen
        LE("Light Engine"):::worldGen
    end

    subgraph "Network & Packet Processing"
        NL("Network Library"):::network
        PP("Packet Processing"):::network
    end

    subgraph "Utility & Configuration Layer"
        CFG("Configuration"):::utility
        LG("Logging"):::utility
        LOC("Localization"):::utility
        TOK("Tokenization"):::utility
        UT("General Utilities"):::utility
    end

    subgraph "External Dependencies"
        JSON("JSON Parsing"):::external
        PL("Packet Library"):::external
        SSL("SSL/Encryption"):::external
    end

    subgraph "Testing Suite"
        TEST("Testing Suite"):::test
    end

    %% Relationships
    BS --> SC
    CI --> SC

    SC --> PN
    SC --> CM
    SC --> LE

    SC --> NL
    SC --> PP

    SC --> CFG
    SC --> LG
    SC --> LOC
    SC --> TOK
    SC --> UT

    NL --> SSL
    PP --> PL
    CFG --> JSON

    TEST --> SC

    %% Styles
    classDef core fill:#f9c74f,stroke:#000,stroke-width:2px;
    classDef worldGen fill:#90be6d,stroke:#000,stroke-width:2px;
    classDef network fill:#f9844a,stroke:#000,stroke-width:2px;
    classDef utility fill:#43aa8b,stroke:#000,stroke-width:2px;
    classDef external fill:#577590,stroke:#000,stroke-width:2px;
    classDef build fill:#277da1,stroke:#000,stroke-width:2px;
    classDef test fill:#f94144,stroke:#000,stroke-width:2px;

    %% Click Events
    click SC "https://github.com/lluna4/jelly/blob/main/src/main.cpp"
    click PN "https://github.com/lluna4/jelly/blob/main/src/libs/PerlinNoise.hpp"
    click CM "https://github.com/lluna4/jelly/blob/main/src/libs/chunks.hpp"
    click LE "https://github.com/lluna4/jelly/blob/main/src/libs/light_engine.hpp"
    click NL "https://github.com/lluna4/jelly/blob/main/src/libs/netlib.h"
    click PP "https://github.com/lluna4/jelly/blob/main/src/libs/packet_processing.hpp"
    click CFG "https://github.com/lluna4/jelly/blob/main/src/libs/config.hpp"
    click LG "https://github.com/lluna4/jelly/blob/main/src/libs/logging.hpp"
    click LOC "https://github.com/lluna4/jelly/blob/main/src/libs/localization.hpp"
    click TOK "https://github.com/lluna4/jelly/blob/main/src/libs/tokenize.hpp"
    click UT "https://github.com/lluna4/jelly/blob/main/src/libs/utils.hpp"
    click BS "https://github.com/lluna4/jelly/blob/main/CMakeLists.txt"
    click CI "https://github.com/lluna4/jelly/blob/main/.github/workflows/pre-release.yml"
    click TEST "https://github.com/lluna4/jelly/tree/main/src/tests"
```
