# aarongoldenthal/pa11y architecture

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

- Interactive diagram: https://gitdiagram.com/aarongoldenthal/pa11y
- Repository: https://github.com/aarongoldenthal/pa11y

## Overview

##### Main Components (Core Architecture)

a. Command-Line Interface Layer
- CLI entry point (bin/pa11y.js)
- Command parsing and configuration loading
- To the core Pa11y module

b. Core Pa11y Module (lib/pa11y.js)
- Central orchestrator
- Configuration management
- Test execution flow

c. Runner System
- Multiple test runners (htmlcs, axe)
- Runner loading mechanism
- Runner execution environment

d. Reporter System
- Multiple output formats (cli, csv, json, html, tsv)
- Reporter loading mechanism
- Results transformation pipeline

##### Key Interactions and Data Flow

a. Test Execution Flow
- CLI/API Input → Configuration → Browser Launch → Page Load → Actions → Test Execution → Results → Reporting

b. Runner Integration
- Pa11y Core → Runner Loading → Script Injection → Test Execution → Results Collection

c. Reporter Processing
- Raw Results → Reporter Selection → Format Transformation → Output Generation

##### Component Details

a. Browser Integration
- Puppeteer integration
- Chrome launch configuration
- Page management

b. Action System
- Action parser
- Action executor
- Supported actions (click, wait, set field, etc.)

c. Results Processing
- Issue collection
- Result normalization
- Threshold checking

##### Specific Elements

a. External Dependencies
- Puppeteer
- HTML_CodeSniffer
- Axe-core

b. Configuration System
- CLI options
- JSON config
- Default settings

c. Extension Points
- Custom runners
- Custom reporters
- Action system

##### Technical Details to Highlight

- Node.js runtime environment
- Async/Promise-based operations
- Browser automation
- File system interactions
- Event system

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI
        CLI_Entry["CLI Entry Point"]
        Config_Load["Configuration Loading"]
        Cmd_Parse["Command Parsing"]
    end

    subgraph Core
        Pa11y_Core["Pa11y Core"]
        Browser["Browser Integration"]
        Action_System["Action System"]
        Results["Results Processing"]
    end

    subgraph Runners
        Runner_Base["Runner Base"]
        HTMLCS["HTML CodeSniffer Runner"]
        AXE["Axe Runner"]
    end

    subgraph Reporters
        Reporter_Base["Reporter Base"]
        CLI_Rep["CLI Reporter"]
        CSV_Rep["CSV Reporter"]
        HTML_Rep["HTML Reporter"]
        JSON_Rep["JSON Reporter"]
        TSV_Rep["TSV Reporter"]
    end

    subgraph Config
        Options["Options Handler"]
        Default_Config["Default Settings"]
        JSON_Config["JSON Config"]
    end

    subgraph External
        Puppeteer["Puppeteer"]
        HTMLCS_Lib["HTML_CodeSniffer"]
        Axe_Core["Axe-core"]
    end

    %% Main Flow
    CLI_Entry --> Config_Load
    Config_Load --> Cmd_Parse
    Cmd_Parse --> Pa11y_Core
    Pa11y_Core --> Browser
    Browser --> Action_System
    Action_System --> Runner_Base
    Runner_Base --> Results
    Results --> Reporter_Base

    %% Runner Connections
    Runner_Base --> HTMLCS
    Runner_Base --> AXE
    HTMLCS --> HTMLCS_Lib
    AXE --> Axe_Core

    %% Reporter Connections
    Reporter_Base --> CLI_Rep
    Reporter_Base --> CSV_Rep
    Reporter_Base --> HTML_Rep
    Reporter_Base --> JSON_Rep
    Reporter_Base --> TSV_Rep

    %% Config Connections
    Options --> Default_Config
    Options --> JSON_Config
    Options --> Pa11y_Core

    %% External Connections
    Browser --> Puppeteer

    %% Styling
    classDef core fill:#f9f,stroke:#333,stroke-width:2px
    classDef runner fill:#bbf,stroke:#333,stroke-width:2px
    classDef reporter fill:#bfb,stroke:#333,stroke-width:2px
    classDef config fill:#fbb,stroke:#333,stroke-width:2px
    classDef external fill:#ddd,stroke:#333,stroke-width:2px
    classDef cli fill:#ff9,stroke:#333,stroke-width:2px

    class Pa11y_Core,Browser,Action_System,Results core
    class Runner_Base,HTMLCS,AXE runner
    class Reporter_Base,CLI_Rep,CSV_Rep,HTML_Rep,JSON_Rep,TSV_Rep reporter
    class Options,Default_Config,JSON_Config config
    class Puppeteer,HTMLCS_Lib,Axe_Core external
    class CLI_Entry,Config_Load,Cmd_Parse cli

    %% Click Events
    click CLI_Entry "https://github.com/aarongoldenthal/pa11y/blob/fork/bin/pa11y.js"
    click Pa11y_Core "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/pa11y.js"
    click Runner_Base "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/runner.js"
    click HTMLCS "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/runners/htmlcs.js"
    click AXE "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/runners/axe.js"
    click Reporter_Base "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/reporter.js"
    click CLI_Rep "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/reporters/cli.js"
    click CSV_Rep "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/reporters/csv.js"
    click HTML_Rep "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/reporters/html.js"
    click JSON_Rep "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/reporters/json.js"
    click TSV_Rep "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/reporters/tsv.js"
    click Action_System "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/action.js"
    click Options "https://github.com/aarongoldenthal/pa11y/blob/fork/lib/option.js"
```
