# magcius/noclip.website architecture

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

- Interactive diagram: https://gitdiagram.com/magcius/noclip.website
- Repository: https://github.com/magcius/noclip.website

## Overview

##### Main System Components

a) Frontend Layer
- Web Interface (src/viewer.ts, src/ui.ts)
- Input Management (src/InputManager.ts)
- Camera Controls (src/Camera.ts)
- Scene Management (src/SceneBase.ts)

b) Core Engine Layer
- Graphics Pipeline
- WebGL2/WebGPU Renderers (src/gfx/platform/)
- Render Graph System (src/gfx/render/)
- Shader Compilation (src/gfx/shaderc/)
- Material System (src/gx/)

c) Game Support Layer
- Game-Specific Implementations
- Multiple game folders (src/SuperMarioGalaxy/, src/ZeldaWindWaker/, etc.)
- Format Parsers
- Scene Renderers

d) Asset Processing Layer
- Texture Processing (src/TextureHolder.ts)
- Model Processing
- Animation Systems
- Compression Handlers (src/Common/Compression/)

##### Key Relationships to Highlight

- Data flow from game files through asset processing to rendering
- User input flow through the input manager to camera and scene control
- Render pipeline flow from scene graph through graphics API
- Resource management between asset processing and rendering systems

##### Technical Details

Create dedicated sections for:
- Graphics API abstraction (WebGL2/WebGPU)
- File format support (multiple game formats)
- Scene rendering pipeline
- Asset management system
- Input handling system

##### Component Relationships

Show:
- How the Rust components (rust/) integrate with the TypeScript frontend
- WebAssembly bridge points (various *_wasm.ts files)
- Resource loading and caching pathways
- Scene graph hierarchy

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef game fill:#e67e22,stroke:#d35400,color:white
    classDef asset fill:#9b59b6,stroke:#8e44ad,color:white
    classDef graphics fill:#e74c3c,stroke:#c0392b,color:white

    %% Frontend Layer
    subgraph Frontend
        WebUI["Web Interface"]
        InputMgr["Input Management"]
        CamCtrl["Camera Controls"]
        SceneMgmt["Scene Management"]
    end

    %% Core Engine Layer
    subgraph CoreEngine
        subgraph Graphics
            WebGL["WebGL2 Renderer"]
            WebGPU["WebGPU Renderer"]
            RenderGraph["Render Graph System"]
            ShaderComp["Shader Compilation"]
        end
        
        subgraph Materials
            MatSystem["Material System"]
        end
    end

    %% Game Support Layer
    subgraph GameSupport
        SMG["Super Mario Galaxy"]
        WW["Wind Waker"]
        MP["Metroid Prime"]
        DS["Dark Souls"]
    end

    %% Asset Processing Layer
    subgraph AssetProcessing
        TexProc["Texture Processing"]
        AnimSys["Animation Systems"]
        
        subgraph Compression
            LZ4["LZ4"]
            LZMA["LZMA"]
            Yaz0["Yaz0"]
            Deflate["Deflate"]
        end
    end

    %% Relationships
    WebUI --> InputMgr
    InputMgr --> CamCtrl
    CamCtrl --> SceneMgmt
    SceneMgmt --> RenderGraph
    
    RenderGraph --> WebGL
    RenderGraph --> WebGPU
    ShaderComp --> RenderGraph
    MatSystem --> RenderGraph
    
    GameSupport --> AssetProcessing
    AssetProcessing --> CoreEngine
    
    %% Click Events
    click WebUI "https://github.com/magcius/noclip.website/blob/main/src/viewer.ts"
    click InputMgr "https://github.com/magcius/noclip.website/blob/main/src/InputManager.ts"
    click CamCtrl "https://github.com/magcius/noclip.website/blob/main/src/Camera.ts"
    click SceneMgmt "https://github.com/magcius/noclip.website/blob/main/src/SceneBase.ts"
    
    click WebGL "https://github.com/magcius/noclip.website/blob/main/src/gfx/platform/GfxPlatformWebGL2.ts"
    click WebGPU "https://github.com/magcius/noclip.website/blob/main/src/gfx/platform/GfxPlatformWebGPU.ts"
    click RenderGraph "https://github.com/magcius/noclip.website/blob/main/src/gfx/render/GfxRenderGraph.ts"
    click ShaderComp "https://github.com/magcius/noclip.website/blob/main/src/gfx/shaderc/GfxShaderCompiler.ts"
    click MatSystem "https://github.com/magcius/noclip.website/blob/main/src/gx/GXMaterialBuilder.ts"
    
    click SMG "https://github.com/magcius/noclip.website/tree/main/src/SuperMarioGalaxy/"
    click WW "https://github.com/magcius/noclip.website/tree/main/src/ZeldaWindWaker/"
    click MP "https://github.com/magcius/noclip.website/tree/main/src/MetroidPrime/"
    click DS "https://github.com/magcius/noclip.website/tree/main/src/DarkSouls/"
    
    click TexProc "https://github.com/magcius/noclip.website/blob/main/src/TextureHolder.ts"
    click AnimSys "https://github.com/magcius/noclip.website/blob/main/src/AnimationController.ts"
    click LZ4 "https://github.com/magcius/noclip.website/blob/main/src/Common/Compression/LZ4.ts"
    click LZMA "https://github.com/magcius/noclip.website/blob/main/src/Common/Compression/LZMA.ts"
    click Yaz0 "https://github.com/magcius/noclip.website/blob/main/src/Common/Compression/Yaz0.ts"
    click Deflate "https://github.com/magcius/noclip.website/blob/main/src/Common/Compression/Deflate.ts"

    %% Style Applications
    class WebUI,InputMgr,CamCtrl,SceneMgmt frontend
    class WebGL,WebGPU,RenderGraph,ShaderComp graphics
    class MatSystem core
    class SMG,WW,MP,DS game
    class TexProc,AnimSys,LZ4,LZMA,Yaz0,Deflate asset

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Components"]
        Core_L["Core Components"]
        Game_L["Game Components"]
        Asset_L["Asset Components"]
        Graphics_L["Graphics Components"]
    end
    
    class Frontend_L frontend
    class Core_L core
    class Game_L game
    class Asset_L asset
    class Graphics_L graphics
```
