# wordpress/performance architecture

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

- Interactive diagram: https://gitdiagram.com/wordpress/performance
- Repository: https://github.com/wordpress/performance

## Overview

- Performance Lab Monorepo Container
– This is the primary “root” of the architecture that encompasses every other component. It contains shared configuration files (e.g., .editorconfig, package.json, composer.json), CI configurations in the .github directory, and build-related tools (webpack, phpunit, phpcs, and phpstan).

- Plugins Directory
– Inside each plugin’s folder, there is a further separation between core code, hooks, includes, tests, and configuration files (e.g., phpcs.xml.dist). These details can be abstracted to show that each plugin’s code is self-contained and has its own testing and CI hooks.

- Bin and Tools Directories
– The “bin” folder contains command-line tools (such as plugin CLI commands and scripts for generating pending release diffs).
– The “tools” folder includes scripts and configurations for code quality (phpcs, phpstan, webpack, phpunit bootstrap, etc.).

- CI/CD and Integration Layer
– GitHub workflows found under the .github/workflows directory illustrate continuous integration (linting, testing, code analysis, deployment, etc.).

##### Relationships and Interactions

- Internal Integration among Plugins

- Communication with the CI/CD Pipeline

- Developer Tools and Testing
– Include directional flows from the “tools” directory (e.g., phpcs, phpstan, webpack) to indicate how they are used to build, lint, and test the codebase. Similarly, represent the “tests” subdirectories within each plugin showing that each module is thoroughly covered by its own test suite.

##### Architectural Patterns and Design Principles

- Monorepo Module Strategy
– Emphasize the design choice of using a monorepo to manage multiple plugins in one repository. This means that while each plugin is modular, they share common development workflows.

- Separation of Concerns

- Use of Standard Tooling and Configuration

## Diagram (Mermaid)

```mermaid
graph TD
    A["Performance Lab Monorepo Container"]:::monorepo

    subgraph PD["Plugins Directory"]
        P1["Embed Optimizer"]:::plugin
        P2["Dominant Color Images"]:::plugin
        P3["Image Prioritizer"]:::plugin
        P4["WebP Uploads"]:::plugin
        P5["Optimization Detective"]:::plugin
        P6["Performance Lab"]:::plugin
        P7["Speculation Rules"]:::plugin
        P8["Auto Sizes"]:::plugin
        P9["Web Worker Offloading"]:::plugin
    end

    subgraph BIN["Bin Directory"]
        B1["CLI Tools & Scripts"]:::support
    end

    subgraph TOOLS["Tools Directory"]
        T1["Build, Lint, and Test Utilities"]:::support
    end

    subgraph CICD["CI/CD Workflows"]
        C1["GitHub Workflows (CI)"]:::ci
    end

    %% Main container relationships
    A -->|"contains"| PD
    A -->|"contains"| BIN
    A -->|"contains"| TOOLS
    A -->|"codecommit_triggers"| CICD

    %% Interactions between components
    PD -->|"triggers_tests_and_deployments"| CICD
    BIN -->|"integrates_with"| PD
    TOOLS -->|"validates_and_builds"| PD

    %% Click Events
    click A "https://github.com/wordpress/performance/tree/trunk/root"
    click PD "https://github.com/wordpress/performance/tree/trunk//plugins"
    click P1 "https://github.com/wordpress/performance/tree/trunk//plugins/embed-optimizer"
    click P2 "https://github.com/wordpress/performance/tree/trunk//plugins/dominant-color-images"
    click P3 "https://github.com/wordpress/performance/tree/trunk//plugins/image-prioritizer"
    click P4 "https://github.com/wordpress/performance/tree/trunk//plugins/webp-uploads"
    click P5 "https://github.com/wordpress/performance/tree/trunk//plugins/optimization-detective"
    click P6 "https://github.com/wordpress/performance/tree/trunk//plugins/performance-lab"
    click P7 "https://github.com/wordpress/performance/tree/trunk//plugins/speculation-rules"
    click P8 "https://github.com/wordpress/performance/tree/trunk//plugins/auto-sizes"
    click P9 "https://github.com/wordpress/performance/tree/trunk//plugins/web-worker-offloading"
    click B1 "https://github.com/wordpress/performance/tree/trunk//bin"
    click T1 "https://github.com/wordpress/performance/tree/trunk//tools"
    click C1 "https://github.com/wordpress/performance/tree/trunk//.github/workflows"

    %% Styles
    classDef monorepo fill:#f2d7d5,stroke:#c0392b,stroke-width:2px;
    classDef plugin fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef support fill:#d6eaf8,stroke:#2980b9,stroke-width:2px;
    classDef ci fill:#fcf3cf,stroke:#f39c12,stroke-width:2px;
```
