# ortonikc/ortoni-report architecture

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

- Interactive diagram: https://gitdiagram.com/ortonikc/ortoni-report
- Repository: https://github.com/ortonikc/ortoni-report

## Overview

##### Main Components
- CLI Interface: Represented primarily by the files in src/cli (for example, cli.ts) and the overall entry point in src/ortoni-report.ts. This component accepts commands (like “show-report”) and options (such as the directory, file, or port).
- Helper Modules: Under src/helpers, these include:
– HTMLGenerator: Responsible for converting test information into HTML views.
– FileManager and DatabaseManager: For reading/writing report assets, managing storage (e.g., the “report-db” folder).
– ResultProcessor: Parses and processes the Playwright test results.
– ServerManager: Sets up/modifies servers.
- Utilities: In src/utils, functions such as expressServer.ts, attachFiles.ts, and groupProjects.ts support the core operations like starting an Express server, managing test attachments, and grouping tests logically.
- Views/Assets: The precompiled Handlebars templates (in dist/views) and CSS style sheets (in dist/style) are used by the HTMLGenerator to produce the final report interface.
- External Integration & Configuration: The project supports integration into Playwright via configuration files (as shown by the example configurations in the README) and interacts with the test results generated during a Playwright run.

##### Relationships and Data Flow
- Data Entry: Test results from Playwright (configured in playwright.config.ts or .js) are passed into the Ortoni Report system.
- Processing Pipeline: The CLI triggers the main report generation process that calls on:
- The ResultProcessor (to interpret the raw test data).
- The HTMLGenerator (to produce HTML components based on Handlebars templates in the dist/views folder).
- FileManager and DatabaseManager (to handle saving and retrieving of report files and assets).
- Serving the Report: The Express server module (in src/utils/expressServer.ts, assisted by serverManager.ts) is spawned to serve the generated HTML report, listening on a configurable port (by default 2004) and providing live access via a browser.
- Output: A fully rendered HTML report that users can view in a browser with interactive navigation (sidebar, charts, and detailed test data).

##### Architectural Patterns and Design Principles
- Modularization: The project is clearly split into separate modules (CLI, Helpers, Utils), promoting single-responsibility and easier testing (with the tests folder containing integration/spec tests).
- Separation of Concerns: The HTML generation, file management, result processing, and server starting are handled by different modules.
- Template-based Rendering: Utilizing Handlebars templates (in dist/views) for dynamic HTML generation based on runtime test results.
- Extensibility: The configuration options (via playwright.config file examples) allow extensive customization of themes, report titles, and metadata.

##### Technologies & Frameworks
- Node.js and TypeScript (evident through tsconfig.json, tsup.config.ts, and source file extensions).
- Express (to serve the report on a local web server) as shown in the CLI commands and expressServer.ts.
- Handlebars (in dist/views) for templating.
- Playwright integration (as indicated by sample configuration and the README) for test data input.

##### Essential Elements
- Clear labels for each component (CLI, Helpers, Utils, Views, Deployment/Server).
- Annotation of relationships, such as “Calls”, “Processes”, or “Serves” between components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Input
    testResults["Playwright Test Results"]:::external

    %% CLI & Configuration Layer
    subgraph "CLI & Configuration"
        cli["CLI: cli.ts"]:::cli
        entry["Entry Point: ortoni-report.ts"]:::cli
    end

    %% Processing Modules Layer
    subgraph "Processing Modules"
        rp["Result Processor"]:::processing
        hg["HTML Generator"]:::processing
        fm["File Manager"]:::processing
        dm["Database Manager"]:::processing
        sm["Server Manager"]:::processing
    end

    %% Server & Presentation Layer
    subgraph "Server & Presentation"
        es["Express Server Utility"]:::server
        report["HTML Report Output"]:::server
    end

    %% Assets Layer
    subgraph "Assets"
        tv["Template Views"]:::assets
        sa["Style Assets"]:::assets
    end

    %% Data Flow Connections
    testResults -->|"input"| cli
    cli -->|"triggers"| entry
    entry -->|"initiates"| rp
    entry -->|"initiates"| sm

    rp -->|"processes"| hg
    rp -->|"stores"| fm
    rp -->|"logs"| dm

    hg -->|"renders"| report
    hg -->|"utilizes"| tv
    hg -->|"utilizes"| sa

    sm -->|"configures"| es
    es -->|"serves"| report

    %% Styling Classes
    classDef cli fill:#f9c74f,stroke:#000,stroke-width:1px;
    classDef processing fill:#90be6d,stroke:#000,stroke-width:1px;
    classDef server fill:#577590,stroke:#000,stroke-width:1px;
    classDef assets fill:#f94144,stroke:#000,stroke-width:1px;
    classDef external fill:#277da1,stroke:#000,stroke-width:1px;

    %% Click Events
    click cli "https://github.com/ortonikc/ortoni-report/blob/main/src/cli/cli.ts"
    click entry "https://github.com/ortonikc/ortoni-report/blob/main/src/ortoni-report.ts"
    click rp "https://github.com/ortonikc/ortoni-report/blob/main/src/helpers/resultProcessor.ts"
    click hg "https://github.com/ortonikc/ortoni-report/blob/main/src/helpers/HTMLGenerator.ts"
    click fm "https://github.com/ortonikc/ortoni-report/blob/main/src/helpers/fileManager.ts"
    click dm "https://github.com/ortonikc/ortoni-report/blob/main/src/helpers/databaseManager.ts"
    click sm "https://github.com/ortonikc/ortoni-report/blob/main/src/helpers/serverManager.ts"
    click es "https://github.com/ortonikc/ortoni-report/blob/main/src/utils/expressServer.ts"
    click tv "https://github.com/ortonikc/ortoni-report/tree/main/dist/views"
    click sa "https://github.com/ortonikc/ortoni-report/tree/main/dist/style"
```
