# cmu-graphics/scotty3d architecture

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

- Interactive diagram: https://gitdiagram.com/cmu-graphics/scotty3d
- Repository: https://github.com/cmu-graphics/scotty3d

## Overview

##### Main Components

a) Core Application Layer:
- Entry point (src/main.cpp, src/app.cpp)
- GUI System (src/gui/*)
- Scene Management (src/scene/*)

b) Major Functional Modules:
- Geometry Processing (src/geometry/*)
- Rasterization Pipeline (src/rasterizer/*)
- Path Tracer (src/pathtracer/*)
- Animation System (src/scene/animator.*, src/scene/skeleton.*)

c) Support Systems:
- Platform Layer (src/platform/*)
- Math Library (src/lib/*)
- Utility Functions (src/util/*)

##### Component Relationships

**[GUI Layer] ←→ [Scene Management]**
- ↑               ↑

- ↓               ↓
**[Core Application Logic]**
- ↑     ↑     ↑     ↑

**[Geometry] [Rasterizer] [PathTracer] [Animation]**
- ↑     ↑     ↑     ↑

**[Math Library & Utilities]**
- ↑

**[Platform Layer]**

##### Specific Implementation Details

a) Scene Graph Structure:
- How scene/scene.h manages the hierarchy of:
- Meshes (geometry/halfedge.h)
- Materials (scene/material.h)
- Lights (scene/delta_light.h, scene/env_light.h)
- Cameras (scene/camera.h)

b) Pipeline Flow:
- Rendering pipeline from:
- Scene data → Rasterizer → Framebuffer
- Scene data → Path Tracer → Final Image

c) Animation System:
- Relationship between:
- Skeleton system (scene/skeleton.h)
- Particle system (scene/particles.h)
- Animation controller (scene/animator.h)

##### External Dependencies
- ImGui (UI framework)
- SDL (platform abstraction)
- OpenGL (rendering backend)

##### Testing Framework
- How it interfaces with each major component

##### Build System
- A small section showing the build pipeline:
- Maekfile.js
- nest-libs dependencies
- Platform-specific compilation

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and classes
    classDef core fill:#4a90e2,color:white
    classDef processing fill:#2ecc71,color:white
    classDef support fill:#f1c40f,color:black
    classDef platform fill:#e67e22,color:white
    classDef external fill:#95a5a6,color:white
    classDef testing fill:#8e44ad,color:white

    %% Main Application Layer
    subgraph AppLayer
        MainEntry["Main Entry Point"]:::core
        AppCore["Application Core"]:::core
    end
    click MainEntry "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/main.cpp"
    click AppCore "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/app.cpp"

    %% GUI and Scene Management Layer
    subgraph TopLayer
        GUI["GUI System"]:::core
        SceneManagement["Scene Management"]:::core
    end
    click GUI "https://github.com/CMU-Graphics/Scotty3D/tree/main/src/gui"
    click SceneManagement "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/scene.h"

    %% Scene Components
    subgraph SceneComponents
        Materials["Materials"]:::core
        Lights["Lights"]:::core
        Camera["Camera"]:::core
    end
    click Materials "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/material.h"
    click Lights "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/delta_light.h"
    click Camera "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/camera.h"

    %% Processing Modules
    subgraph ProcessingModules
        Geometry["Geometry Processing"]:::processing
        Rasterizer["Rasterizer"]:::processing
        PathTracer["Path Tracer"]:::processing
        Animation["Animation System"]:::processing
    end
    click Geometry "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/geometry/halfedge.h"
    click Rasterizer "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/rasterizer/pipeline.h"
    click PathTracer "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/pathtracer/pathtracer.h"
    click Animation "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/animator.h"

    %% Animation Components
    subgraph AnimationComponents
        Skeleton["Skeleton System"]:::processing
        Particles["Particle System"]:::processing
        Animator["Animation Controller"]:::processing
    end
    click Skeleton "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/skeleton.h"
    click Particles "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/particles.h"
    click Animator "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/scene/animator.h"

    %% Support Systems
    subgraph SupportSystems
        MathLib["Math Library"]:::support
        Utils["Utilities"]:::support
    end
    click MathLib "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/lib/mathlib.h"
    click Utils "https://github.com/CMU-Graphics/Scotty3D/tree/main/src/util"

    %% Platform Layer
    subgraph PlatformLayer
        Platform["Platform Layer"]:::platform
        OpenGL["OpenGL Backend"]:::platform
    end
    click Platform "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/platform/platform.h"
    click OpenGL "https://github.com/CMU-Graphics/Scotty3D/blob/main/src/platform/gl.h"

    %% External Dependencies
    subgraph ExternalDeps
        ImGui["ImGui"]:::external
        SDL["SDL"]:::external
    end
    click ImGui "https://github.com/CMU-Graphics/Scotty3D/tree/main/deps/imgui"

    %% Testing Framework
    Testing["Testing Framework"]:::testing
    click Testing "https://github.com/CMU-Graphics/Scotty3D/tree/main/tests"

    %% Relationships
    MainEntry --> AppCore
    AppCore --> GUI
    AppCore --> SceneManagement
    
    SceneManagement --> SceneComponents
    SceneManagement --> ProcessingModules
    
    GUI --> ProcessingModules
    
    Animation --> AnimationComponents
    
    ProcessingModules --> SupportSystems
    AnimationComponents --> SupportSystems
    
    SupportSystems --> PlatformLayer
    PlatformLayer --> ExternalDeps
    
    Testing -.-> ProcessingModules
    Testing -.-> SceneComponents
    Testing -.-> SupportSystems

    %% Legend
    subgraph Legend
        CoreComp["Core Components"]:::core
        ProcComp["Processing Modules"]:::processing
        SuppComp["Support Systems"]:::support
        PlatComp["Platform Layer"]:::platform
        ExtComp["External Dependencies"]:::external
        TestComp["Testing"]:::testing
    end
```
