# joaquinlarroca/pizzajs architecture

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

- Interactive diagram: https://gitdiagram.com/joaquinlarroca/pizzajs
- Repository: https://github.com/joaquinlarroca/pizzajs

## Overview

##### Project type and purpose
- It also ships with a template “starter” project, a suite of HTML/JS example tests, and a full documentation site generated via MkDocs (and optionally Jekyll via GitHub Pages).

##### File structure
- **source/**
- Core ES-modules under `source/modules/`:
– `global.js` (shared state, helpers)
– `functions.js` (drawing, loading, setup)
– `classes.js` (actors, buttons, hitboxes, sliders, timeouts, etc.)
– `listener.js` (keyboard/mouse/resize listeners)
- -ons under `source/Addons/` (particle, miniMonitor, localstorage, etc.)
- **template/project/**
- A ready-to-rename starter project that brings in PizzaJS modules.
- **mkdocs/** + **docs/**
- Markdown docs in `mkdocs/docs/` → built by MkDocs into HTML under `docs/`.
- Custom overrides, scripts, assets for search & rendering.
- **.github/**
- CI workflow (`jekyll-docker.yml`) to build & deploy the docs as a GitHub Pages site.
- **tests/**
- A collection of self-contained HTML/JS examples verifying different features.

##### README insights
- Emphasizes usage: import modules or all at once, call `initLoaderCheck()`, then use `setup()`, `start()`.
- Points to the template project for bootstrapping.
- Documentation site is live via GitHub Pages.
- CI badge shows automated docs deployment.

##### Main components & relationships
a. **Core Library Modules** (source/modules + source/Addons)
b. **Client Project** (template/project renamed by user)
c. **Example/Test Suite** (tests folder)
d. **Documentation Pipeline**
- MkDocs transforms Markdown → static HTML
- Placed under `docs/`
- GitHub Actions (jekyll-docker.yml) picks up `docs/` and pushes to Pages
e. **CI/CD** (GitHub Actions)
f. **External Services** (GitHub Pages for hosting documentation)

##### Architectural patterns & design principles
- **Modularity**: ES-module boundaries separate responsibilities (global vs functions vs classes vs listeners).
- **Extensibility**: Add-ons folder can inject new behaviors.
- **Separation of concerns**: Template project is decoupled from core source via import statements.
- **Static site generation**: MkDocs pipeline plus optional Jekyll for theming.

##### Relevant technologies/frameworks/libraries
- JavaScript ES-Modules
- CSS for styling
- MkDocs (Python-based static site generator)
- GitHub Actions for CI/CD
- GitHub Pages for hosting docs

- ES-Modules (global.js, functions.js, classes.js, listener.js)
- -ons (DefaultScreenshot, miniMonitor, etc.)
5. Technologies alongside each component.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Workspace
    subgraph "Development Workspace"
        direction TB
        subgraph "PizzaJS Library"
            direction TB
            PL_INDEX["index.js"]:::core
            PL_GLOBAL["global.js"]:::core
            PL_FUNCTIONS["functions.js"]:::core
            PL_CLASSES["classes.js"]:::core
            PL_LISTENER["listener.js"]:::core
            subgraph "Add-ons"
                direction TB
                ADD_SS["DefaultScreenshot.js"]:::core
                ADD_LS["localstorage.js"]:::core
                ADD_MM["miniMonitor.js"]:::core
                ADD_MI["mouseInfo.js"]:::core
                ADD_P["particle.js"]:::core
            end
        end

        subgraph "Template Starter Project"
            direction TB
            TP_HTML["index.html"]:::template
            TP_MAIN["main.js"]:::template
            subgraph "source/modules"
                direction TB
                TMP_MOD_INDEX["index.js"]:::template
                TMP_MOD_GLOBAL["global.js"]:::template
                TMP_MOD_FUNCS["functions.js"]:::template
                TMP_MOD_CLASSES["classes.js"]:::template
                TMP_MOD_LISTENER["listener.js"]:::template
            end
            subgraph "source/Addons"
                direction TB
                TMP_ADD_SS["DefaultScreenshot.js"]:::template
                TMP_ADD_LS["localstorage.js"]:::template
                TMP_ADD_MM["miniMonitor.js"]:::template
                TMP_ADD_MI["mouseInfo.js"]:::template
                TMP_ADD_P["particle.js"]:::template
            end
            TP_CSS["main.css"]:::template
            TP_FONTS["FiraCode"]:::template
            TP_ICONS["icons/"]:::template
            TP_IMAGES["images/"]:::template
        end

        subgraph "Example/Test Suite"
            direction TB
            TEST_COLL["tests/collision/"]:::tests
            TEST_COP["tests/copilot-code/"]:::tests
            TEST_FF["tests/fitFont/"]:::tests
            TEST_MAIN["tests/main/"]:::tests
            TEST_MK["tests/mkdocs examples/"]:::tests
            TEST_RS["tests/round+stroke/"]:::tests
            TEST_TIME["tests/time/"]:::tests
        end
    end

    %% Documentation Pipeline
    subgraph "Documentation"
        direction TB
        DOC_MD["mkdocs/docs/ (Markdown)"]:::docs
        MKDOCS["MkDocs Build"]:::docs
        DOC_HTML["docs/ (Generated HTML)"]:::docs
    end

    %% Infrastructure
    subgraph "Infrastructure"
        direction TB
        CI[".github/workflows/jekyll-docker.yml"]:::infra
        GH_PAGES["GitHub Pages"]:::infra
    end

    %% Relationships
    PL_INDEX -->|"imports"| TP_HTML
    PL_GLOBAL -->|"imports"| TP_HTML
    PL_FUNCTIONS -->|"imports"| TP_HTML
    PL_CLASSES -->|"imports"| TP_HTML
    PL_LISTENER -->|"imports"| TP_HTML
    ADD_SS -->|"imports"| TP_HTML
    ADD_LS -->|"imports"| TP_HTML
    ADD_MM -->|"imports"| TP_HTML
    ADD_MI -->|"imports"| TP_HTML
    ADD_P -->|"imports"| TP_HTML

    PL_INDEX -->|"imports"| TEST_COLL
    PL_INDEX -->|"imports"| TEST_COP
    PL_INDEX -->|"imports"| TEST_FF
    PL_INDEX -->|"imports"| TEST_MAIN
    PL_INDEX -->|"imports"| TEST_MK
    PL_INDEX -->|"imports"| TEST_RS
    PL_INDEX -->|"imports"| TEST_TIME

    DOC_MD -->|"builds"| MKDOCS
    MKDOCS -->|"outputs"| DOC_HTML
    DOC_HTML -->|"deployed by"| CI
    CI -->|"publishes to"| GH_PAGES

    %% Click Events - Core Library
    click PL_INDEX "https://github.com/joaquinlarroca/pizzajs/blob/main/source/modules/index.js"
    click PL_GLOBAL "https://github.com/joaquinlarroca/pizzajs/blob/main/source/modules/global.js"
    click PL_FUNCTIONS "https://github.com/joaquinlarroca/pizzajs/blob/main/source/modules/functions.js"
    click PL_CLASSES "https://github.com/joaquinlarroca/pizzajs/blob/main/source/modules/classes.js"
    click PL_LISTENER "https://github.com/joaquinlarroca/pizzajs/blob/main/source/modules/listener.js"
    click ADD_SS "https://github.com/joaquinlarroca/pizzajs/blob/main/source/Addons/DefaultScreenshot.js"
    click ADD_LS "https://github.com/joaquinlarroca/pizzajs/blob/main/source/Addons/localstorage.js"
    click ADD_MM "https://github.com/joaquinlarroca/pizzajs/blob/main/source/Addons/miniMonitor.js"
    click ADD_MI "https://github.com/joaquinlarroca/pizzajs/blob/main/source/Addons/mouseInfo.js"
    click ADD_P "https://github.com/joaquinlarroca/pizzajs/blob/main/source/Addons/particle.js"

    %% Click Events - Template Project
    click TP_HTML "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/index.html"
    click TP_MAIN "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/main.js"
    click TMP_MOD_INDEX "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/modules/index.js"
    click TMP_MOD_GLOBAL "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/modules/global.js"
    click TMP_MOD_FUNCS "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/modules/functions.js"
    click TMP_MOD_CLASSES "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/modules/classes.js"
    click TMP_MOD_LISTENER "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/modules/listener.js"
    click TMP_ADD_SS "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/Addons/DefaultScreenshot.js"
    click TMP_ADD_LS "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/Addons/localstorage.js"
    click TMP_ADD_MM "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/Addons/miniMonitor.js"
    click TMP_ADD_MI "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/Addons/mouseInfo.js"
    click TMP_ADD_P "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/Addons/particle.js"
    click TP_CSS "https://github.com/joaquinlarroca/pizzajs/blob/main/template/project/source/css/main.css"
    click TP_FONTS "https://github.com/joaquinlarroca/pizzajs/tree/main/template/project/source/fonts/FiraCode"
    click TP_ICONS "https://github.com/joaquinlarroca/pizzajs/tree/main/template/project/source/icons/"
    click TP_IMAGES "https://github.com/joaquinlarroca/pizzajs/tree/main/template/project/source/images/"

    %% Click Events - Tests
    click TEST_COLL "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/collision/"
    click TEST_COP "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/copilot-code/"
    click TEST_FF "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/fitFont/"
    click TEST_MAIN "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/main/"
    click TEST_MK "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/mkdocs examples/"
    click TEST_RS "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/round+stroke/"
    click TEST_TIME "https://github.com/joaquinlarroca/pizzajs/tree/main/tests/time/"

    %% Click Events - Documentation
    click DOC_MD "https://github.com/joaquinlarroca/pizzajs/tree/main/mkdocs/docs/"
    click MKDOCS "https://github.com/joaquinlarroca/pizzajs/blob/main/mkdocs/mkdocs.yml"
    click DOC_HTML "https://github.com/joaquinlarroca/pizzajs/tree/main/docs/"

    %% Click Events - Infrastructure
    click CI "https://github.com/joaquinlarroca/pizzajs/blob/main/.github/workflows/jekyll-docker.yml"

    %% Styles
    classDef core fill:#D0E4FE,stroke:#0366D6,color:#0366D6;
    classDef template fill:#FFE7C6,stroke:#D9822B,color:#D9822B;
    classDef tests fill:#EAEAEA,stroke:#777, color:#333;
    classDef docs fill:#E6FFED,stroke:#28A745,color:#28A745;
    classDef infra fill:#FFF5D1,stroke:#C08401,color:#C08401;
```
