# hax0r31337/protohax architecture

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

- Interactive diagram: https://gitdiagram.com/hax0r31337/protohax
- Repository: https://github.com/hax0r31337/protohax

## Overview

##### Project Type & Purpose
- This is an open-source Java project built with Gradle. Its purpose is to provide an abstract, platform-agnostic cheat framework for Minecraft: Bedrock Edition. The cheat works by intercepting and controlling the network layer (packet manipulation) without modifying the Minecraft client.
- The README emphasizes its features (no client modifications, multi-version support, full packet control) and explains that platform-specific implementations (like Android) exist elsewhere.

##### Analyzing the File Structure
- The top-level layout shows standard Gradle configuration files (build.gradle, gradlew, settings.gradle) that indicate a Java-based project.
- The src/main/java directory contains packages under “dev.sora.relay” where most of the core functionality lives.
- There are distinct packages for:
- Relay and network components (e.g., MinecraftRelay.kt, MinecraftRelayListener.kt) handling the main entry point from the network layer.
- Cheat-specific modules and commands (under cheat/command, cheat/module, cheat/config). These classes (for example, CommandManager.kt, ModuleManager.kt) indicate the existence of a command system and a modular cheat framework that registers and toggles cheat behaviors.
- Game simulation and abstraction (packages like game/entity, game/inventory, game/world) which likely simulate Minecraft’s internal entities and world state.
- Session and protocol handling (packages under session and the org.cloudburstmc libraries) that manage network sessions, packet listening, and specialized protocols (such as handling Xbox logins).
- Utility classes (e.g., in dev.sora.relay/utils) for HTTP, JWT, JSON handling, logging and timing.
- The tests are organized under src/test which confirms that unit testing and sample usage are important for this project.

##### Main Components
a. Network Communication Layer:
- Components: MinecraftRelay, MinecraftRelayListener, various RelayListener classes (e.g., RelayListenerEncryptedSession, RelayListenerXboxLogin).
- Role: Handles establishing and managing the network session, processing incoming/outgoing packets, and interfacing with protocol decoders (integrated via CloudburstMC protocol packages).
b. Cheat Framework (Modules and Commands):
- Components: Cheat Module package (ModuleManager, CheatModule and implementations like ModuleKillAura, ModuleFly, etc.), Command package (CommandManager, specific Command implementations).
- Role: This layer contains cheat modules that modify game behavior, command interfaces to trigger actions, and configuration management (AbstractConfigManager, ConfigManagerFileSystem, and related config sections).
c. Game Abstraction Layer:
- Components: Game session, entity representations (EntityPlayer, EntityItem, etc.), event handling (EventManager, EventHandler), inventory and world/chunk management.
- Role: Replicates aspects of the Minecraft game environment for cheat operations such as entity management, world simulation, and game events.
d. Protocol & External Library Integration:
- Components: Protocol handling via org.cloudburstmc packages (bedrock codec, Zlib for compression).
- Role: Decode and interpret Minecraft: Bedrock protocol data ensuring version flexibility and correct packet interpretation.
e. Utility & Configuration:
- Components: Various utility classes (HTTPUtils, JWTUtils, Logger, timing classes) and configuration files.
- Role: Provide common support functions (logging, configuration persistence, timing) to all layers.
f. Build and Development Infrastructure:
- Components: Gradle scripts, README, and test modules.
- Role: Infrastructure for building, testing, and development cycles.

##### Relationships and Interactions
- The Cheat Framework receives commands and events from the network layer and, via the ModuleManager and CommandManager, manipulates game simulation represented in the Game Abstraction Layer.
- Interactions with configuration and utility modules happen as supporting flows (e.g., a cheat module checking configuration values or logging events).
- Protocol handling components connect to the network layer, interpreting raw data and producing meaningful entities for higher layers.
- The session management (including listeners for special cases like Xbox login) connects the external communication with the internal processing.

##### Emphasizing Architectural Patterns
- The modular structure (separation into commands, cheat modules, configuration) suggests a dynamic plug-in style architecture where new cheat modules can be dynamically managed.
- The clear session and event management imply an event-driven design.
- The layered approach where raw network data is processed before being used to simulate and manipulate game state shows separation of concerns and layered abstraction.

## Diagram (Mermaid)

```mermaid
flowchart TD

  subgraph "Network Communication"
    NC1["MinecraftRelay"]:::network
    NC2["MinecraftRelayListener"]:::network
    NC3["RelayListenerEncryptedSession"]:::network
    NC4["XboxLoginListener"]:::network
  end

  subgraph "Cheat Framework (Modules & Commands)"
    CF1["Command Management"]:::cheat
    CF2["Module Management"]:::cheat
    CF3["Configuration Management"]:::cheat
  end

  subgraph "Game Abstraction"
    GA1["Game Session Handling"]:::game
    GA2["Entity Representations"]:::game
    GA3["Inventory Management"]:::game
    GA4["World Management"]:::game
  end

  subgraph "Protocol Handling"
    PH["Protocol Handling (CloudburstMC)"]:::protocol
  end

  subgraph "Utilities/Configuration"
    UT["Utility Functions"]:::utils
  end

  subgraph "Build/Testing Infrastructure"
    BT1["Build Scripts & Configurations"]:::build
    BT2["Documentation & Testing"]:::build
  end

  NC1 -->|"packets"| CF1
  NC1 -->|"packets"| CF2
  NC2 -->|"packets"| GA1
  NC3 -->|"packets"| GA1
  NC4 -->|"packets"| GA1
  CF1 -->|"commands/events"| GA1
  CF2 -->|"commands/events"| GA1
  PH -->|"decode"| NC1
  UT -->|"support"| NC1
  UT -->|"support"| CF1
  UT -->|"support"| GA1
  UT -->|"support"| PH

  classDef network fill:#ffcccc,stroke:#990000,stroke-width:2px;
  classDef cheat fill:#ccffcc,stroke:#006600,stroke-width:2px;
  classDef game fill:#ccccff,stroke:#000099,stroke-width:2px;
  classDef protocol fill:#ffffcc,stroke:#999900,stroke-width:2px;
  classDef utils fill:#e6e6e6,stroke:#666666,stroke-width:2px;
  classDef build fill:#ffe6cc,stroke:#cc6600,stroke-width:2px;

  click NC1 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/MinecraftRelay.kt"
  click NC2 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/MinecraftRelayListener.kt"
  click NC3 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/session/listener/RelayListenerEncryptedSession.kt"
  click NC4 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/session/listener/xbox/RelayListenerXboxLogin.kt"

  click CF1 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/cheat/command/CommandManager.kt"
  click CF2 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/cheat/module/ModuleManager.kt"
  click CF3 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/cheat/config/AbstractConfigManager.kt"

  click GA1 "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/dev/sora/relay/game/GameSession.kt"
  click GA2 "https://github.com/hax0r31337/protohax/tree/stable/src/main/java/dev/sora/relay/game/entity"
  click GA3 "https://github.com/hax0r31337/protohax/tree/stable/src/main/java/dev/sora/relay/game/inventory"
  click GA4 "https://github.com/hax0r31337/protohax/tree/stable/src/main/java/dev/sora/relay/game/world"

  click PH "https://github.com/hax0r31337/protohax/blob/stable/src/main/java/org/cloudburstmc/protocol/bedrock/codec/BedrockCodec.java"

  click UT "https://github.com/hax0r31337/protohax/tree/stable/src/main/java/dev/sora/relay/utils"

  click BT1 "https://github.com/hax0r31337/protohax/blob/stable/build.gradle"
  click BT2 "https://github.com/hax0r31337/protohax/blob/stable/README.md"
```
