# juanp95m/cub3d_public architecture

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

- Interactive diagram: https://gitdiagram.com/juanp95m/cub3d_public
- Repository: https://github.com/juanp95m/cub3d_public

## Overview

Cub3D is a raycasting game that accepts a .cub map, validates its configuration and walkable map, initializes graphics, and runs an interactive movement-and-render loop. Its main domain stages are parsing, map validation, player control, raycasting, and drawing. MLX42 supplies the graphics runtime; libft and get_next_line provide supporting utilities. Several internal calls are not visible in the excerpts, so links beyond the main entry point and README-documented behavior are omitted or marked unverified.

Main entry points: [`src/parse/parsing.c`](https://github.com/juanp95m/cub3d_public/blob/main/src/parse/parsing.c) (Config parsing), [`src/core/main.c`](https://github.com/juanp95m/cub3d_public/blob/main/src/core/main.c) (Game entry), [`MLX42/src`](https://github.com/juanp95m/cub3d_public/tree/main/MLX42/src) (MLX42 runtime), [`src/graphics/graphics.c`](https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/graphics.c) (Graphics setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_game["Game runtime"]
  node_entry["Game entry<br/>[main.c]"]
  node_lifecycle["Game lifecycle"]
  node_controls["Player controls<br/>[player_move.c]"]
  node_rotation["Camera rotation<br/>[player_rotate.c]"]
  node_rayinit["Ray setup<br/>[raycast_init.c]"]
  node_dda["DDA traversal<br/>[raycast_dda.c]"]
  node_wallrender["Wall rendering<br/>[raycast_draw.c]"]
end

subgraph group_input["Map input"]
  node_parser["Config parsing<br/>[parsing.c]"]
  node_colors["Color parsing<br/>[save_color.c]"]
  node_texturespec["Texture parsing<br/>[save_texture.c]"]
  node_mapdata["Map loading<br/>[save_map.c]"]
  node_mapchecks["Map validation<br/>[map_validation.c]"]
  node_padding["Map padding<br/>[map_padding.c]"]
end

subgraph group_graphics["Graphics runtime"]
  node_graphics["Graphics setup<br/>[graphics.c]"]
  node_textureinit["Texture setup<br/>[init_textures.c]"]
  node_renderloop["Render loop<br/>[render_loop.c]"]
  node_mlx["MLX42 runtime"]
  node_mlxheaders["MLX42 API<br/>[MLX42.h]"]
  node_png["PNG decoder<br/>[lodepng.c]"]
  node_glad["OpenGL loader<br/>[glad.c]"]
end

subgraph group_support["C support"]
  node_gnl["Line reader<br/>[get_next_line.c]"]
  node_libft["Libft utilities<br/>[libft.h]"]
end

node_player(("Player"))
node_mapfile["Map file"]

node_player -->|"starts with"| node_entry
node_mapfile -->|"supplies map"| node_entry
node_entry -->|"calls"| node_parser
node_entry -->|"initializes"| node_graphics
node_entry -->|"runs loop"| node_mlx
node_entry -->|"frees state"| node_lifecycle
node_parser -.->|"reads colors"| node_colors
node_parser -.->|"reads textures"| node_texturespec
node_parser -.->|"reads map"| node_mapdata
node_mapdata -.->|"validates"| node_mapchecks
node_mapchecks -.->|"pads map"| node_padding
node_player -->|"moves"| node_controls
node_player -->|"rotates view"| node_rotation
node_renderloop -.->|"sets up rays"| node_rayinit
node_renderloop -->|"casts rays"| node_dda
node_renderloop -.->|"draws walls"| node_wallrender
node_graphics -.->|"loads textures"| node_textureinit
node_graphics -.->|"starts rendering"| node_renderloop
node_graphics -->|"uses runtime"| node_mlx
node_mlxheaders -->|"defines API"| node_mlx
node_mlx -.->|"decodes PNG"| node_png
node_mlx -.->|"loads OpenGL"| node_glad
node_parser -.->|"reads lines"| node_gnl
node_parser -.->|"uses utilities"| node_libft

click node_entry "https://github.com/juanp95m/cub3d_public/blob/main/src/core/main.c"
click node_lifecycle "https://github.com/juanp95m/cub3d_public/tree/main/src/core"
click node_parser "https://github.com/juanp95m/cub3d_public/blob/main/src/parse/parsing.c"
click node_colors "https://github.com/juanp95m/cub3d_public/blob/main/src/parse/save_color.c"
click node_texturespec "https://github.com/juanp95m/cub3d_public/blob/main/src/parse/save_texture.c"
click node_mapdata "https://github.com/juanp95m/cub3d_public/blob/main/src/parse/save_map.c"
click node_mapchecks "https://github.com/juanp95m/cub3d_public/blob/main/src/map/map_validation.c"
click node_padding "https://github.com/juanp95m/cub3d_public/blob/main/src/map/map_padding.c"
click node_controls "https://github.com/juanp95m/cub3d_public/blob/main/src/player/player_move.c"
click node_rotation "https://github.com/juanp95m/cub3d_public/blob/main/src/player/player_rotate.c"
click node_rayinit "https://github.com/juanp95m/cub3d_public/blob/main/src/raycast/raycast_init.c"
click node_dda "https://github.com/juanp95m/cub3d_public/blob/main/src/raycast/raycast_dda.c"
click node_wallrender "https://github.com/juanp95m/cub3d_public/blob/main/src/raycast/raycast_draw.c"
click node_graphics "https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/graphics.c"
click node_textureinit "https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/init_textures.c"
click node_renderloop "https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/render_loop.c"
click node_mlx "https://github.com/juanp95m/cub3d_public/tree/main/MLX42/src"
click node_mlxheaders "https://github.com/juanp95m/cub3d_public/blob/main/MLX42/include/MLX42/MLX42.h"
click node_png "https://github.com/juanp95m/cub3d_public/blob/main/MLX42/lib/png/lodepng.c"
click node_glad "https://github.com/juanp95m/cub3d_public/blob/main/MLX42/lib/glad/glad.c"
click node_gnl "https://github.com/juanp95m/cub3d_public/blob/main/Get_next_line/get_next_line.c"
click node_libft "https://github.com/juanp95m/cub3d_public/blob/main/libft/libft.h"

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_lifecycle,node_controls,node_rotation,node_rayinit,node_dda,node_wallrender toneBlue
class node_parser,node_colors,node_texturespec,node_mapdata,node_mapchecks,node_padding toneAmber
class node_graphics,node_textureinit,node_renderloop,node_mlx,node_mlxheaders,node_png,node_glad toneMint
class node_gnl,node_libft toneRose
class node_player,node_mapfile toneIndigo
```

## Components

### Game runtime

- [Game entry](https://github.com/juanp95m/cub3d_public/blob/main/src/core/main.c): `src/core/main.c`
- [Game lifecycle](https://github.com/juanp95m/cub3d_public/tree/main/src/core): `src/core`
- [Player controls](https://github.com/juanp95m/cub3d_public/blob/main/src/player/player_move.c): `src/player/player_move.c`
- [Camera rotation](https://github.com/juanp95m/cub3d_public/blob/main/src/player/player_rotate.c): `src/player/player_rotate.c`
- [Ray setup](https://github.com/juanp95m/cub3d_public/blob/main/src/raycast/raycast_init.c): `src/raycast/raycast_init.c`
- [DDA traversal](https://github.com/juanp95m/cub3d_public/blob/main/src/raycast/raycast_dda.c): `src/raycast/raycast_dda.c`
- [Wall rendering](https://github.com/juanp95m/cub3d_public/blob/main/src/raycast/raycast_draw.c): `src/raycast/raycast_draw.c`

### Map input

- [Config parsing](https://github.com/juanp95m/cub3d_public/blob/main/src/parse/parsing.c): `src/parse/parsing.c`
- [Color parsing](https://github.com/juanp95m/cub3d_public/blob/main/src/parse/save_color.c): `src/parse/save_color.c`
- [Texture parsing](https://github.com/juanp95m/cub3d_public/blob/main/src/parse/save_texture.c): `src/parse/save_texture.c`
- [Map loading](https://github.com/juanp95m/cub3d_public/blob/main/src/parse/save_map.c): `src/parse/save_map.c`
- [Map validation](https://github.com/juanp95m/cub3d_public/blob/main/src/map/map_validation.c): `src/map/map_validation.c`
- [Map padding](https://github.com/juanp95m/cub3d_public/blob/main/src/map/map_padding.c): `src/map/map_padding.c`

### Graphics runtime

- [Graphics setup](https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/graphics.c): `src/graphics/graphics.c`
- [Texture setup](https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/init_textures.c): `src/graphics/init_textures.c`
- [Render loop](https://github.com/juanp95m/cub3d_public/blob/main/src/graphics/render_loop.c): `src/graphics/render_loop.c`
- [MLX42 runtime](https://github.com/juanp95m/cub3d_public/tree/main/MLX42/src): `MLX42/src`
- [MLX42 API](https://github.com/juanp95m/cub3d_public/blob/main/MLX42/include/MLX42/MLX42.h): `MLX42/include/MLX42/MLX42.h`
- [PNG decoder](https://github.com/juanp95m/cub3d_public/blob/main/MLX42/lib/png/lodepng.c): `MLX42/lib/png/lodepng.c`
- [OpenGL loader](https://github.com/juanp95m/cub3d_public/blob/main/MLX42/lib/glad/glad.c): `MLX42/lib/glad/glad.c`

### C support

- [Line reader](https://github.com/juanp95m/cub3d_public/blob/main/Get_next_line/get_next_line.c): `Get_next_line/get_next_line.c`
- [Libft utilities](https://github.com/juanp95m/cub3d_public/blob/main/libft/libft.h): `libft/libft.h`

### Other components

- **Player**
- **Map file**

## Connections

- Player → Game entry: starts with (evidence: `README.md`)
- Map file → Game entry: supplies map (evidence: `README.md`)
- Game entry → Config parsing: calls (evidence: `src/core/main.c`)
- Game entry → Graphics setup: initializes (evidence: `src/core/main.c`)
- Game entry → MLX42 runtime: runs loop (evidence: `src/core/main.c`)
- Game entry → Game lifecycle: frees state (evidence: `src/core/main.c`)
- Config parsing → Color parsing: reads colors
- Config parsing → Texture parsing: reads textures
- Config parsing → Map loading: reads map
- Map loading → Map validation: validates
- Map validation → Map padding: pads map
- Player → Player controls: moves (evidence: `README.md`)
- Player → Camera rotation: rotates view (evidence: `README.md`)
- Render loop → Ray setup: sets up rays
- Render loop → DDA traversal: casts rays (evidence: `README.md`)
- Render loop → Wall rendering: draws walls
- Graphics setup → Texture setup: loads textures
- Graphics setup → Render loop: starts rendering
- Graphics setup → MLX42 runtime: uses runtime
- MLX42 API → MLX42 runtime: defines API (evidence: `MLX42/include/MLX42/MLX42.h`)
- MLX42 runtime → PNG decoder: decodes PNG
- MLX42 runtime → OpenGL loader: loads OpenGL
- Config parsing → Line reader: reads lines
- Config parsing → Libft utilities: uses utilities
