# andyessomba/afrocraft architecture

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

- Interactive diagram: https://gitdiagram.com/andyessomba/afrocraft
- Repository: https://github.com/andyessomba/afrocraft
- Video tour (about a minute): https://gitdiagram.com/andyessomba/afrocraft/video

## Overview

AfroCraft is a browser-based Three.js voxel game. The main runtime initializes a generated world and its chunk meshes, then runs the playable experience: movement and block interaction against that world, with interface and day/night state. Procedural terrain, rendering, and player physics form distinct internal layers. The README also describes three biomes, block placement and breaking, and day/night progression. Some visual subsystems are indexed but their runtime wiring is not visible in the excerpts, so those links are marked unverified.

Main entry points: [`src/main.js`](https://github.com/andyessomba/afrocraft/blob/main/src/main.js) (Game entry), [`src/world/World.js`](https://github.com/andyessomba/afrocraft/blob/main/src/world/World.js) (Voxel world), [`src/generation/WorldGenerator.js`](https://github.com/andyessomba/afrocraft/blob/main/src/generation/WorldGenerator.js) (World generation), [`src/interaction/Interaction.js`](https://github.com/andyessomba/afrocraft/blob/main/src/interaction/Interaction.js) (Block interaction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Game runtime"]
  node_entry["Game entry<br/>[main.js]"]
  node_daynight["Day-night cycle<br/>[DayNightCycle.js]"]
end

subgraph group_terrain["World and terrain"]
  node_worldgen["World generation<br/>[WorldGenerator.js]"]
  node_biomes["Biome map<br/>[biomes.js]"]
  node_noise["Seeded noise<br/>[noise.js]"]
  node_world[("Voxel world<br/>[World.js]")]
  node_chunks[("Chunk storage<br/>[Chunk.js]")]
  node_block_types["Block definitions<br/>[blocks.js]"]
end

subgraph group_play["Player and interaction"]
  node_player["Player movement<br/>[Player.js]"]
  node_physics["Collision physics<br/>[Physics.js]"]
  node_interaction["Block interaction<br/>[Interaction.js]"]
  node_pointer_lock["Pointer lock<br/>[PointerLock.js]"]
end

subgraph group_visuals["Rendering and ambience"]
  node_chunk_renderer["Chunk renderer<br/>[ChunkRenderer.js]"]
  node_materials["Block materials<br/>[materials.js]"]
  node_player_model["Player model<br/>[PlayerModel.js]"]
  node_effects["Block effects<br/>[Effects.js]"]
  node_ambience["World ambience<br/>[Ambience.js]"]
end

subgraph group_interface["Game interface"]
  node_ui["Game interface"]
end

node_player_user(("Player"))

node_player_user -->|"starts game"| node_entry
node_entry -->|"generates world"| node_worldgen
node_worldgen -->|"uses biome map"| node_biomes
node_worldgen -->|"samples noise"| node_noise
node_biomes -->|"uses noise"| node_noise
node_worldgen -->|"writes terrain"| node_world
node_entry -->|"creates world"| node_world
node_world -->|"stores blocks"| node_chunks
node_entry -->|"builds meshes"| node_chunk_renderer
node_chunk_renderer -->|"reads chunks"| node_world
node_chunk_renderer -->|"creates materials"| node_materials
node_entry -->|"creates player"| node_player
node_player -->|"resolves movement"| node_physics
node_physics -->|"checks collisions"| node_world
node_entry -->|"wires interaction"| node_interaction
node_interaction -->|"reads and edits"| node_world
node_interaction -->|"checks overlap"| node_player
node_entry -->|"wires pointer lock"| node_pointer_lock
node_entry -->|"wires interface"| node_ui
node_entry -->|"creates cycle"| node_daynight
node_entry -.->|"may initialize effects"| node_effects
node_entry -.->|"may initialize ambience"| node_ambience
node_entry -.->|"may initialize model"| node_player_model

click node_entry "https://github.com/andyessomba/afrocraft/blob/main/src/main.js"
click node_daynight "https://github.com/andyessomba/afrocraft/blob/main/src/environment/DayNightCycle.js"
click node_worldgen "https://github.com/andyessomba/afrocraft/blob/main/src/generation/WorldGenerator.js"
click node_biomes "https://github.com/andyessomba/afrocraft/blob/main/src/generation/biomes.js"
click node_noise "https://github.com/andyessomba/afrocraft/blob/main/src/generation/noise.js"
click node_world "https://github.com/andyessomba/afrocraft/blob/main/src/world/World.js"
click node_chunks "https://github.com/andyessomba/afrocraft/blob/main/src/world/Chunk.js"
click node_block_types "https://github.com/andyessomba/afrocraft/blob/main/src/world/blocks.js"
click node_player "https://github.com/andyessomba/afrocraft/blob/main/src/player/Player.js"
click node_physics "https://github.com/andyessomba/afrocraft/blob/main/src/player/Physics.js"
click node_interaction "https://github.com/andyessomba/afrocraft/blob/main/src/interaction/Interaction.js"
click node_pointer_lock "https://github.com/andyessomba/afrocraft/blob/main/src/interaction/PointerLock.js"
click node_chunk_renderer "https://github.com/andyessomba/afrocraft/blob/main/src/rendering/ChunkRenderer.js"
click node_materials "https://github.com/andyessomba/afrocraft/blob/main/src/rendering/materials.js"
click node_player_model "https://github.com/andyessomba/afrocraft/blob/main/src/rendering/PlayerModel.js"
click node_effects "https://github.com/andyessomba/afrocraft/blob/main/src/effects/Effects.js"
click node_ambience "https://github.com/andyessomba/afrocraft/blob/main/src/environment/Ambience.js"
click node_ui "https://github.com/andyessomba/afrocraft/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_entry,node_daynight toneBlue
class node_worldgen,node_biomes,node_noise,node_world,node_chunks,node_block_types toneAmber
class node_player,node_physics,node_interaction,node_pointer_lock toneMint
class node_chunk_renderer,node_materials,node_player_model,node_effects,node_ambience toneRose
class node_ui,node_player_user toneIndigo
```

## Components

### Game runtime

- [Game entry](https://github.com/andyessomba/afrocraft/blob/main/src/main.js): `src/main.js`
- [Day-night cycle](https://github.com/andyessomba/afrocraft/blob/main/src/environment/DayNightCycle.js): `src/environment/DayNightCycle.js`

### World and terrain

- [World generation](https://github.com/andyessomba/afrocraft/blob/main/src/generation/WorldGenerator.js): `src/generation/WorldGenerator.js`
- [Biome map](https://github.com/andyessomba/afrocraft/blob/main/src/generation/biomes.js): `src/generation/biomes.js`
- [Seeded noise](https://github.com/andyessomba/afrocraft/blob/main/src/generation/noise.js): `src/generation/noise.js`
- [Voxel world](https://github.com/andyessomba/afrocraft/blob/main/src/world/World.js): `src/world/World.js`
- [Chunk storage](https://github.com/andyessomba/afrocraft/blob/main/src/world/Chunk.js): `src/world/Chunk.js`
- [Block definitions](https://github.com/andyessomba/afrocraft/blob/main/src/world/blocks.js): `src/world/blocks.js`

### Player and interaction

- [Player movement](https://github.com/andyessomba/afrocraft/blob/main/src/player/Player.js): `src/player/Player.js`
- [Collision physics](https://github.com/andyessomba/afrocraft/blob/main/src/player/Physics.js): `src/player/Physics.js`
- [Block interaction](https://github.com/andyessomba/afrocraft/blob/main/src/interaction/Interaction.js): `src/interaction/Interaction.js`
- [Pointer lock](https://github.com/andyessomba/afrocraft/blob/main/src/interaction/PointerLock.js): `src/interaction/PointerLock.js`

### Rendering and ambience

- [Chunk renderer](https://github.com/andyessomba/afrocraft/blob/main/src/rendering/ChunkRenderer.js): `src/rendering/ChunkRenderer.js`
- [Block materials](https://github.com/andyessomba/afrocraft/blob/main/src/rendering/materials.js): `src/rendering/materials.js`
- [Player model](https://github.com/andyessomba/afrocraft/blob/main/src/rendering/PlayerModel.js): `src/rendering/PlayerModel.js`
- [Block effects](https://github.com/andyessomba/afrocraft/blob/main/src/effects/Effects.js): `src/effects/Effects.js`
- [World ambience](https://github.com/andyessomba/afrocraft/blob/main/src/environment/Ambience.js): `src/environment/Ambience.js`

### Game interface

- [Game interface](https://github.com/andyessomba/afrocraft/tree/main/src/ui): `src/ui`

### Other components

- **Player**

## Connections

- Player → Game entry: starts game (evidence: `README.md`)
- Game entry → World generation: generates world (evidence: `src/main.js`)
- World generation → Biome map: uses biome map (evidence: `src/generation/WorldGenerator.js`)
- World generation → Seeded noise: samples noise (evidence: `src/generation/WorldGenerator.js`)
- Biome map → Seeded noise: uses noise (evidence: `src/generation/biomes.js`)
- World generation → Voxel world: writes terrain (evidence: `src/generation/WorldGenerator.js`)
- Game entry → Voxel world: creates world (evidence: `src/main.js`)
- Voxel world → Chunk storage: stores blocks (evidence: `src/world/World.js`)
- Game entry → Chunk renderer: builds meshes (evidence: `src/main.js`)
- Chunk renderer → Voxel world: reads chunks (evidence: `src/rendering/ChunkRenderer.js`)
- Chunk renderer → Block materials: creates materials (evidence: `src/rendering/ChunkRenderer.js`)
- Game entry → Player movement: creates player (evidence: `src/main.js`)
- Player movement → Collision physics: resolves movement (evidence: `src/player/Player.js`)
- Collision physics → Voxel world: checks collisions (evidence: `src/player/Physics.js`)
- Game entry → Block interaction: wires interaction (evidence: `src/main.js`)
- Block interaction → Voxel world: reads and edits (evidence: `src/interaction/Interaction.js`)
- Block interaction → Player movement: checks overlap (evidence: `src/interaction/Interaction.js`)
- Game entry → Pointer lock: wires pointer lock (evidence: `src/main.js`)
- Game entry → Game interface: wires interface (evidence: `src/main.js`)
- Game entry → Day-night cycle: creates cycle (evidence: `src/main.js`)
- Game entry → Block effects: may initialize effects (evidence: `src/main.js`)
- Game entry → World ambience: may initialize ambience (evidence: `src/main.js`)
- Game entry → Player model: may initialize model (evidence: `src/main.js`)
