# carlos-o-grande/minirt architecture

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

- Interactive diagram: https://gitdiagram.com/carlos-o-grande/minirt
- Repository: https://github.com/carlos-o-grande/minirt

## Overview

miniRT is a C path tracer with a MiniLibX interface. The main workflow is to launch with a `.rt` scene, parse scene elements, render sampled rays into an image, and display it; the separate menu adjusts render and material settings. Additional branches provide progressive rendering, anaglyph and depth views, and scene textures. The graph combines README-documented capabilities with shown calls; several subsystem links are documented at a feature level because their implementation files were not sampled.

Main entry points: [`srcs/menu`](https://github.com/carlos-o-grande/minirt/tree/main/srcs/menu) (Menu controls), [`srcs/main.c`](https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c) (Ray renderer), [`srcs/rays/ray_color.c`](https://github.com/carlos-o-grande/minirt/blob/main/srcs/rays/ray_color.c) (Ray color), [`srcs/mlx/image_window.c`](https://github.com/carlos-o-grande/minirt/blob/main/srcs/mlx/image_window.c) (Image display)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_scene["Scene input"]
  node_scene_file["RT scene file"]
  node_entry["Program entry<br/>[main.c]"]
  node_parser["Scene parser"]
  node_geometry["Scene geometry"]
end

subgraph group_trace["Path tracing"]
  node_ray_render["Ray renderer<br/>[main.c]"]
  node_ray_color["Ray color<br/>[ray_color.c]"]
  node_intersections["Shape intersections<br/>[intersections.c]"]
  node_materials["Material scattering"]
  node_textures["Textures and bumps"]
  node_progressive["Progressive passes<br/>[main.c]"]
end

subgraph group_views["Render views"]
  node_anaglyph["Anaglyph views"]
  node_depth["Depth views<br/>[anaglyph_depth.c]"]
end

subgraph group_interface["User interface"]
  node_menu["Menu controls"]
  node_menu_draw["Menu rendering<br/>[render_bts.c]"]
  node_xpm["XPM assets<br/>[draw_xpm.c]"]
end

subgraph group_platform["Display platform"]
  node_display["Image display<br/>[image_window.c]"]
  node_mlx["MiniLibX<br/>[mlx_int.h]"]
  node_libft["C utility library<br/>[libft.h]"]
end

node_user(("User"))

node_user -->|"launches"| node_entry
node_scene_file -->|"provides scene"| node_parser
node_entry -->|"runs render loop"| node_ray_render
node_ray_render -->|"traces rays"| node_ray_color
node_ray_render -->|"shows image"| node_display
node_ray_render -->|"accumulates passes"| node_progressive
node_ray_color -.->|"tests hits"| node_intersections
node_ray_color -.->|"shades materials"| node_materials
node_ray_color -.->|"uses textures"| node_textures
node_parser -->|"parses shapes"| node_geometry
node_user -->|"changes settings"| node_menu
node_menu -.->|"draws controls"| node_menu_draw
node_menu -->|"starts or stops"| node_ray_render
node_menu -->|"requests view"| node_anaglyph
node_menu -->|"requests depth view"| node_depth
node_anaglyph -->|"shows merged image"| node_display
node_depth -->|"shows depth image"| node_display
node_xpm -->|"loads image"| node_mlx
node_display -.->|"uses window API"| node_mlx
node_entry -.->|"uses utilities"| node_libft

click node_entry "https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c"
click node_parser "https://github.com/carlos-o-grande/minirt/tree/main/srcs/parsing"
click node_geometry "https://github.com/carlos-o-grande/minirt/tree/main/srcs/parsing"
click node_ray_render "https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c"
click node_ray_color "https://github.com/carlos-o-grande/minirt/blob/main/srcs/rays/ray_color.c"
click node_intersections "https://github.com/carlos-o-grande/minirt/blob/main/srcs/rays/intersections.c"
click node_materials "https://github.com/carlos-o-grande/minirt/tree/main/srcs/rays"
click node_textures "https://github.com/carlos-o-grande/minirt/tree/main/srcs/rays"
click node_progressive "https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c"
click node_display "https://github.com/carlos-o-grande/minirt/blob/main/srcs/mlx/image_window.c"
click node_mlx "https://github.com/carlos-o-grande/minirt/blob/main/lib/mlx_linux/mlx_int.h"
click node_menu "https://github.com/carlos-o-grande/minirt/tree/main/srcs/menu"
click node_menu_draw "https://github.com/carlos-o-grande/minirt/blob/main/srcs/menu/render_bts.c"
click node_anaglyph "https://github.com/carlos-o-grande/minirt/tree/main/srcs/anaglyph"
click node_depth "https://github.com/carlos-o-grande/minirt/blob/main/srcs/anaglyph/anaglyph_depth.c"
click node_xpm "https://github.com/carlos-o-grande/minirt/blob/main/srcs/mlx/draw_xpm.c"
click node_libft "https://github.com/carlos-o-grande/minirt/blob/main/lib/libft/include/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_scene_file,node_entry,node_parser,node_geometry,node_user toneBlue
class node_ray_render,node_ray_color,node_intersections,node_materials,node_textures,node_progressive toneAmber
class node_anaglyph,node_depth toneMint
class node_menu,node_menu_draw,node_xpm toneRose
class node_display,node_mlx,node_libft toneIndigo
```

## Components

### Scene input

- **RT scene file**
- [Program entry](https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c): `srcs/main.c`
- [Scene parser](https://github.com/carlos-o-grande/minirt/tree/main/srcs/parsing): `srcs/parsing`
- [Scene geometry](https://github.com/carlos-o-grande/minirt/tree/main/srcs/parsing): `srcs/parsing`

### Path tracing

- [Ray renderer](https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c): `srcs/main.c`
- [Ray color](https://github.com/carlos-o-grande/minirt/blob/main/srcs/rays/ray_color.c): `srcs/rays/ray_color.c`
- [Shape intersections](https://github.com/carlos-o-grande/minirt/blob/main/srcs/rays/intersections.c): `srcs/rays/intersections.c`
- [Material scattering](https://github.com/carlos-o-grande/minirt/tree/main/srcs/rays): `srcs/rays`
- [Textures and bumps](https://github.com/carlos-o-grande/minirt/tree/main/srcs/rays): `srcs/rays`
- [Progressive passes](https://github.com/carlos-o-grande/minirt/blob/main/srcs/main.c): `srcs/main.c`

### Render views

- [Anaglyph views](https://github.com/carlos-o-grande/minirt/tree/main/srcs/anaglyph): `srcs/anaglyph`
- [Depth views](https://github.com/carlos-o-grande/minirt/blob/main/srcs/anaglyph/anaglyph_depth.c): `srcs/anaglyph/anaglyph_depth.c`

### User interface

- [Menu controls](https://github.com/carlos-o-grande/minirt/tree/main/srcs/menu): `srcs/menu`
- [Menu rendering](https://github.com/carlos-o-grande/minirt/blob/main/srcs/menu/render_bts.c): `srcs/menu/render_bts.c`
- [XPM assets](https://github.com/carlos-o-grande/minirt/blob/main/srcs/mlx/draw_xpm.c): `srcs/mlx/draw_xpm.c`

### Display platform

- [Image display](https://github.com/carlos-o-grande/minirt/blob/main/srcs/mlx/image_window.c): `srcs/mlx/image_window.c`
- [MiniLibX](https://github.com/carlos-o-grande/minirt/blob/main/lib/mlx_linux/mlx_int.h): `lib/mlx_linux/mlx_int.h`
- [C utility library](https://github.com/carlos-o-grande/minirt/blob/main/lib/libft/include/libft.h): `lib/libft/include/libft.h`

### Other components

- **User**

## Connections

- User → Program entry: launches (evidence: `README.md`)
- RT scene file → Scene parser: provides scene (evidence: `README.md`)
- Program entry → Ray renderer: runs render loop (evidence: `srcs/main.c`)
- Ray renderer → Ray color: traces rays (evidence: `srcs/main.c`)
- Ray renderer → Image display: shows image (evidence: `srcs/main.c`)
- Ray renderer → Progressive passes: accumulates passes (evidence: `srcs/main.c`)
- Ray color → Shape intersections: tests hits
- Ray color → Material scattering: shades materials
- Ray color → Textures and bumps: uses textures
- Scene parser → Scene geometry: parses shapes (evidence: `README.md`)
- User → Menu controls: changes settings (evidence: `README.md`)
- Menu controls → Menu rendering: draws controls
- Menu controls → Ray renderer: starts or stops (evidence: `README.md`)
- Menu controls → Anaglyph views: requests view (evidence: `README.md`)
- Menu controls → Depth views: requests depth view (evidence: `README.md`)
- Anaglyph views → Image display: shows merged image (evidence: `README.md`)
- Depth views → Image display: shows depth image (evidence: `README.md`)
- XPM assets → MiniLibX: loads image (evidence: `srcs/mlx/draw_xpm.c`)
- Image display → MiniLibX: uses window API
- Program entry → C utility library: uses utilities
