# alegemaate/forager architecture

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

- Interactive diagram: https://gitdiagram.com/alegemaate/forager
- Repository: https://github.com/alegemaate/forager

## Overview

Forager is a 3D voxel-terrain game. Its runtime starts the Game scene, where the user plays by moving through and viewing a generated world; the README also documents world regeneration. The source tree separates world data and registries from chunk meshing, rendering, input, and GUI. The graph preserves those product areas, but several internals are unsampled, so their relationships are omitted rather than inferred. Edges cite the main entry point, sampled files, or README where the relationship is visible.

Main entry points: [`src/state/game.cpp`](https://github.com/alegemaate/forager/blob/main/src/state/game.cpp) (Game scene), [`src/world/chunk/chunk_map.cpp`](https://github.com/alegemaate/forager/blob/main/src/world/chunk/chunk_map.cpp) (Chunk map), [`src/game/controls.cpp`](https://github.com/alegemaate/forager/blob/main/src/game/controls.cpp) (Input bindings), [`src/game/Player.cpp`](https://github.com/alegemaate/forager/blob/main/src/game/Player.cpp) (Player movement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_main["Application entry<br/>[main.cpp]"]
  node_game["Game scene<br/>[game.cpp]"]
  node_player["Player movement<br/>[Player.cpp]"]
  node_camera["Camera<br/>[Camera.h]"]
end

subgraph group_world["Voxel world"]
  node_world["World simulation<br/>[world.cpp]"]
  node_chunks["Chunk map<br/>[chunk_map.cpp]"]
  node_chunk["Chunk data<br/>[chunk.cpp]"]
  node_biomes["Biome registry<br/>[biome_registry.cpp]"]
  node_blocks["Block registry<br/>[block_registry.cpp]"]
  node_blocktypes["Block types<br/>[block_type.h]"]
  node_noise["Terrain noise<br/>[SimplexNoise.cpp]"]
end

subgraph group_rendering["Rendering"]
  node_mesh["Chunk meshing<br/>[chunk_mesh.cpp]"]
  node_faces["Cube faces<br/>[cube_faces.cpp]"]
  node_programs["Shader programs"]
  node_skybox["Skybox<br/>[skybox.cpp]"]
  node_loaders["Asset loaders<br/>[loaders.cpp]"]
end

subgraph group_interface["Input and interface"]
  node_controls["Input bindings<br/>[controls.cpp]"]
  node_toolbar["Toolbar<br/>[toolbar.h]"]
  node_screenshot["Screenshot capture<br/>[screenshot.cpp]"]
end

node_user(("Player"))

node_user -->|"provides actions"| node_controls
node_main -->|"registers scene"| node_game
node_game -->|"uses actions"| node_controls
node_game -->|"uses interface"| node_toolbar
node_game -->|"captures screenshot"| node_screenshot
node_player -->|"updates position"| node_camera
node_player -->|"checks collisions"| node_chunks
node_player -->|"reads actions"| node_controls
node_world -->|"reads actions"| node_controls
node_chunks -->|"stores chunks"| node_chunk
node_chunks -->|"uses block registry"| node_blocks
node_chunks -->|"uses biome registry"| node_biomes
node_chunk -->|"looks up blocks"| node_blocks
node_blocks -->|"stores types"| node_blocktypes
node_mesh -->|"reads world"| node_world
node_mesh -->|"loads assets"| node_loaders
node_mesh -->|"uses face geometry"| node_faces
node_skybox -->|"uses shader programs"| node_programs

click node_main "https://github.com/alegemaate/forager/blob/main/src/main.cpp"
click node_game "https://github.com/alegemaate/forager/blob/main/src/state/game.cpp"
click node_world "https://github.com/alegemaate/forager/blob/main/src/world/world.cpp"
click node_player "https://github.com/alegemaate/forager/blob/main/src/game/Player.cpp"
click node_camera "https://github.com/alegemaate/forager/blob/main/src/core/Camera.h"
click node_chunks "https://github.com/alegemaate/forager/blob/main/src/world/chunk/chunk_map.cpp"
click node_chunk "https://github.com/alegemaate/forager/blob/main/src/world/chunk/chunk.cpp"
click node_biomes "https://github.com/alegemaate/forager/blob/main/src/world/biome/biome_registry.cpp"
click node_blocks "https://github.com/alegemaate/forager/blob/main/src/block/block_registry.cpp"
click node_blocktypes "https://github.com/alegemaate/forager/blob/main/src/block/block_type.h"
click node_noise "https://github.com/alegemaate/forager/blob/main/src/core/SimplexNoise.cpp"
click node_mesh "https://github.com/alegemaate/forager/blob/main/src/render/chunk_mesh.cpp"
click node_faces "https://github.com/alegemaate/forager/blob/main/src/render/cube_faces.cpp"
click node_programs "https://github.com/alegemaate/forager/blob/main/src/render/gpu_program_manager.h"
click node_skybox "https://github.com/alegemaate/forager/blob/main/src/render/skybox.cpp"
click node_controls "https://github.com/alegemaate/forager/blob/main/src/game/controls.cpp"
click node_toolbar "https://github.com/alegemaate/forager/blob/main/src/gui/toolbar.h"
click node_screenshot "https://github.com/alegemaate/forager/blob/main/src/utils/screenshot.cpp"
click node_loaders "https://github.com/alegemaate/forager/blob/main/src/utils/loaders.cpp"

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_game,node_player,node_camera toneBlue
class node_world,node_chunks,node_chunk,node_biomes,node_blocks,node_blocktypes,node_noise toneAmber
class node_mesh,node_faces,node_programs,node_skybox,node_loaders toneMint
class node_controls,node_toolbar,node_screenshot toneRose
class node_user toneIndigo
```

## Components

### Game runtime

- [Application entry](https://github.com/alegemaate/forager/blob/main/src/main.cpp): `src/main.cpp`
- [Game scene](https://github.com/alegemaate/forager/blob/main/src/state/game.cpp): `src/state/game.cpp`
- [Player movement](https://github.com/alegemaate/forager/blob/main/src/game/Player.cpp): `src/game/Player.cpp`
- [Camera](https://github.com/alegemaate/forager/blob/main/src/core/Camera.h): `src/core/Camera.h`

### Voxel world

- [World simulation](https://github.com/alegemaate/forager/blob/main/src/world/world.cpp): `src/world/world.cpp`
- [Chunk map](https://github.com/alegemaate/forager/blob/main/src/world/chunk/chunk_map.cpp): `src/world/chunk/chunk_map.cpp`
- [Chunk data](https://github.com/alegemaate/forager/blob/main/src/world/chunk/chunk.cpp): `src/world/chunk/chunk.cpp`
- [Biome registry](https://github.com/alegemaate/forager/blob/main/src/world/biome/biome_registry.cpp): `src/world/biome/biome_registry.cpp`
- [Block registry](https://github.com/alegemaate/forager/blob/main/src/block/block_registry.cpp): `src/block/block_registry.cpp`
- [Block types](https://github.com/alegemaate/forager/blob/main/src/block/block_type.h): `src/block/block_type.h`
- [Terrain noise](https://github.com/alegemaate/forager/blob/main/src/core/SimplexNoise.cpp): `src/core/SimplexNoise.cpp`

### Rendering

- [Chunk meshing](https://github.com/alegemaate/forager/blob/main/src/render/chunk_mesh.cpp): `src/render/chunk_mesh.cpp`
- [Cube faces](https://github.com/alegemaate/forager/blob/main/src/render/cube_faces.cpp): `src/render/cube_faces.cpp`
- [Shader programs](https://github.com/alegemaate/forager/blob/main/src/render/gpu_program_manager.h): `src/render/gpu_program_manager.h`
- [Skybox](https://github.com/alegemaate/forager/blob/main/src/render/skybox.cpp): `src/render/skybox.cpp`
- [Asset loaders](https://github.com/alegemaate/forager/blob/main/src/utils/loaders.cpp): `src/utils/loaders.cpp`

### Input and interface

- [Input bindings](https://github.com/alegemaate/forager/blob/main/src/game/controls.cpp): `src/game/controls.cpp`
- [Toolbar](https://github.com/alegemaate/forager/blob/main/src/gui/toolbar.h): `src/gui/toolbar.h`
- [Screenshot capture](https://github.com/alegemaate/forager/blob/main/src/utils/screenshot.cpp): `src/utils/screenshot.cpp`

### Other components

- **Player**

## Connections

- Player → Input bindings: provides actions (evidence: `README.md`)
- Application entry → Game scene: registers scene (evidence: `src/main.cpp`)
- Game scene → Input bindings: uses actions (evidence: `src/state/game.cpp`)
- Game scene → Toolbar: uses interface (evidence: `src/state/game.cpp`)
- Game scene → Screenshot capture: captures screenshot (evidence: `src/state/game.cpp`)
- Player movement → Camera: updates position (evidence: `src/game/Player.cpp`)
- Player movement → Chunk map: checks collisions (evidence: `src/game/Player.cpp`)
- Player movement → Input bindings: reads actions (evidence: `src/game/Player.cpp`)
- World simulation → Input bindings: reads actions (evidence: `src/world/world.cpp`)
- Chunk map → Chunk data: stores chunks
- Chunk map → Block registry: uses block registry
- Chunk map → Biome registry: uses biome registry
- Chunk data → Block registry: looks up blocks (evidence: `src/world/chunk/chunk.cpp`)
- Block registry → Block types: stores types
- Chunk meshing → World simulation: reads world (evidence: `src/render/chunk_mesh.cpp`)
- Chunk meshing → Asset loaders: loads assets (evidence: `src/render/chunk_mesh.cpp`)
- Chunk meshing → Cube faces: uses face geometry
- Skybox → Shader programs: uses shader programs
