# ca1pher/allure2 architecture

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

- Interactive diagram: https://gitdiagram.com/ca1pher/allure2
- Repository: https://github.com/ca1pher/allure2

## Overview

##### Project type and purpose
- This is Allure Report—a command-line tool and static report generator for test results.
- It comprises multiple Java modules (CLI, generator core, plugin API, plugins, Jira commons) and a JavaScript frontend (webpack-built) to render interactive HTML reports.

##### File structure
- Top-level modules (Gradle subprojects):
- allure-commandline: CLI entrypoint (Java)
- allure-generator: report-generation engine (Java + JS frontend + templates + webpack)
- allure-plugin-api: core plugin interface (Java)
- allure-jira-commons: shared Jira integration (Java)
- plugins/*: individual result readers/exporters (Java or JS)
- Configuration and build files: Gradle wrappers, build scripts, Jenkinsfile.
- Frontend under allure-generator/src/main/javascript, built via webpack.
- Templates: Freemarker (.ftl) in resources/tpl.
- Static layouts and plugin API exports for dynamic widgets in JS.

##### README
- Confirms project purpose: “flexible lightweight multi-language test report tool” with commands generate, serve, open.
- Mentions multi-language support and plugin ecosystem.

a. Main components
- CLI (CommandLine.java)
- Core engine (ReportGenerator, ConfigurationBuilder)
- Plugin infrastructure
– Plugin API (interfaces: Plugin, Aggregator, Reader, Widget)
– Built-in plugins (cucumber-json, junit-xml, xunit, trx, behaviours, etc.)
– Third-party plugins via ServiceLoader
- Data sources (Allure results folder: JSON, XML, attachments)
- Template engine (Freemarker)
- JavaScript frontend (Webpack bundle)
- Local web server (Jetty) for “serve” command
- Browser client

b. Relationships and interactions
1. User invokes CLI →
- Parses CLI args (GenerateCommand/OpenCommand/ServeCommand)
- Loads configuration (CommandlineConfig, ConfigLoader)
2. GenerateCommand →
- Reads test result files via plugins (Reader implementations)
- Feeds data into core engine → ReportGenerator
- ReportGenerator calls plugins (Aggregator, Writer, Widget) to produce JSON and static assets
- Freemarker templates + JS/CSS/HTML write to “allure-report” directory
3. ServeCommand →
- Starts embedded Jetty server
- Serves generated static content (HTML, JS, CSS, data)
4. OpenCommand →
- Launches default browser pointing to local/remote report URL
5. Frontend →
- Loads JS bundle (Webpack output)
- Fetches JSON data files
- Renders interactive UI (charts, trees, widgets)

c. Architectural patterns and design principles
- Modular micro-kernel: Core engine + plugin extensions via Plugin API
- Clear separation: CLI, core generation, plugin interface, frontend
- Build pipelines: Gradle for Java modules, Webpack for JS
- ServiceLoader/dynamic loading of plugins (Java SPI)
- Template-based static site generation (Freemarker + JS templates)

d. Key technologies
- Java 8+, Gradle Kotlin DSL
- Freemarker template engine
- ServiceLoader for plugin discovery
- Jackson/Gson for JSON parsing
- Jetty for embedded server
- Node.js + Webpack + Handlebars for frontend
- SCSS/CSS for styling

##### Essential elements
- Don’t omit the plugin layer—this is what gives Allure its extensibility.
- Both the Java and JS build/deploy paths.
- Separate commands (generate/serve/open) as distinct entrypoints.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "CLI (Java)"
        CL["CommandLine"]:::java
        Gen["GenerateCommand"]:::java
        Sev["ServeCommand"]:::java
        Op["OpenCommand"]:::java
        CL -->|invokes| Gen
        CL -->|invokes| Sev
        CL -->|invokes| Op
        Gen -->|load config| CLCon["ConfigLoader"]:::java
    end

    click CL "https://github.com/ca1pher/allure2/blob/master/allure-commandline/src/main/java/io/qameta/allure/CommandLine.java"
    click Gen "https://github.com/ca1pher/allure2/blob/master/allure-commandline/src/main/java/io/qameta/allure/command/GenerateCommand.java"
    click Sev "https://github.com/ca1pher/allure2/blob/master/allure-commandline/src/main/java/io/qameta/allure/command/ServeCommand.java"
    click Op "https://github.com/ca1pher/allure2/blob/master/allure-commandline/src/main/java/io/qameta/allure/command/OpenCommand.java"
    click CLCon "https://github.com/ca1pher/allure2/blob/master/allure-commandline/src/main/java/io/qameta/allure/config/ConfigLoader.java"

    subgraph "Core Engine (Java)"
        RG["ReportGenerator"]:::java
        CB["ConfigurationBuilder"]:::java
        DC["DefaultConfiguration"]:::java
        DRV["DefaultResultsVisitor"]:::java
        RG --> CB
        RG --> DC
        RG --> DRV
    end

    click RG "https://github.com/ca1pher/allure2/blob/master/allure-generator/src/main/java/io/qameta/allure/ReportGenerator.java"
    click CB "https://github.com/ca1pher/allure2/blob/master/allure-generator/src/main/java/io/qameta/allure/ConfigurationBuilder.java"
    click DC "https://github.com/ca1pher/allure2/blob/master/allure-generator/src/main/java/io/qameta/allure/DefaultConfiguration.java"
    click DRV "https://github.com/ca1pher/allure2/blob/master/allure-generator/src/main/java/io/qameta/allure/DefaultResultsVisitor.java"

    Gen --> RG

    subgraph "Plugin Infrastructure"
        API["Plugin API Interfaces"]:::boundary
        PL["DefaultPluginLoader"]:::java
        API --> PL
    end

    click API "https://github.com/ca1pher/allure2/tree/master/allure-plugin-api/src/main/java/io/qameta/allure"
    click PL "https://github.com/ca1pher/allure2/blob/master/allure-generator/src/main/java/io/qameta/allure/plugin/DefaultPluginLoader.java"

    RG --> API
    PL -->|loads| API

    subgraph "Built-in Plugins (Java)"
        subgraph Readers
            A1["Allure1Plugin"]:::java
            A2["Allure2Plugin"]:::java
        end
        subgraph Extensions
            PCat["Category, core, etc. Plugins"]:::java
        end
        Readers --> PCat
    end

    click A1 "https://github.com/ca1pher/allure2/tree/master/allure-generator/src/main/java/io/qameta/allure/allure1"
    click A2 "https://github.com/ca1pher/allure2/tree/master/allure-generator/src/main/java/io/qameta/allure/allure2"
    click PCat "https://github.com/ca1pher/allure2/tree/master/allure-generator/src/main/java/io/qameta/allure"

    PL --> A1
    PL --> A2
    PL --> PCat

    subgraph "Third-Party Plugins"
        TPP["Plugins under plugins/*"]:::java
    end

    click TPP "https://github.com/ca1pher/allure2/tree/master/plugins"

    PL --> TPP

    subgraph "Template Engine"
        FT["Freemarker Templates"]:::java
    end

    click FT "https://github.com/ca1pher/allure2/blob/master/allure-generator/src/main/resources/tpl/index.html.ftl"

    RG --> FT
    FT -->|"generates static HTML/JS/CSS"| FS[(Static Files)]:::infra

    subgraph "JS Frontend"
        JS["JS Source"]:::frontend
        WS["Webpack Configs"]:::frontend
        Bndl["JS Bundle"]:::frontend
        JS --> WS
        WS --> Bndl
    end

    click JS "https://github.com/ca1pher/allure2/tree/master/allure-generator/src/main/javascript"
    click WS "https://github.com/ca1pher/allure2/blob/master/allure-generator/webpack/webpack.common.js"
    click WS "https://github.com/ca1pher/allure2/blob/master/allure-generator/webpack/webpack.dev.js"
    click WS "https://github.com/ca1pher/allure2/blob/master/allure-generator/webpack/webpack.prod.js"

    FS --> Bndl

    Sev --> Jetty["Jetty Server"]:::infra
    click Jetty "https://github.com/ca1pher/allure2/blob/master/allure-commandline/src/dist/lib/config/jetty-logging.properties"
    Jetty --> FS

    Op --> Browser["Browser"]:::infra
    Browser --> FS
    Browser --> Bndl

    classDef java fill:#cce5ff,stroke:#004085,color:#004085
    classDef boundary fill:#d4edda,stroke:#155724,color:#155724
    classDef frontend fill:#fff3cd,stroke:#856404,color:#856404
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#6c757d
```
