# dotpys/pgal architecture

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

- Interactive diagram: https://gitdiagram.com/dotpys/pgal
- Repository: https://github.com/dotpys/pgal

## Overview

##### Project Type and Purpose
- PGAL is a Procedural Generation Algorithm Library consisting of several C# class-library modules (PerlinNoise, SimplexNoise, RandomExtensions) plus two “consumer” applications:
– Benchmark (console app to measure PRNG & noise performance)
- Primary use cases:
– Provide reusable noise and PRNG algorithms to .NET developers.
– Allow live experimentation via the WebShowcase.
– Benchmark performance of different generators and algorithms.

##### File Structure
Top-level solution (PGAL.sln) includes five projects:
- RandomExtensions – core PRNG implementations (SplitMix64, Xoshiro variants).
- PerlinNoise – 2D/3D Perlin-noise algorithms, depends on RandomExtensions.
- SimplexNoise – Simplex-noise implementation, depends on RandomExtensions.
- Benchmark – console app referencing RandomExtensions and PerlinNoise/SimplexNoise for performance tests.
- WebShowcase – Blazor WASM app referencing PerlinNoise, SimplexNoise (and future Voronoi), with its own Node/TypeScript build pipeline and static wwwroot assets.
Build and deployment assets:
- .github/workflows/main.yml – CI build/test/deploy pipeline.
- package.json, tsconfig.json – front-end toolchain for WebShowcase.
- wwwroot/dist – compiled JS/TS graphics utilities (matrix.js).

##### README for Insights
- Lists supported algorithms (Perlin 2D/3D, Simplex) and future work (Voronoi).
- Provides a live demo link, indicating the need for static hosting of the Blazor app.

##### Main Components and Their Relationships
A. Core Library Layer
– RandomExtensions (PRNGs)
– PerlinNoise & SimplexNoise (depend on RandomExtensions)
B. Consumer Apps
– Benchmark Console App (references Core Library Layer)
– WebShowcase Blazor App (references Core Library Layer)
C. Front-end Build Pipeline (for WebShowcase)
– Node.js, TypeScript → compile matrix.js → output to wwwroot/dist
D. Deployment/CI
– GitHub Actions orchestrates build/test for all .NET projects and publishes WebShowcase to GitHub Pages.

##### Architectural Patterns and Principles
- Layered architecture: clear separation between algorithm libraries and apps that consume them.
- Single repository monolith with multiple .csproj projects – fosters coordinated versioning and CI.
- Blazor WebAssembly front-end: C# runs in-browser; static assets served by GitHub Pages.
- Build pipelines: MSBuild for .NET, npm/tsc for TypeScript assets.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Library Layer
    subgraph "Core Library Layer"
        direction TB
        RExt["RandomExtensions\n(Core PRNG Library)"]:::lib
        PN["PerlinNoise\n(2D/3D Algorithms)"]:::lib
        SN["SimplexNoise\n(Simplex Algorithm)"]:::lib
    end

    RExt -->|"depends on"| PN
    RExt -->|"depends on"| SN

    %% Consumer Applications
    subgraph "Consumer Applications"
        direction TB
        Benchmark["Benchmark\n(Console App)"]:::app
        WebShowcase["WebShowcase\n(Blazor WASM App)"]:::app
    end

    Benchmark -->|"references"| PN
    Benchmark -->|"references"| SN

    WebShowcase -->|"references"| PN
    WebShowcase -->|"references"| SN
    WebShowcase -->|"uses"| RExt

    %% Front-end Build Subsystem
    subgraph "Front-end Build Subsystem" 
        direction TB
        NodeTS["Node.js/TypeScript Toolchain"]:::tool
        MatrixBuild["matrix.ts → wwwroot/dist"]:::tool
    end

    NodeTS -->|"compiles"| MatrixBuild
    MatrixBuild -->|"outputs to"| WebShowcase

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GHActions["GitHub Actions\n(CI/CD)"]:::ci
    end

    GHActions -->|"builds & tests"| RExt
    GHActions -->|"builds & tests"| PN
    GHActions -->|"builds & tests"| SN
    GHActions -->|"builds & tests"| Benchmark
    GHActions -->|"builds & tests"| WebShowcase
    GHActions -->|"deploys"| WebShowcase

    %% Click Events
    click RExt "https://github.com/dotpys/pgal/blob/main/RandomExtensions/RandomExtensions.csproj"
    click PN "https://github.com/dotpys/pgal/blob/main/PerlinNoise/PerlinNoise.csproj"
    click SN "https://github.com/dotpys/pgal/blob/main/SimplexNoise/SimplexNoise.csproj"
    click Benchmark "https://github.com/dotpys/pgal/blob/main/Benchmark/Benchmark.csproj"
    click WebShowcase "https://github.com/dotpys/pgal/blob/main/WebShowcase/WebShowcase.csproj"
    click NodeTS "https://github.com/dotpys/pgal/blob/main/WebShowcase/package.json"
    click MatrixBuild "https://github.com/dotpys/pgal/blob/main/WebShowcase/typescript/matrix.ts"
    click GHActions "https://github.com/dotpys/pgal/blob/main/.github/workflows/main.yml"

    %% Styling
    classDef lib fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef app fill:#90EE90,stroke:#000,stroke-width:1px
    classDef tool fill:#FFD700,stroke:#000,stroke-width:1px
    classDef ci fill:#D3D3D3,stroke:#000,stroke-width:1px
```
