# playcanvas/supersplat architecture

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

- Interactive diagram: https://gitdiagram.com/playcanvas/supersplat
- Repository: https://github.com/playcanvas/supersplat

## Overview

##### Project Type and Purpose

**Project Type:**
SuperSplat is a **web-based full-stack application** designed for creating, editing, optimizing, and publishing 3D Gaussian Splats. It leverages modern web technologies to provide a seamless experience directly in the browser, eliminating the need for downloads or installations.

**Purpose:**
The tool serves artists and developers working with 3D splat data, offering functionalities such as inspection, editing, optimization, and publishing of 3D Gaussian Splats. Its real-time capabilities and browser-based deployment make it accessible and efficient for collaborative and individual workflows.

##### Top-Level Directories and Files
- **.github:** Contains GitHub workflows for continuous integration (`ci.yml`).
- **docs:** Documentation files, including `index.md`.
- **src:** Core source code of the application.
- **anim, shaders, serialize, tools, ui:** Subdirectories indicating modular architecture.
- **index.html, main.ts, index.ts, etc.:** Entry points and main application files.
- **Configuration Files:** `package.json`, `rollup.config.mjs`, `tsconfig.json`, `eslint.config.mjs`, etc., indicating a robust build and development setup.

##### Architectural Patterns
- **Modular Architecture:** Subdirectories within `src` (e.g., `anim`, `shaders`, `tools`, `ui`) suggest a component-based structure, promoting reusability and maintainability.
- **Service Workers:** Presence of `src/sw.ts` indicates the use of service workers for offline capabilities and caching.
- **Build and Deployment:** Use of Rollup (`rollup.config.mjs`) for bundling, ESLint for linting, and GitHub Actions for CI/CD.

##### README for Additional Insights

The README highlights that SuperSplat is built with **web technologies** and runs entirely in the browser. It outlines the setup for local development using Node.js and includes instructions for live-reloading during development. The absence of backend-specific instructions suggests that the application is primarily frontend-focused, possibly utilizing serverless functions or relying entirely on client-side processing.

##### a. Main Components of the System
- **Frontend Application:**
- **UI Module:** Manages user interfaces such as toolbars, panels, dialogs (`src/ui`).
- **Core Functionality Modules:** Handle animations (`src/anim`), shaders (`src/shaders`), serialization (`src/serialize`), tools (`src/tools`), and more.
- **Build Tools:**
- **Rollup:** Bundles JavaScript and TypeScript files.
- **ESLint & Prettier:** Enforce code quality and formatting.
- **Service Worker:** Manages caching and offline capabilities (`src/sw.ts`).
- **Continuous Integration:**
- **GitHub Workflows:** Automates testing and deployment (`.github/workflows/ci.yml`).

##### b. Relationships and Interactions Between Components
- **UI Module** interacts with **Core Functionality Modules** to reflect user actions and updates.
- **Core Functionality Modules** communicate with **Shaders** for rendering and **Serialization** for data handling.
- **Service Worker** intercepts network requests to cache assets and provide offline support.
- **Build Tools** process and bundle code from `src` and manage dependencies from `static/lib`.
- **CI Workflows** automate testing and deployment processes upon code commits.

##### c. Architectural Patterns or Design Principles
- **Component-Based Architecture:** Facilitates separation of concerns and modularity.
- **Single Page Application (SPA):** Ensures seamless user experience without full page reloads.
- **Progressive Web App (PWA):** Utilizes service workers for offline functionality and improved performance.
- **TypeScript Usage:** Enhances code reliability and maintainability through static typing.

##### d. Relevant Technologies, Frameworks, or Libraries
- **Languages and Frameworks:** TypeScript, JavaScript, HTML, CSS.
- **Build Tools:** Rollup, ESLint, Prettier.
- **Libraries:** WebGL for rendering shaders, various UI libraries within `src/ui`.
- **Service Workers:** For caching and offline capabilities.
- **Version Control and CI:** GitHub Actions for continuous integration.

##### Frontend Layer
- **UI Components**
- Toolbar
- Panels
- Dialogs
- **Core Functionality**
- Animation Module
- Shader Management
- Tools (e.g., Brush, Lasso, Move)
- Serialization and Data Processing

##### Infrastructure Layer
- **Build Tools**
- Rollup Bundler
- ESLint and Prettier
- **Service Workers**
- Caching Strategy
- Offline Support

##### Asset Management
- **Static Assets**
- Third-Party Libraries

##### Continuous Integration
- **GitHub Workflows**
- CI Pipelines
- Automated Testing

##### Deployment
- **Live Application**
- Hosting Details (e.g., GitHub Pages, Netlify)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Global entities
    subgraph "Frontend Layer"
        UIM["UI Module"]:::frontend
        AnimM["Animation Module"]:::core
        ShaderM["Shader Management"]:::core
        SerializeM["Serialization Module"]:::core
        ToolsM["Tools Module"]:::core
    end

    subgraph "Infrastructure Layer"
        Rollup["Rollup Bundler"]:::build
        ESLint["ESLint & Prettier"]:::build
        SW["Service Worker"]:::service
    end

    subgraph "Asset Management"
        Static["Static Assets"]:::assets
    end

    subgraph "Continuous Integration"
        CI["GitHub Workflows"]:::ci
    end

    subgraph "Deployment"
        LiveApp["Live Application"]:::deploy
    end

    %% Connections
    UIM --> AnimM
    UIM --> ShaderM
    UIM --> SerializeM
    UIM --> ToolsM

    AnimM --> ShaderM
    ShaderM --> SerializeM
    ToolsM --> SerializeM

    Rollup --> UIM
    Rollup --> AnimM
    Rollup --> ShaderM
    Rollup --> SerializeM
    Rollup --> ToolsM

    ESLint --> Rollup

    SW --> Static
    SW --> Rollup

    Static --> Rollup

    CI --> Rollup
    CI --> ESLint

    Rollup --> LiveApp
    ESLint --> LiveApp
    SW --> LiveApp
    Static --> LiveApp

    %% Click Events
    click UIM "https://github.com/playcanvas/supersplat/tree/main/src/ui"
    click AnimM "https://github.com/playcanvas/supersplat/tree/main/src/anim"
    click ShaderM "https://github.com/playcanvas/supersplat/tree/main/src/shaders"
    click SerializeM "https://github.com/playcanvas/supersplat/tree/main/src/serialize"
    click ToolsM "https://github.com/playcanvas/supersplat/tree/main/src/tools"
    click SW "https://github.com/playcanvas/supersplat/blob/main/src/sw.ts"
    click Rollup "https://github.com/playcanvas/supersplat/blob/main/rollup.config.mjs"
    click ESLint "https://github.com/playcanvas/supersplat/blob/main/eslint.config.mjs"
    click Static "https://github.com/playcanvas/supersplat/tree/main/static/"
    click CI "https://github.com/playcanvas/supersplat/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef frontend fill:#1f77b4,stroke:#333,stroke-width:2px;
    classDef core fill:#aec7e8,stroke:#333,stroke-width:2px;
    classDef service fill:#2ca02c,stroke:#333,stroke-width:2px,shape:hexagon;
    classDef build fill:#ff7f0e,stroke:#333,stroke-width:2px;
    classDef ci fill:#9467bd,stroke:#333,stroke-width:2px;
    classDef assets fill:#7f7f7f,stroke:#333,stroke-width:2px,shape:cylinder;
    classDef deploy fill:#8c564b,stroke:#333,stroke-width:2px;
    
    class UIM frontend
    class AnimM,ShaderM,SerializeM,ToolsM core
    class SW service
    class Rollup,ESLint build
    class CI ci
    class Static assets
    class LiveApp deploy
```
