# zairus-jay-c-opinion/escape-the-brainrot architecture

> Architecture diagram of the GitHub repository zairus-jay-c-opinion/escape-the-brainrot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zairus-jay-c-opinion/escape-the-brainrot
- Repository: https://github.com/zairus-jay-c-opinion/escape-the-brainrot

## Overview

Escape the Brainrot is a Java Swing game whose runtime moves from a title screen into an overworld, then into timed coding-challenge boss battles. Battle answers change boss health and the Brainrot Gauge; overworld movement and map tiles provide the exploration layer. Supporting systems include inventory, usable tools, player stats, and saving. The README gives little feature detail, so this map relies mainly on source excerpts and the SOURCE INDEX; unsampled subsystem links are omitted where call ownership is unclear.

Main entry points: [`src/engine/OverworldState.java`](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/OverworldState.java) (Overworld State), [`src/battle/BattleState.java`](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/BattleState.java) (Battle State), [`src/engine/GamePanel.java`](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/GamePanel.java) (Game Loop Panel), [`src/systems/BrainrotGauge.java`](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/BrainrotGauge.java) (Brainrot Gauge)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game Runtime"]
  node_main["Application Entry<br/>[Main.java]"]
  node_panel["Game Loop Panel<br/>[GamePanel.java]"]
  node_input["Input Handler<br/>[InputHandler.java]"]
  node_states["State Manager<br/>[StateManager.java]"]
  node_game_state["Game State Base<br/>[GameState.java]"]
  node_title["Title Screen<br/>[TitleState.java]"]
  node_assets["Asset Manager<br/>[AssetManager.java]"]
  node_config["Game Config<br/>[Config.java]"]
  node_ui["Game UI"]
end

subgraph group_world["World Exploration"]
  node_overworld["Overworld State"]
  node_entity["Entity Base<br/>[Entity.java]"]
  node_player_entity["Player Entity<br/>[Player.java]"]
  node_tilemap["Tile Map<br/>[TileMap.java]"]
end

subgraph group_battle["Boss Challenges"]
  node_battle_state["Battle State<br/>[BattleState.java]"]
  node_challenge_loader["Challenge Loader"]
  node_challenge["Challenge Types<br/>[Challenge.java]"]
  node_boss["Boss Model<br/>[Boss.java]"]
  node_battle_timer["Battle Timer<br/>[BattleTimer.java]"]
  node_difficulty["Difficulty Rules<br/>[Difficulty.java]"]
end

subgraph group_systems["Player Systems"]
  node_gauge["Brainrot Gauge<br/>[BrainrotGauge.java]"]
  node_inventory["Backpack<br/>[Backpack.java]"]
  node_item["Items and Tools<br/>[Item.java]"]
  node_assistant["AI Assistant<br/>[AiAssistant.java]"]
  node_answer_key["Answer Key<br/>[AnswerKey.java]"]
  node_clue["Clue Scroll<br/>[ClueScroll.java]"]
  node_player_stats["Player Stats<br/>[PlayerStats.java]"]
  node_save["Save Manager<br/>[SaveManager.java]"]
end

node_player(("Player"))

node_main -->|"creates"| node_panel
node_panel -->|"registers"| node_input
node_panel -->|"updates and draws"| node_states
node_panel -->|"starts in"| node_title
node_states -->|"updates and draws"| node_game_state
node_title -->|"switches to"| node_overworld
node_overworld -->|"uses"| node_player_entity
node_player_entity -->|"extends"| node_entity
node_player_entity -->|"checks movement"| node_tilemap
node_overworld -->|"loads and draws"| node_tilemap
node_tilemap -->|"opens map"| node_assets
node_overworld -->|"starts battle"| node_battle_state
node_battle_state -->|"loads challenges"| node_challenge_loader
node_challenge_loader -->|"opens challenge data"| node_assets
node_challenge_loader -->|"builds challenge types"| node_challenge
node_challenge -->|"uses difficulty"| node_difficulty
node_battle_state -->|"damages and checks"| node_boss
node_battle_state -->|"adjusts strain"| node_gauge
node_battle_state -->|"ticks and resets"| node_battle_timer
node_gauge -->|"loads settings"| node_config
node_overworld -->|"reads controls"| node_input
node_title -->|"reads controls"| node_input
node_inventory -->|"stores items"| node_item
node_assistant -->|"uses tool contract"| node_item
node_assistant -->|"affects gauge"| node_gauge
node_answer_key -->|"uses item"| node_item
node_answer_key -->|"affects gauge"| node_gauge
node_save -->|"saves gauge"| node_gauge
node_save -->|"saves stats"| node_player_stats
node_player -.->|"plays"| node_panel

click node_main "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/Main.java"
click node_panel "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/GamePanel.java"
click node_input "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/InputHandler.java"
click node_states "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/StateManager.java"
click node_game_state "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/GameState.java"
click node_title "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/TitleState.java"
click node_overworld "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/OverworldState.java"
click node_entity "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/entity/Entity.java"
click node_player_entity "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/entity/Player.java"
click node_tilemap "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/world/TileMap.java"
click node_assets "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/AssetManager.java"
click node_config "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/Config.java"
click node_battle_state "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/BattleState.java"
click node_challenge_loader "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/challenge/ChallengeLoader.java"
click node_challenge "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/challenge/Challenge.java"
click node_boss "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/Boss.java"
click node_battle_timer "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/BattleTimer.java"
click node_difficulty "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/Difficulty.java"
click node_gauge "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/BrainrotGauge.java"
click node_inventory "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/Backpack.java"
click node_item "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/Item.java"
click node_assistant "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/AiAssistant.java"
click node_answer_key "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/AnswerKey.java"
click node_clue "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/ClueScroll.java"
click node_player_stats "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/PlayerStats.java"
click node_save "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/SaveManager.java"
click node_ui "https://github.com/zairus-jay-c-opinion/escape-the-brainrot/tree/main/src/ui"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_panel,node_input,node_states,node_game_state,node_title,node_assets,node_config,node_ui toneBlue
class node_overworld,node_entity,node_player_entity,node_tilemap toneAmber
class node_battle_state,node_challenge_loader,node_challenge,node_boss,node_battle_timer,node_difficulty toneMint
class node_gauge,node_inventory,node_item,node_assistant,node_answer_key,node_clue,node_player_stats,node_save toneRose
class node_player toneIndigo
```

## Components

### Game Runtime

- [Application Entry](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/Main.java): `src/Main.java`
- [Game Loop Panel](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/GamePanel.java): `src/engine/GamePanel.java`
- [Input Handler](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/InputHandler.java): `src/engine/InputHandler.java`
- [State Manager](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/StateManager.java): `src/engine/StateManager.java`
- [Game State Base](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/GameState.java): `src/engine/GameState.java`
- [Title Screen](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/TitleState.java): `src/engine/TitleState.java`
- [Asset Manager](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/AssetManager.java): `src/engine/AssetManager.java`
- [Game Config](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/Config.java): `src/engine/Config.java`
- [Game UI](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/tree/main/src/ui): `src/ui`

### World Exploration

- [Overworld State](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/engine/OverworldState.java): `src/engine/OverworldState.java`
- [Entity Base](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/entity/Entity.java): `src/entity/Entity.java`
- [Player Entity](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/entity/Player.java): `src/entity/Player.java`
- [Tile Map](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/world/TileMap.java): `src/world/TileMap.java`

### Boss Challenges

- [Battle State](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/BattleState.java): `src/battle/BattleState.java`
- [Challenge Loader](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/challenge/ChallengeLoader.java): `src/challenge/ChallengeLoader.java`
- [Challenge Types](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/challenge/Challenge.java): `src/challenge/Challenge.java`
- [Boss Model](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/Boss.java): `src/battle/Boss.java`
- [Battle Timer](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/BattleTimer.java): `src/battle/BattleTimer.java`
- [Difficulty Rules](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/battle/Difficulty.java): `src/battle/Difficulty.java`

### Player Systems

- [Brainrot Gauge](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/BrainrotGauge.java): `src/systems/BrainrotGauge.java`
- [Backpack](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/Backpack.java): `src/systems/Backpack.java`
- [Items and Tools](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/Item.java): `src/systems/Item.java`
- [AI Assistant](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/AiAssistant.java): `src/systems/AiAssistant.java`
- [Answer Key](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/AnswerKey.java): `src/systems/AnswerKey.java`
- [Clue Scroll](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/ClueScroll.java): `src/systems/ClueScroll.java`
- [Player Stats](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/PlayerStats.java): `src/systems/PlayerStats.java`
- [Save Manager](https://github.com/zairus-jay-c-opinion/escape-the-brainrot/blob/main/src/systems/SaveManager.java): `src/systems/SaveManager.java`

### Other components

- **Player**

## Connections

- Application Entry → Game Loop Panel: creates (evidence: `src/Main.java`)
- Game Loop Panel → Input Handler: registers (evidence: `src/engine/GamePanel.java`)
- Game Loop Panel → State Manager: updates and draws (evidence: `src/engine/GamePanel.java`)
- Game Loop Panel → Title Screen: starts in (evidence: `src/engine/GamePanel.java`)
- State Manager → Game State Base: updates and draws (evidence: `src/engine/StateManager.java`)
- Title Screen → Overworld State: switches to (evidence: `src/engine/TitleState.java`)
- Overworld State → Player Entity: uses (evidence: `src/engine/OverworldState.java`)
- Player Entity → Entity Base: extends (evidence: `src/entity/Player.java`)
- Player Entity → Tile Map: checks movement (evidence: `src/entity/Player.java`)
- Overworld State → Tile Map: loads and draws (evidence: `src/engine/OverworldState.java`)
- Tile Map → Asset Manager: opens map (evidence: `src/world/TileMap.java`)
- Overworld State → Battle State: starts battle (evidence: `src/engine/OverworldState.java`)
- Battle State → Challenge Loader: loads challenges (evidence: `src/battle/BattleState.java`)
- Challenge Loader → Asset Manager: opens challenge data (evidence: `src/challenge/ChallengeLoader.java`)
- Challenge Loader → Challenge Types: builds challenge types (evidence: `src/challenge/ChallengeLoader.java`)
- Challenge Types → Difficulty Rules: uses difficulty (evidence: `src/challenge/Challenge.java`)
- Battle State → Boss Model: damages and checks (evidence: `src/battle/BattleState.java`)
- Battle State → Brainrot Gauge: adjusts strain (evidence: `src/battle/BattleState.java`)
- Battle State → Battle Timer: ticks and resets (evidence: `src/battle/BattleState.java`)
- Brainrot Gauge → Game Config: loads settings (evidence: `src/systems/BrainrotGauge.java`)
- Overworld State → Input Handler: reads controls (evidence: `src/engine/OverworldState.java`)
- Title Screen → Input Handler: reads controls (evidence: `src/engine/TitleState.java`)
- Backpack → Items and Tools: stores items (evidence: `src/systems/Backpack.java`)
- AI Assistant → Items and Tools: uses tool contract (evidence: `src/systems/AiAssistant.java`)
- AI Assistant → Brainrot Gauge: affects gauge (evidence: `src/systems/AiAssistant.java`)
- Answer Key → Items and Tools: uses item (evidence: `src/systems/AnswerKey.java`)
- Answer Key → Brainrot Gauge: affects gauge (evidence: `src/systems/AnswerKey.java`)
- Save Manager → Brainrot Gauge: saves gauge (evidence: `src/systems/SaveManager.java`)
- Save Manager → Player Stats: saves stats (evidence: `src/systems/SaveManager.java`)
- Player → Game Loop Panel: plays
