# nerfstudio-project/gsplat architecture

> Architecture diagram of the GitHub repository nerfstudio-project/gsplat, 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/nerfstudio-project/gsplat
- Repository: https://github.com/nerfstudio-project/gsplat

## Overview

##### Main Components

a. Core Components:
- Python API Layer
- CUDA Backend
- Optimization Components
- Compression System
- Strategy System
- Rendering Pipeline

b. Key Integration Points:
- PyTorch Integration
- CUDA Runtime
- External Tools Integration (COLMAP)

**Application Layer (Top)**

**Interface Layer**

**Core Processing Layer**

**CUDA Implementation Layer (Bottom)**

##### Specific Component Details

a. Application Layer:
- Example applications (image_fitting.py, simple_trainer.py, simple_viewer.py)
- To the Interface Layer

b. Interface Layer:
- Main Python modules (__init__.py, rendering.py)
- Strategy patterns (strategy/*)
- Compression utilities (compression/*)

c. Core Processing Layer:
- Optimization components (optimizers/*)
- Rasterization pipeline
- Utility functions

d. CUDA Implementation Layer:
- CUDA kernels (cuda/csrc/*)
- Memory management
- Computational graphs

##### Critical Relationships to Highlight

a. Data Flow:
- Input data → Gaussian representation
- Gaussian processing → Rasterization
- Rasterization → Output rendering

b. Control Flow:
- Strategy selection → Optimization process
- Memory management → CUDA kernels
- Python bindings → CUDA implementation

##### Implementation Details

- Double lines for high-bandwidth data paths
- Hexagons for CUDA kernels
- Diamonds for decision points

##### Key Features to Emphasize

- CUDA acceleration pathways
- Memory optimization techniques
- Python-CUDA interaction points
- Gaussian splatting pipeline stages
- Optimization strategies

##### Documentation Integration

References to:
- API documentation locations
- Example code paths
- Benchmark results
- Testing frameworks

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph AL["Application Layer"]
        direction TB
        EX1["Image Fitting"]:::example
        EX2["Simple Trainer"]:::example
        EX3["Simple Viewer"]:::example
    end

    subgraph IL["Interface Layer"]
        direction TB
        API["Python API"]:::api
        STRAT["Strategy System"]:::strategy
        COMP["Compression System"]:::compression
        DIST["Distributed Processing"]:::dist
        PROF["Profiling System"]:::prof
        UTIL["Core Utilities"]:::util
    end

    subgraph CPL["Core Processing Layer"]
        direction TB
        OPT["Optimization Components"]:::opt
        RAST["Rasterization Pipeline"]:::rast
        MEM["Memory Management"]:::mem
    end

    subgraph CUDA["CUDA Implementation Layer"]
        direction TB
        KERN["CUDA Kernels"]:::cuda
        PROJ["Projection Module"]:::cuda
        RPIX["Rasterization Module"]:::cuda
    end

    subgraph TEST["Testing Framework"]
        direction TB
        UNIT["Unit Tests"]:::test
        INT["Integration Tests"]:::test
    end

    %% Connections
    AL --> IL
    IL --> CPL
    CPL --> CUDA
    IL --> TEST
    CUDA --> TEST

    %% Detailed connections
    API --> OPT
    API --> RAST
    STRAT --> OPT
    COMP --> MEM
    OPT --> KERN
    RAST --> PROJ
    RAST --> RPIX
    MEM --> KERN

    %% Click events
    click EX1 "https://github.com/nerfstudio-project/gsplat/blob/main/examples/image_fitting.py"
    click EX2 "https://github.com/nerfstudio-project/gsplat/blob/main/examples/simple_trainer.py"
    click EX3 "https://github.com/nerfstudio-project/gsplat/blob/main/examples/simple_viewer.py"
    click API "https://github.com/nerfstudio-project/gsplat/blob/main/gsplat/__init__.py"
    click STRAT "https://github.com/nerfstudio-project/gsplat/tree/main/gsplat/strategy/"
    click COMP "https://github.com/nerfstudio-project/gsplat/tree/main/gsplat/compression/"
    click DIST "https://github.com/nerfstudio-project/gsplat/blob/main/gsplat/distributed.py"
    click PROF "https://github.com/nerfstudio-project/gsplat/blob/main/gsplat/profile.py"
    click UTIL "https://github.com/nerfstudio-project/gsplat/blob/main/gsplat/utils.py"
    click OPT "https://github.com/nerfstudio-project/gsplat/tree/main/gsplat/optimizers/"
    click KERN "https://github.com/nerfstudio-project/gsplat/tree/main/gsplat/cuda/csrc/"
    click PROJ "https://github.com/nerfstudio-project/gsplat/blob/main/gsplat/cuda/csrc/proj_fwd.cu"
    click RPIX "https://github.com/nerfstudio-project/gsplat/blob/main/gsplat/cuda/csrc/rasterize_to_pixels_fwd.cu"
    click TEST "https://github.com/nerfstudio-project/gsplat/tree/main/tests/"

    %% Styling
    classDef example fill:#f9f,stroke:#333,stroke-width:2px
    classDef api fill:#9cf,stroke:#333,stroke-width:2px
    classDef strategy fill:#ff9,stroke:#333,stroke-width:2px
    classDef compression fill:#9f9,stroke:#333,stroke-width:2px
    classDef dist fill:#f99,stroke:#333,stroke-width:2px
    classDef prof fill:#99f,stroke:#333,stroke-width:2px
    classDef util fill:#ddd,stroke:#333,stroke-width:2px
    classDef opt fill:#ff9,stroke:#333,stroke-width:2px
    classDef rast fill:#f99,stroke:#333,stroke-width:2px
    classDef mem fill:#9f9,stroke:#333,stroke-width:2px
    classDef cuda fill:#9cf,stroke:#333,stroke-width:2px
    classDef test fill:#ddd,stroke:#333,stroke-width:2px
```
