# lloydasp/nodequality architecture

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

- Interactive diagram: https://gitdiagram.com/lloydasp/nodequality
- Repository: https://github.com/lloydasp/nodequality

## Overview

##### Main Components
- Coordinator/Orchestrator – Represented by the main NodeQuality.sh script.
- Test Script Modules – Located under the “part” folder (header.sh, swap.sh, sysbench.sh, trace.sh, yabs.sh). These modules encapsulate specific test routines.
- Provider/Configuration Data – Found in the “providers” folder (data.json and its readme) which supplies configuration or metadata required by the tests.
- Sandbox Environment – The chroot-based “BenchOS” (although not explicitly in the file tree, the README details its use) which encapsulates the isolated testing environment.
- Post-Processing & Result Export – Components responsible for formatting the test results (markdown export, screenshotting, interfacing with external services for image hosting and web clipboard).
- External Integrations – Indicate integration with external test script repositories ([xykt] and others), as well as external services (e.g., IPQuality, NetQuality result handling, and the image hosting service).

##### Component Relationships and Data Flows
- User triggers NodeQuality.sh (the entry point) which then:
- Sets up the BenchOS environment via chroot.
- Mounts required binaries and temporary files for testing.
- Within the sandbox, the main script calls one or more test modules (from the “part” directory) in a controlled sequence.
- Test Modules run specific diagnostics (like benchmarking, memory, I/O, etc.) and produce raw test data.
- Raw test results are fed back into a post-processing routine that formats the results into a unified markdown report.
- The formatted report may trigger screenshot generation and communicate with external services (web paste board, image hosting APIs) to upload and display the results.
- Configuration and additional testing data are provided via the “providers” folder to augment or parameterize the tests.

##### Architectural Patterns and Design Principles
- Modular Script-Based Design: The project is broken down into discrete shell script modules (following a “microservice-like” style in shell).
- Sandboxing via chroot: Ensuring that testing happens in an isolated environment (BenchOS), which is spun up for each test run and then cleaned up.
- Separation of Concerns: The orchestration (NodeQuality.sh) is kept separate from the test routines (individual scripts in “part”) and the result processing/formatting.
- Lightweight and Dependency-Free: Emphasize that aside from downloading needed scripts and using preinstalled common tools, the project avoids heavy dependencies (like Docker).

## Diagram (Mermaid)

```mermaid
flowchart TB
    NodeQuality["Coordinator: NodeQuality.sh"]:::orchestrator
    click NodeQuality "https://github.com/lloydasp/nodequality/blob/main/NodeQuality.sh"
    
    Providers["Providers (Configuration)"]:::provider
    click Providers "https://github.com/lloydasp/nodequality/tree/main/providers/"
    
    NodeQuality -->|"initializes_sandbox"| Header

    subgraph "Sandbox Environment (BenchOS)"
        direction TB
        Header["Test Module: header.sh"]:::testmodule
        click Header "https://github.com/lloydasp/nodequality/blob/main/part/header.sh"
        Swap["Test Module: swap.sh"]:::testmodule
        click Swap "https://github.com/lloydasp/nodequality/blob/main/part/swap.sh"
        Sysbench["Test Module: sysbench.sh"]:::testmodule
        click Sysbench "https://github.com/lloydasp/nodequality/blob/main/part/sysbench.sh"
        Trace["Test Module: trace.sh"]:::testmodule
        click Trace "https://github.com/lloydasp/nodequality/blob/main/part/trace.sh"
        Yabs["Test Module: yabs.sh"]:::testmodule
        click Yabs "https://github.com/lloydasp/nodequality/blob/main/part/yabs.sh"
        
        RawData["Raw Data Aggregator"]:::rawdata
        Header -->|"sends_data"| RawData
        Swap -->|"sends_data"| RawData
        Sysbench -->|"sends_data"| RawData
        Trace -->|"sends_data"| RawData
        Yabs -->|"sends_data"| RawData
    end

    Providers -->|"supplies_config"| RawData
    Providers -->|"supplies_config"| NodeQuality
    
    RawData -->|"formats_results"| RP

    RP["Result Formatter/Post-Processor\n(automated_cleanup, screenshot_export)"]:::postprocessing

    RP -->|"exports_results"| WebClipboard
    RP -->|"exports_results"| ImageHosting

    subgraph "External Integrations"
        WebClipboard["Web Clipboard Service"]:::external
        ImageHosting["Image Hosting Service"]:::external
    end

    classDef orchestrator fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef testmodule fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef provider fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef postprocessing fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef external fill:#ffeeba,stroke:#fd7e14,stroke-width:2px;
    classDef rawdata fill:#d1ecf1,stroke:#0c5460,stroke-width:2px;
```
