# absulit/points architecture

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

- Interactive diagram: https://gitdiagram.com/absulit/points
- Repository: https://github.com/absulit/points

## Overview

##### Main components
- Canvas & Application Bootstrap: At the entry-level, a webpage (HTML/JS) references a canvas element. The main JavaScript (e.g., main.js, index.html, examples) instantiates the main class (Points) and wires up the render loop.
- Points Core Library: This is the central module (src/absulit.points.module.js) that coordinates initializations, updates, and resource management. It forms the heart of the application.
- Resource Management: The library manages various types of resources such as:
- Uniforms, Samplers, and Textures (2D, image, video, webcam)
- Storage buffers and StorageMaps (for read-back or multi-frame data)
- Binding Textures (for communicating between compute and fragment shaders)
- Event & Feedback Mechanism: The system supports dispatching events from shaders back to JavaScript (e.g., through addEventListener) and passing data between shader passes.
- Examples and Demos: These serve as modules or “plug-ins” that demonstrate different effects, post-processing render passes, and custom shader projects.

##### Relationships and interactions
- RenderPasses as a sequential pipeline: Data from JavaScript is fed into the RenderPass (starting with a compute shader, then vertex, then passed to a fragment shader) before outputting to the screen.

##### Architectural patterns and design principles
- Modular design: Each shader and support module is self-contained, enabling developers to easily create custom rendering projects by changing or extending RenderPasses.
- Pipeline separation: The division between data setup (in JavaScript) and render passes (in shader code) shows clear separation of concerns.
- Reusability & Extensibility: Highlight how the RenderPass abstraction and dynamic module import (via JavaScript string interpolation) allow customizable, layered postprocessing effects.

##### Relevant technologies
- WebGPU and WGSL: As the project is built on WebGPU using shaders written in WGSL, these should be labeled.
- VSCode with WGSL Literal: Mention the development environment and syntax-highlighting configurations.
- JavaScript ES6 modules: Show that the project uses modern JavaScript modules for modularization including the legacy and examples systems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer: Canvas & Application Bootstrap
    subgraph "UI Layer: Canvas & Application Bootstrap"
        A1["index.html"]:::bootstrap
        A2["main.js"]:::bootstrap
    end

    %% Points Core Library
    B["Points Core Library"]:::core

    %% Render Pipeline Layer
    subgraph "Render Pipeline"
        subgraph "RenderPass Abstraction"
            RP1["RenderPass.js"]:::render
            RP2["RenderPasses.js"]:::render
        end
        subgraph "Shader Pipeline"
            C1["Compute Shader"]:::render
            C2["Vertex Shader"]:::render
            C3["Fragment Shader"]:::render
            C1 -->|"pipeline"| C2
            C2 -->|"pipeline"| C3
        end
    end

    %% Shader Modules & Support Libraries
    subgraph "Shader Modules & Support Libraries"
        D1["defaultFunctions.js"]:::shader
        D2["defaultConstants.js"]:::shader
        D3["defaultStructs.js"]:::shader
        D1 -->|"interpolates_to"| D2
        D2 -->|"interpolates_to"| D3
    end

    %% Resource Management
    subgraph "Resource Manager"
        E1["UniformKeys.js"]:::resource
        E2["VertexBufferInfo.js"]:::resource
        E1 -->|"provides"| E2
    end

    %% Event & Feedback Mechanism
    F["Event & Feedback Mechanism"]:::event

    %% External Modules
    G["Examples & Demos (examples/)"]:::external
    H["Legacy Support (legacy/)"]:::external
    I["External WebGPU Demos (webgpu_demo_reference/)"]:::external

    %% Connections
    A1 -->|"initializes"| B
    A2 -->|"initializes"| B

    B -->|"setup_RenderPass"| RP2
    RP2 -->|"initiate_pass"| C1

    D1 ---|"shader_interpolation"| C1
    E1 ---|"resource_injection"| C1

    B -->|"event_dispatch"| F
    B -->|"demo_integration"| G
    B -->|"legacy_compatibility"| H
    B -->|"external_assets"| I

    %% Click Events
    click A1 "https://github.com/absulit/points/blob/master/examples/index.html"
    click A2 "https://github.com/absulit/points/blob/master/examples/main.js"
    click B "https://github.com/absulit/points/blob/master/src/absulit.points.module.js"
    click RP1 "https://github.com/absulit/points/blob/master/src/RenderPass.js"
    click RP2 "https://github.com/absulit/points/blob/master/src/RenderPasses.js"
    click D1 "https://github.com/absulit/points/blob/master/src/core/defaultFunctions.js"
    click D2 "https://github.com/absulit/points/blob/master/src/core/defaultConstants.js"
    click D3 "https://github.com/absulit/points/blob/master/src/core/defaultStructs.js"
    click E1 "https://github.com/absulit/points/blob/master/src/UniformKeys.js"
    click E2 "https://github.com/absulit/points/blob/master/src/VertexBufferInfo.js"
    click G "https://github.com/absulit/points/tree/master/examples/"
    click H "https://github.com/absulit/points/tree/master/legacy/"
    click I "https://github.com/absulit/points/tree/master/webgpu_demo_reference/"

    %% Styles
    classDef bootstrap fill:#f9c,stroke:#333,stroke-width:2px;
    classDef core fill:#ccf,stroke:#333,stroke-width:2px;
    classDef render fill:#cfc,stroke:#333,stroke-width:2px;
    classDef shader fill:#fc9,stroke:#333,stroke-width:2px;
    classDef resource fill:#cff,stroke:#333,stroke-width:2px;
    classDef external fill:#ffc,stroke:#333,stroke-width:2px;
    classDef event fill:#fdd,stroke:#333,stroke-width:2px;
```
