# scratchapixel/scratchapixel-code architecture

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

- Interactive diagram: https://gitdiagram.com/scratchapixel/scratchapixel-code
- Repository: https://github.com/scratchapixel/scratchapixel-code

## Overview

##### Project type and purpose
- This is an educational code‐sample repository for the Scratchapixel website (www.scratchapixel.com).
- It bundles dozens of self-contained C++ “chapters” (modules), each illustrating a discrete computer‐graphics concept (ray tracing, rasterization, geometry transforms, texturing, etc.).

##### File structure
- The root is a Git repo containing one directory per tutorial topic (e.g., “global‐illumination‐path‐tracing”, “perlin‐noise‐part‐2”, “ray‐tracing‐rendering‐a‐triangle”, etc.).
- Inside each module are source files (.cpp/.cc), headers (.h), and assets (.obj, .ppm, .zip).
- No shared build script—each module is compiled/run independently with a standard C++ toolchain.

##### README
- Confirms this is the “Official Scratchapixel website’s code repo.”

##### Detail without overthinking
- Every essential element: repo structure, module independence, build process, runtime output.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Layer
    Repo["Scratchapixel Repo"]:::repo
    click Repo "https://github.com/scratchapixel/scratchapixel-code/tree/main//"

    %% Detailed Module
    subgraph "Detailed Module: Ray Tracing Rendering a Triangle"
        raytri["ray-tracing-rendering-a-triangle"]:::module
        raytri --> src1["raytri.cpp"]:::code
        raytri --> hdr1["geometry.h"]:::code
        click src1 "https://github.com/scratchapixel/scratchapixel-code/blob/main/ray-tracing-rendering-a-triangle/raytri.cpp"
        click hdr1 "https://github.com/scratchapixel/scratchapixel-code/blob/main/ray-tracing-rendering-a-triangle/geometry.h"
    end
    Repo --> raytri

    %% Build and Execution
    src1 & hdr1 --> compiler["C++ Compiler & Linker"]:::process
    compiler --> exe["Executable"]:::process
    exe --> out["Output Image (untitled.ppm)"]:::output
    click out "https://github.com/scratchapixel/scratchapixel-code/blob/main/introduction-rendering/untitled.ppm"

    %% Other Modules (Greyed)
    subgraph "Other Modules"
        gi["global-illumination-path-tracing"]:::moduleGrey
        intR["introduction-rendering"]:::moduleGrey
        intL["introduction-to-lighting"]:::moduleGrey
        intT["introduction-to-texturing"]:::moduleGrey
        minRT["minimal-ray-tracer-rendering-simple-shapes"]:::moduleGrey
        util["build-raytracer-core"]:::moduleGrey
        view3d["3d-viewing-pinhole-camera"]:::moduleGrey
    end
    Repo --> gi
    Repo --> intR
    Repo --> intL
    Repo --> intT
    Repo --> minRT
    Repo --> util
    Repo --> view3d

    click gi "https://github.com/scratchapixel/scratchapixel-code/tree/main/global-illumination-path-tracing/"
    click intR "https://github.com/scratchapixel/scratchapixel-code/tree/main/introduction-rendering/"
    click intL "https://github.com/scratchapixel/scratchapixel-code/tree/main/introduction-to-lighting/"
    click intT "https://github.com/scratchapixel/scratchapixel-code/tree/main/introduction-to-texturing/"
    click minRT "https://github.com/scratchapixel/scratchapixel-code/tree/main/minimal-ray-tracer-rendering-simple-shapes/"
    click util "https://github.com/scratchapixel/scratchapixel-code/tree/main/build-raytracer-core/"
    click view3d "https://github.com/scratchapixel/scratchapixel-code/tree/main/3d-viewing-pinhole-camera/"

    %% Styles
    classDef repo fill:#f2f2f2,stroke:#333,stroke-width:1px;
    classDef module fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef code fill:#bbdefb,stroke:#0d47a1,stroke-width:1px;
    classDef asset fill:#c8e6c9,stroke:#1b5e20,stroke-width:1px;
    classDef process fill:#ffe0b2,stroke:#e65100,stroke-width:2px;
    classDef output fill:#ffccbc,stroke:#bf360c,stroke-width:1px;
    classDef moduleGrey fill:#e0e0e0,stroke:#9e9e9e,stroke-width:1px,opacity:50%;
```
