# quentin6440/minirt architecture

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

- Interactive diagram: https://gitdiagram.com/quentin6440/minirt
- Repository: https://github.com/quentin6440/minirt

## Overview

miniRT reads one .rt scene, validates its camera, lighting, and geometry, then renders the scene in a MiniLibX window until the user exits. The graph preserves the documented sphere, plane, finite-cylinder, ambient/diffuse-lighting, and shadow capabilities. Source excerpts confirm argument handling and parsing details; rendering and event wiring are represented at the documented subsystem level because their implementations were not sampled.

Main entry points: [`src/render.c`](https://github.com/quentin6440/minirt/blob/main/src/render.c) (Scene renderer), [`src/main.c`](https://github.com/quentin6440/minirt/blob/main/src/main.c) (Program entry), [`src/intersect.c`](https://github.com/quentin6440/minirt/blob/main/src/intersect.c) (Scene intersections), [`src/runtime.c`](https://github.com/quentin6440/minirt/blob/main/src/runtime.c) (Window runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Scene input"]
  node_main["Program entry<br/>[main.c]"]
  node_scene_loader["Scene loading<br/>[parse_file.c]"]
  node_line_parser["Line dispatch<br/>[parser.c]"]
  node_element_parser["Global elements<br/>[parse_elements.c]"]
  node_object_parser["Object elements<br/>[parse_obj.c]"]
  node_parse_utils["Parse conversion<br/>[parse_utils.c]"]
end

subgraph group_scene["Scene model"]
  node_scene_state["Scene state<br/>[minirt.h]"]
end

subgraph group_tracing["Ray tracing"]
  node_ray_generation["Camera rays<br/>[ray.c]"]
  node_intersection["Scene intersections<br/>[intersect.c]"]
  node_geometry["Shape intersections<br/>[obj_sp.c]"]
  node_cylinder_geometry["Cylinder geometry<br/>[obj_cl.c]"]
  node_surface_normals["Surface normals<br/>[normal.c]"]
  node_lighting["Diffuse lighting<br/>[light.c]"]
  node_shadows["Shadow checks<br/>[shadow.c]"]
  node_color["Color calculation<br/>[color.c]"]
  node_vector_math["Vector operations<br/>[vec_math.c]"]
end

subgraph group_display["Display runtime"]
  node_renderer["Scene renderer<br/>[render.c]"]
  node_pixel_output["Image output<br/>[mlx_utils.c]"]
  node_runtime["Window runtime<br/>[runtime.c]"]
  node_events["Window events<br/>[events.c]"]
end

node_user(("User"))
node_scene_file["Scene file"]
node_mlx["MiniLibX"]

node_user -->|"starts with"| node_main
node_main -->|"loads scene"| node_scene_loader
node_scene_file -->|"supplies text"| node_scene_loader
node_scene_loader -->|"parses lines"| node_line_parser
node_line_parser -->|"dispatches globals"| node_element_parser
node_line_parser -->|"dispatches objects"| node_object_parser
node_element_parser -->|"converts values"| node_parse_utils
node_object_parser -->|"converts values"| node_parse_utils
node_scene_loader -->|"fills scene"| node_scene_state
node_main -->|"starts runtime"| node_runtime
node_main -->|"destroys scene"| node_scene_state
node_runtime -->|"renders scene"| node_renderer
node_renderer -->|"writes pixels"| node_pixel_output
node_runtime -->|"uses windowing"| node_mlx
node_pixel_output -->|"displays image"| node_mlx
node_user -->|"exits window"| node_events
node_runtime -->|"registers handlers"| node_events
node_renderer -->|"generates rays"| node_ray_generation
node_renderer -->|"tests scene"| node_intersection
node_intersection -->|"tests shapes"| node_geometry
node_intersection -->|"tests cylinders"| node_cylinder_geometry
node_renderer -->|"gets normals"| node_surface_normals
node_renderer -->|"computes lighting"| node_lighting
node_renderer -->|"checks shadows"| node_shadows
node_renderer -->|"computes color"| node_color
node_ray_generation -->|"uses vectors"| node_vector_math
node_intersection -->|"uses vectors"| node_vector_math

click node_main "https://github.com/quentin6440/minirt/blob/main/src/main.c"
click node_scene_loader "https://github.com/quentin6440/minirt/blob/main/src/parse_file.c"
click node_line_parser "https://github.com/quentin6440/minirt/blob/main/src/parser.c"
click node_element_parser "https://github.com/quentin6440/minirt/blob/main/src/parse_elements.c"
click node_object_parser "https://github.com/quentin6440/minirt/blob/main/src/parse_obj.c"
click node_parse_utils "https://github.com/quentin6440/minirt/blob/main/src/parse_utils.c"
click node_scene_state "https://github.com/quentin6440/minirt/blob/main/include/minirt.h"
click node_ray_generation "https://github.com/quentin6440/minirt/blob/main/src/ray.c"
click node_intersection "https://github.com/quentin6440/minirt/blob/main/src/intersect.c"
click node_geometry "https://github.com/quentin6440/minirt/blob/main/src/obj_sp.c"
click node_cylinder_geometry "https://github.com/quentin6440/minirt/blob/main/src/obj_cl.c"
click node_surface_normals "https://github.com/quentin6440/minirt/blob/main/src/normal.c"
click node_lighting "https://github.com/quentin6440/minirt/blob/main/src/light.c"
click node_shadows "https://github.com/quentin6440/minirt/blob/main/src/shadow.c"
click node_color "https://github.com/quentin6440/minirt/blob/main/src/color.c"
click node_renderer "https://github.com/quentin6440/minirt/blob/main/src/render.c"
click node_pixel_output "https://github.com/quentin6440/minirt/blob/main/src/mlx_utils.c"
click node_runtime "https://github.com/quentin6440/minirt/blob/main/src/runtime.c"
click node_events "https://github.com/quentin6440/minirt/blob/main/src/events.c"
click node_vector_math "https://github.com/quentin6440/minirt/blob/main/src/vec_math.c"

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_scene_loader,node_line_parser,node_element_parser,node_object_parser,node_parse_utils,node_user toneBlue
class node_scene_state toneAmber
class node_ray_generation,node_intersection,node_geometry,node_cylinder_geometry,node_surface_normals,node_lighting,node_shadows,node_color,node_vector_math toneMint
class node_renderer,node_pixel_output,node_runtime,node_events toneRose
class node_scene_file,node_mlx toneIndigo
```

## Components

### Scene input

- [Program entry](https://github.com/quentin6440/minirt/blob/main/src/main.c): `src/main.c`
- [Scene loading](https://github.com/quentin6440/minirt/blob/main/src/parse_file.c): `src/parse_file.c`
- [Line dispatch](https://github.com/quentin6440/minirt/blob/main/src/parser.c): `src/parser.c`
- [Global elements](https://github.com/quentin6440/minirt/blob/main/src/parse_elements.c): `src/parse_elements.c`
- [Object elements](https://github.com/quentin6440/minirt/blob/main/src/parse_obj.c): `src/parse_obj.c`
- [Parse conversion](https://github.com/quentin6440/minirt/blob/main/src/parse_utils.c): `src/parse_utils.c`

### Scene model

- [Scene state](https://github.com/quentin6440/minirt/blob/main/include/minirt.h): `include/minirt.h`

### Ray tracing

- [Camera rays](https://github.com/quentin6440/minirt/blob/main/src/ray.c): `src/ray.c`
- [Scene intersections](https://github.com/quentin6440/minirt/blob/main/src/intersect.c): `src/intersect.c`
- [Shape intersections](https://github.com/quentin6440/minirt/blob/main/src/obj_sp.c): `src/obj_sp.c`
- [Cylinder geometry](https://github.com/quentin6440/minirt/blob/main/src/obj_cl.c): `src/obj_cl.c`
- [Surface normals](https://github.com/quentin6440/minirt/blob/main/src/normal.c): `src/normal.c`
- [Diffuse lighting](https://github.com/quentin6440/minirt/blob/main/src/light.c): `src/light.c`
- [Shadow checks](https://github.com/quentin6440/minirt/blob/main/src/shadow.c): `src/shadow.c`
- [Color calculation](https://github.com/quentin6440/minirt/blob/main/src/color.c): `src/color.c`
- [Vector operations](https://github.com/quentin6440/minirt/blob/main/src/vec_math.c): `src/vec_math.c`

### Display runtime

- [Scene renderer](https://github.com/quentin6440/minirt/blob/main/src/render.c): `src/render.c`
- [Image output](https://github.com/quentin6440/minirt/blob/main/src/mlx_utils.c): `src/mlx_utils.c`
- [Window runtime](https://github.com/quentin6440/minirt/blob/main/src/runtime.c): `src/runtime.c`
- [Window events](https://github.com/quentin6440/minirt/blob/main/src/events.c): `src/events.c`

### Other components

- **User**
- **Scene file**
- **MiniLibX**

## Connections

- User → Program entry: starts with
- Program entry → Scene loading: loads scene
- Scene file → Scene loading: supplies text
- Scene loading → Line dispatch: parses lines
- Line dispatch → Global elements: dispatches globals
- Line dispatch → Object elements: dispatches objects
- Global elements → Parse conversion: converts values
- Object elements → Parse conversion: converts values
- Scene loading → Scene state: fills scene
- Program entry → Window runtime: starts runtime
- Program entry → Scene state: destroys scene
- Window runtime → Scene renderer: renders scene
- Scene renderer → Image output: writes pixels
- Window runtime → MiniLibX: uses windowing
- Image output → MiniLibX: displays image
- User → Window events: exits window
- Window runtime → Window events: registers handlers
- Scene renderer → Camera rays: generates rays
- Scene renderer → Scene intersections: tests scene
- Scene intersections → Shape intersections: tests shapes
- Scene intersections → Cylinder geometry: tests cylinders
- Scene renderer → Surface normals: gets normals
- Scene renderer → Diffuse lighting: computes lighting
- Scene renderer → Shadow checks: checks shadows
- Scene renderer → Color calculation: computes color
- Camera rays → Vector operations: uses vectors
- Scene intersections → Vector operations: uses vectors
