# luchobazz/quicktest architecture

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

- Interactive diagram: https://gitdiagram.com/luchobazz/quicktest
- Repository: https://github.com/luchobazz/quicktest

## Overview

##### Project Type and Purpose
- Quick Test CLI is a CLI tool built in Rust (evidenced by Cargo.toml and the “src” structure) designed to perform various types of testing (cmp, check, stress, output, setup) for competitive programming projects.
- Its goal is to generate test cases, compare outputs (possibly with a brute force or checker solution), execute target code in different languages, and report on potential errors (WA, TLE, RTE).

##### Analyzing the File Structure
- Top-level directories like “src”, “tests”, “examples”, “assets”, and “website” indicate a multi-faceted project.
- Under “src”, you have detailed separation into CLI components (src/cli), controllers (src/controllers), error handling, file handling, generators, language modules, runner, and views for output rendering.
- The “examples” folder shows real-world use cases (cmp, check, output, stress) for various supported languages, reinforcing that the tool interconnects code generators, compilers, and validators.
- The “website” directory suggests there is an accompanying documentation and tutorial site, but for the system design, the primary focus is on the CLI tool itself.

##### Key Components
a. CLI Interface
- Entry point (src/main.rs) and option parsing (src/cli/opt.rs) which receives user commands and arguments.
- Subcommand models (src/cli/model/*) representing commands like cmp, stress, check, output, and setup.

b. Controllers
- Modules in src/controllers handle the business logic for each command. Notice both asynchronous controllers (e.g., cmd_cmp_async.rs) and legacy synchronous ones, showing a phase of evolution and potential backward compatibility.

c. Core Functional Modules
- Generator Module (src/generator): Builds test cases through generator programs.
- File Handler Module (src/file_handler): Manages reading/writing files, paths, and asynchronous file operations.
- Language Module (src/language): Handles language-specific tasks like determining file extensions, command generation for compiling/executing code, and JSON configs (src/language/json). This module bridges the CLI commands with multi-language support.
- Runner Module (src/runner): Manages command execution/state counting and process management.
- Views (src/views): Responsible for displaying outputs such as diff views or styled outputs.
- Error Handling (src/error): Captures and processes errors raised in various components.

d. Configuration and Constants:
- Configurations (src/config) for language settings, reading configuration files, and constants (src/constants.rs) ensuring consistent configuration across the application.

##### Relationships and Interactions
- How each subcommand routes the request to its corresponding controller.
- Each controller then interacts with core modules:
- The Generator module for producing test cases.
- The File Handler to read/write both source code and test files.
- The Language module, which selects and prepares compilation/execution commands for multiple programming languages.
- The Runner module, which is responsible for executing the target code and capturing results.
- The Error Handling module that processes runtime errors, timeouts, and memory issues.
- The Views module to display detailed output, differences, or errors.

##### Architectural Patterns and Design Principles
- The presence of “controllers”, “models”, and “views” suggests a loosely applied MVC pattern specific to CLI processing.
- Asynchronous processes (e.g., in the async controller implementations under src/controllers) to denote concurrent processing, which is key for responsiveness during stress testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Node
    UT("User Terminal"):::external

    %% CLI Layer Subgraph
    subgraph "CLI Layer"
        A("Entry Point (src/main.rs)"):::cli
        B("Option Parser (src/cli/opt.rs)"):::cli
        C("Subcommand Model: Check"):::cli
        D("Subcommand Model: Cmp"):::cli
    end

    %% Controllers Layer Subgraph
    subgraph "Controllers Layer"
        %% Async Controllers
        subgraph "Async Controllers"
            E("Async Controller: Check (cmd_check_async)"):::controller
            F("Async Controller: Cmp (cmd_cmp_async)"):::controller
            G("Async Controller: Output (cmd_output_async)"):::controller
            H("Async Controller: Setup (cmd_setup_async)"):::controller
            I("Async Controller: Stress (cmd_stress_async)"):::controller
        end
        %% Legacy Controllers
        subgraph "Legacy Controllers"
            J("Legacy Controller: Check (cmd_check)"):::controller
            K("Legacy Controller: Output (cmd_output)"):::controller
            L("Legacy Controller: Setup (cmd_setup)"):::controller
            M("Legacy Controller: Stress (cmd_stress)"):::controller
        end
    end

    %% Core Modules Subgraph
    subgraph "Core Modules"
        N("Generator Module (Test Case Generation)"):::core
        O("File Handler Module"):::core
        P("Language Module (Language Manager)"):::core
        Q("Runner Module"):::core
        R("Views Module"):::core
        S("Error Handler"):::core
        T("Configuration & Constants"):::core
    end

    %% Data Flow Connections
    UT -->|"inputs"| A
    A -->|"initializes"| B
    B -->|"parses args to"| C
    B -->|"parses args to"| D

    %% Connection from subcommand models to controllers (representative links)
    C -->|"dispatches"| E
    C -->|"fallback to"| J
    D -->|"dispatches"| F
    D -->|"fallback to"| K

    %% Representative controller to core modules connections (using one from each group)
    E -->|"executes"| N
    E --> O
    E --> P
    E --> Q
    E --> R
    E --> S
    E --> T

    J -->|"executes"| N
    J --> O
    J --> P
    J --> Q
    J --> R
    J --> S
    J --> T

    %% Bidirectional communication between Error Handler and Views Module
    S <-->|"reports"| R

    %% Style Definitions
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef controller fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#000,stroke-width:2px;

    %% Click Events
    click A "https://github.com/luchobazz/quicktest/blob/main/src/main.rs"
    click B "https://github.com/luchobazz/quicktest/blob/main/src/cli/opt.rs"
    click C "https://github.com/luchobazz/quicktest/blob/main/src/cli/model/check_command.rs"
    click D "https://github.com/luchobazz/quicktest/blob/main/src/cli/model/cmp_command.rs"
    click E "https://github.com/luchobazz/quicktest/blob/main/src/controllers/cmd_check_async.rs"
    click F "https://github.com/luchobazz/quicktest/blob/main/src/controllers/cmd_cmp_async.rs"
    click G "https://github.com/luchobazz/quicktest/blob/main/src/controllers/cmd_output_async.rs"
    click H "https://github.com/luchobazz/quicktest/blob/main/src/controllers/cmd_setup_async.rs"
    click I "https://github.com/luchobazz/quicktest/blob/main/src/controllers/cmd_stress_async.rs"
    click J "https://github.com/luchobazz/quicktest/blob/main/src/controllers/legacy/cmd_check.rs"
    click K "https://github.com/luchobazz/quicktest/blob/main/src/controllers/legacy/cmd_output.rs"
    click L "https://github.com/luchobazz/quicktest/blob/main/src/controllers/legacy/cmd_setup.rs"
    click M "https://github.com/luchobazz/quicktest/blob/main/src/controllers/legacy/cmd_stress.rs"
    click N "https://github.com/luchobazz/quicktest/blob/main/src/generator/generator.rs"
    click O "https://github.com/luchobazz/quicktest/tree/main/src/file_handler/"
    click P "https://github.com/luchobazz/quicktest/blob/main/src/language/language_handler.rs"
    click Q "https://github.com/luchobazz/quicktest/blob/main/src/runner/cmd.rs"
    click R "https://github.com/luchobazz/quicktest/blob/main/src/views/diff_line_by_line.rs"
    click S "https://github.com/luchobazz/quicktest/blob/main/src/error/handle_error.rs"
    click T "https://github.com/luchobazz/quicktest/blob/main/src/config/languages_config.rs"
```
