# naidru/hl2rpbeta architecture

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

- Interactive diagram: https://gitdiagram.com/naidru/hl2rpbeta
- Repository: https://github.com/naidru/hl2rpbeta

## Overview

##### Project Type and Purpose
- This is a Garry’s Mod “Helix” schema and plugin collection called HL2RPBETA. It customizes the Helix framework (an RPG gamemode for GMod) to implement a Half-Life 2 Beta–style role-playing experience.
- Key indicators:
- A top-level `schema/` folder containing Helix schema definition files (classes, factions, items, attributes, hooks).
- A `plugins/` folder with dozens of self-contained feature modules (each with `cl_*.lua`, `sv_*.lua`, optionally `sh_*.lua` and UI files under a `derma/` subfolder).
- A `gamemode/` folder with the core init scripts.
- Entities defined under `entities/`.

##### File-Structure Analysis
- Top-level:
- `.github/`, `.gitignore`, `README.md`, license, etc.
- `entities/`: custom scripted entities (forcefields, vending machines, etc.).
- `gamemode/`: base Helix glue code (initialization, client vs. server entry points).
- `schema/`: the HL2RP-specific schema (attributes, classes, factions, item definitions, meta definitions, hooks and commands).
- `plugins/`: modular feature packs. Each plugin follows the same pattern:
– `cl_*.lua` for client-only logic (UI hooks, visuals).
– `sv_*.lua` for server-only logic (data enforcement, persistence).
– `sh_*.lua` for shared logic (commands, configuration).
– `derma/`: VGUI definitions when needed.
– `entities/` or `items/` subfolders if the plugin adds its own entity or item definitions.
– `languages/` for localization strings.
- Architectural choice: plugin-based modularity layered on top of a core schema, with clear separation of client, server and shared logic.

##### README Insights
- This schema is “based off” an external Half-Life 2 Beta content pack (steam workshop dependency).
- It’s released under AGPLv3, maintained in GitLab, and intended to be used in a Helix–powered RP server.

a. Main Components
- GMod Engine (Source SDK)
- Helix Core Framework (implicit dependency)
- HL2RP Schema (`schema/` folder)
- Core Gamemode Loader (`gamemode/` folder)
- Entity Definitions (`entities/`)
- Plugin Modules (`plugins/`)
- External Content Pack (Steam workshop addon)
- Clients (players’ game clients) vs. Server (game server)

b. Component Relationships
1. GMod Engine loads the Helix Core.
2. Helix Core invokes `gamemode/init.lua` to bootstrap the HL2RP schema.
3. The Schema registers attributes, classes, factions, item definitions, and server hooks.
4. Each plugin is loaded (server and client), registers its own hooks, net messages, and UI panels.
5. Entity definitions under `entities/` are registered with the GMod engine for use in-game.
6. Client modules (`cl_*.lua` and `derma/`) communicate via net messages to receive or send data to `sv_*.lua`.
7. The external Content Pack provides models and materials for items and entities.

c. Architectural Patterns and Principles
- Modular Plugin Architecture: Each feature resides in its own sandboxed folder, loaded dynamically.
- MVC-style separation:
– Model = schema (data definitions) + server hooks (persistence, rule enforcement)
– View = client-side code (UI, derma panels)
– Controller = shared code handling commands and business logic
- Event-Driven Hooks: Helix provides hook points for character creation, item usage, faction checks, UI events.

d. Key Technologies and Frameworks
- Lua (scripting language)
- Helix Framework (Helix Core)
- Garry’s Mod Engine (Source SDK)
- SQLite or MySQL (via Helix) for persistence (implicit)
- VGUI/Derma (for client-side UIs)
- Net Message API (for client–server communication)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core and Engine
    GMod["GMod Engine (Source SDK)"]:::external
    Helix_Core["Helix Core Framework"]:::core
    PluginLoader["Plugin Loader\n(gamemode/init.lua)"]:::core
    Schema["HL2RP Schema\n(Data Definitions & Hooks)"]:::schema
    Entities["Entity Definitions"]:::entity
    Sql["Database (SQLite/MySQL)"]:::db
    ExtContent["External Content Pack\n(models & materials)"]:::external

    %% Client and Server boundaries
    subgraph "Client"
        direction TB
        Helix_Client["Helix Core (Client)"]:::core
        CL_Derma["Derma Panels & UI"]:::client
    end

    subgraph "Server"
        direction TB
        Helix_Server["Helix Core (Server)"]:::core
        ServerHooks["Server Hooks & Persistence"]:::server
    end

    %% Plugins grouping
    subgraph "Plugins (Modular Features)"
        direction TB
        subgraph "Anti-AFK Plugin" 
            direction TB
            AF_Sh["sh_plugin.lua"]:::plugin
            AF_Cl["cl_hooks.lua"]:::client
            AF_Sv["sv_hooks.lua"]:::server
            AF_Lang["languages/sh_english.lua"]:::plugin
        end
        subgraph "ATM Plugin"
            direction TB
            ATM_Sh["sh_plugin.lua"]:::plugin
            ATM_Sv["sv_hooks.lua"]:::server
            ATM_Ent["ix_atm Entity"]:::entity
        end
    end

    %% Meta Extensions
    MetaSchema["Meta Extensions"]:::schema
    subgraph "Schema Meta"
        direction TB
        Schema_Char["sh_character.lua"]:::schema
        Schema_Player["sh_player.lua"]:::schema
    end
    subgraph "CHUD Meta"
        direction TB
        CHUD_Char["sh_char.lua"]:::schema
        CHUD_Player["sh_player.lua"]:::schema
    end

    %% Connections
    GMod --> Helix_Core
    Helix_Core --> Helix_Client
    Helix_Core --> Helix_Server
    Helix_Server --> PluginLoader
    PluginLoader --> Schema
    PluginLoader --> Plugins
    Schema --> Entities
    Schema --> MetaSchema
    MetaSchema --> Schema_Char
    MetaSchema --> Schema_Player
    Plugins --> AF_Sh
    AF_Sh --> AF_Cl
    AF_Sh --> AF_Sv
    AF_Sh --> AF_Lang
    Plugins --> ATM_Sh
    ATM_Sh --> ATM_Sv
    ATM_Sv --> ATM_Ent

    CL_Derma -->|net messages| Helix_Server
    AF_Cl -->|net messages| AF_Sv
    ATM_Sv -->|entity registration| Entities

    Helix_Server --> Sql
    ExtContent --> Entities
    ExtContent --> CL_Derma

    %% Click Events
    click Schema "https://github.com/naidru/hl2rpbeta/tree/main/schema/"
    click PluginLoader "https://github.com/naidru/hl2rpbeta/blob/main/gamemode/init.lua"
    click Helix_Core "https://github.com/naidru/hl2rpbeta/blob/main/gamemode/cl_init.lua"
    click Entities "https://github.com/naidru/hl2rpbeta/tree/main/entities/entities/"
    click AF_Cl "https://github.com/naidru/hl2rpbeta/blob/main/plugins/antiafk/cl_hooks.lua"
    click AF_Sh "https://github.com/naidru/hl2rpbeta/blob/main/plugins/antiafk/sh_plugin.lua"
    click AF_Sv "https://github.com/naidru/hl2rpbeta/blob/main/plugins/antiafk/sv_hooks.lua"
    click AF_Lang "https://github.com/naidru/hl2rpbeta/blob/main/plugins/antiafk/languages/sh_english.lua"
    click ATM_Sh "https://github.com/naidru/hl2rpbeta/blob/main/plugins/atm/sh_plugin.lua"
    click ATM_Sv "https://github.com/naidru/hl2rpbeta/blob/main/plugins/atm/sv_hooks.lua"
    click ATM_Ent "https://github.com/naidru/hl2rpbeta/blob/main/plugins/atm/entities/entities/ix_atm.lua"
    click Schema_Char "https://github.com/naidru/hl2rpbeta/blob/main/schema/meta/sh_character.lua"
    click Schema_Player "https://github.com/naidru/hl2rpbeta/blob/main/schema/meta/sh_player.lua"
    click CHUD_Char "https://github.com/naidru/hl2rpbeta/blob/main/plugins/chud/meta/sh_char.lua"
    click CHUD_Player "https://github.com/naidru/hl2rpbeta/blob/main/plugins/chud/meta/sh_player.lua"

    %% Styles
    classDef external fill:#d0d0d0,stroke:#888;
    classDef core fill:#ffd700,stroke:#b8860b;
    classDef schema fill:#87cefa,stroke:#4682b4;
    classDef plugin fill:#98fb98,stroke:#2e8b57;
    classDef client fill:#ffb6c1,stroke:#c71585;
    classDef server fill:#add8e6,stroke:#00008b;
    classDef entity fill:#ffe4b5,stroke:#cd853f;
    classDef db fill:#dda0dd,stroke:#800080;
```
