# plutotcool/glsl-bundler architecture

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

- Interactive diagram: https://gitdiagram.com/plutotcool/glsl-bundler
- Repository: https://github.com/plutotcool/glsl-bundler

## Overview

##### Project type and purpose
- This is an open-source, JavaScript/TypeScript monorepo managed by Lerna.
- It provides a core GLSL shader “bundler” library that can run in Node or the browser, plus integrations (Rollup plugin, forthcoming Webpack loader) and a demo website built with Vite.

##### File structure
- Top-level:
– lerna.json, package.json, CHANGELOG.md, GitHub Actions workflows (.github/)
– packages/ – contains three sub-packages:
· glsl-bundler (core library)
· rollup-plugin-glsl (Rollup integration)
· website (demo site)
- Core library (packages/glsl-bundler):
– src/ – modules: bundler, loader, transpiler, minifier, writer, utils
– test/ – unit tests and fixtures for node & browser environments
– config files: tsconfig.json, rollup.config.js, jest.config.js, ESLint
- Plugin (packages/rollup-plugin-glsl):
– src/index.ts – uses core API
– test/fixtures – sample shaders
– config: rollup.config.js, jest.config.js, tsconfig.json
- Website (packages/website):
– src/index.ts, index.html, vite.config.ts – demonstrates plugin/core usage

##### README for additional insights
- Purpose: “Functional regex-based GLSL bundler, loader and minifier. Runs both on node and the browser.”
- Integrations: Rollup plugin, upcoming Webpack loader
- Live demo on Vercel

##### Detail
- Configuration files and test fixtures as part of the development pipeline.
- Build tools (Rollup, Vite) as separate processes that invoke adapters.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Source Input
    GLSL["GLSL Source Files"]:::source

    %% Core Library
    subgraph "Core Library" 
        direction TB
        CoreIndex["Entry Point<br/>(packages/glsl-bundler/src/index.ts)"]:::core
        Loader["Loader<br/>(loader.ts)"]:::core
        Bundler["Bundler<br/>(bundler.ts)"]:::core
        Transpiler["Transpiler<br/>(transpiler.ts)"]:::core
        Minifier["Minifier<br/>(minifier.ts)"]:::core
        Writer["Writer<br/>(writer.ts)"]:::core
        Utils["Utilities<br/>(utils.ts)"]:::core
        Tests["Unit Tests & Fixtures<br/>(packages/glsl-bundler/test/)"]:::test
    end

    %% Adapters / Plugins
    subgraph "Adapters / Integrations"
        direction TB
        RollupPlugin["Rollup Plugin<br/>(packages/rollup-plugin-glsl/src/index.ts)"]:::adapter
        WebpackLoader["Future Webpack Loader"]:::adapter
    end

    %% Consumers
    subgraph "Consumers"
        direction TB
        CLI["CLI/Node API"]:::consumer
        BrowserAPI["Browser API"]:::consumer
        subgraph "Demo Website"
            direction TB
            HTML["HTML Template<br/>(packages/website/src/index.html)"]:::consumer
            WebsiteIndex["App Entry Point<br/>(packages/website/src/index.ts)"]:::consumer
            ViteConfig["Vite Config<br/>(packages/website/vite.config.ts)"]:::consumer
            ViteBuild["Vite Build Pipeline"]:::consumer
        end
    end

    %% CI/CD
    subgraph "CI/CD - GitHub Actions"
        direction TB
        LernaConfig["Lerna Monorepo Config<br/>(lerna.json)"]:::config
        BuildWF["Build Workflow<br/>(.github/workflows/build.yml)"]:::ci
        TestWF["Test Workflow<br/>(.github/workflows/test.yml)"]:::ci
        ReleaseWF["Release Workflow<br/>(.github/workflows/release.yml)"]:::ci
    end

    %% Deployment
    Vercel["Vercel Deployment"]:::hosting
    Npm["npm Registry"]:::hosting

    %% Data Flow
    GLSL -->|parses| Loader
    Loader -->|imports| Bundler
    Bundler -->|transpile| Transpiler
    Transpiler -->|minify| Minifier
    Minifier -->|format| Writer
    Writer --> Bundled["Bundled GLSL Output"]:::output

    %% Core entry usage
    CLI -->|uses| CoreIndex
    BrowserAPI -->|uses| CoreIndex

    %% Plugin integration
    RollupPlugin -->|invokes core API| CoreIndex
    WebpackLoader -->|invokes core API| CoreIndex

    %% Demo pipeline
    ViteBuild -->|uses plugin| RollupPlugin
    HTML --> WebsiteIndex
    WebsiteIndex -->|build| ViteBuild
    ViteBuild --> Bundled

    %% CI/CD flows
    LernaConfig --> BuildWF
    LernaConfig --> TestWF
    BuildWF --> ReleaseWF
    TestWF --> ReleaseWF
    ReleaseWF --> Npm
    ReleaseWF --> Vercel

    %% Click Events
    click CoreIndex "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/index.ts"
    click Loader "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/loader.ts"
    click Bundler "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/bundler.ts"
    click Transpiler "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/transpiler.ts"
    click Minifier "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/minifier.ts"
    click Writer "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/writer.ts"
    click Utils "https://github.com/plutotcool/glsl-bundler/blob/main/packages/glsl-bundler/src/utils.ts"
    click Tests "https://github.com/plutotcool/glsl-bundler/tree/main/packages/glsl-bundler/test/"
    click LernaConfig "https://github.com/plutotcool/glsl-bundler/blob/main/lerna.json"
    click RollupPlugin "https://github.com/plutotcool/glsl-bundler/blob/main/packages/rollup-plugin-glsl/src/index.ts"
    click BuildWF "https://github.com/plutotcool/glsl-bundler/blob/main/.github/workflows/build.yml"
    click TestWF "https://github.com/plutotcool/glsl-bundler/blob/main/.github/workflows/test.yml"
    click ReleaseWF "https://github.com/plutotcool/glsl-bundler/blob/main/.github/workflows/release.yml"
    click HTML "https://github.com/plutotcool/glsl-bundler/blob/main/packages/website/src/index.html"
    click WebsiteIndex "https://github.com/plutotcool/glsl-bundler/blob/main/packages/website/src/index.ts"
    click ViteConfig "https://github.com/plutotcool/glsl-bundler/blob/main/packages/website/vite.config.ts"
    click RollupPlugin "https://github.com/plutotcool/glsl-bundler/blob/main/packages/rollup-plugin-glsl/src/index.ts"
    click Tests "https://github.com/plutotcool/glsl-bundler/tree/main/packages/rollup-plugin-glsl/test/"
    click BuildWF "https://github.com/plutotcool/glsl-bundler/blob/main/.github/workflows/build.yml"
    click TestWF "https://github.com/plutotcool/glsl-bundler/blob/main/.github/workflows/test.yml"
    click ReleaseWF "https://github.com/plutotcool/glsl-bundler/blob/main/.github/workflows/release.yml"

    %% Styles
    classDef source fill:#f9f,stroke:#333,stroke-width:1px
    classDef core fill:#bbf,stroke:#333,stroke-width:1px
    classDef adapter fill:#bfb,stroke:#333,stroke-width:1px
    classDef consumer fill:#fbf,stroke:#333,stroke-width:1px
    classDef test fill:#ffb,stroke:#333,stroke-width:1px
    classDef config fill:#ddf,stroke:#333,stroke-width:1px
    classDef ci fill:#fdd,stroke:#333,stroke-width:1px
    classDef hosting fill:#dfd,stroke:#333,stroke-width:1px
    classDef output fill:#ffd,stroke:#333,stroke-width:1px
```
