# quark-framework/quark architecture

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

- Interactive diagram: https://gitdiagram.com/quark-framework/quark
- Repository: https://github.com/quark-framework/quark

## Overview

##### Project type and purpose
- QUARK is neither a web app nor a microservices system but a Python‐based command‐line framework for orchestrating and benchmarking quantum computing applications.
- It provides a plugin architecture for “applications” (TSP, SAT, MIS, SCP, ACL, Generative Modeling, etc.), “solvers” (classical and quantum algorithms), and “devices” (local simulators, AWS Braket backends, neutral‐atom devices).
- Its primary use case is: the user invokes a CLI (src/main.py), selects or supplies a YAML configuration, and QUARK launches a series of benchmarks, collects metrics, and generates plots.

##### File structure
- Entry point: src/main.py
- Core managers in src/ (ConfigManager.py, BenchmarkManager.py, Installer.py, Metrics.py, Plotter.py)
- Plugin modules under src/modules/
- applications/…
- solvers/…
- devices/…
- Adapter layer: src/quark2_adapter/ (legacy compatibility)
- Utilities: src/utils.py, src/utils_mpi.py
- Results directory: results/ and dynamically created benchmark_runs/
- Configuration & dependency management: .settings/, setup.sh, Dockerfile
- Documentation: docs/
- Tests covering modules and end‐to‐end scenarios under tests/

##### README for additional insights
- CLI modes: interactive vs. non‐interactive (--config, --resume-dir, --summarize)
- Integration points: AWS Braket, Docker container, Git LFS for large files
- Developer extension points: add new modules under src/modules/

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User(("User")):::external
    User --> CLI_Frontend

    %% Core Orchestration Layer
    CLI_Frontend["CLI Frontend"]:::core
    ConfigManager["ConfigManager"]:::core
    Installer["Installer"]:::core
    PluginLoader["Plugin Registry & Loader"]:::core
    BenchmarkManager["BenchmarkManager"]:::core
    LegacyAdapter["Legacy Adapter Layer"]:::core
    Utils["Utilities"]:::core
    MPIUtils["MPI Utilities"]:::core

    User -->|"interactive/batch"| CLI_Frontend
    CLI_Frontend --> ConfigManager
    ConfigManager --> Installer
    Installer --> PluginLoader
    ConfigManager --> PluginLoader
    CLI_Frontend --> BenchmarkManager

    %% Plugin Modules
    subgraph "Applications Plugins" 
        OptimApps["Optimization Applications\n(N implementations)"]:::plugin
        QMLApps["QML Applications\n(N implementations)"]:::plugin
    end
    subgraph "Solvers Plugins"
        Solvers["Solvers\n(N implementations)"]:::plugin
    end
    subgraph "Devices Plugins"
        Devices["Devices\n(N implementations)"]:::plugin
    end

    PluginLoader --> OptimApps
    PluginLoader --> QMLApps
    PluginLoader --> Solvers
    PluginLoader --> Devices

    %% Orchestration Flow
    BenchmarkManager -->|deliver tasks| OptimApps
    BenchmarkManager --> Solvers
    BenchmarkManager --> Devices

    %% Metrics & Plotting
    Metrics["Metrics Collector"]:::metrics
    Plotter["Plotter"]:::metrics
    BenchmarkManager --> Metrics
    Metrics --> Plotter
    Plotter --> Results

    %% Persistence Layer
    subgraph Persistence
        Results["Persistence Layer"]:::persistence
    end

    %% External Services
    AWS["AWS Braket"]:::external
    Docker["Docker"]:::external
    GitLFS["Git LFS"]:::external
    Pip["pip/uv Package Manager"]:::external

    Devices --> AWS
    Devices --> Docker
    Installer --> Pip
    CLI_Frontend --> GitLFS

    %% Legacy Adapter & Utilities
    CLI_Frontend --> LegacyAdapter
    CLI_Frontend --> Utils
    CLI_Frontend --> MPIUtils

    %% Click Events
    click CLI_Frontend "https://github.com/quark-framework/quark/blob/main/src/main.py"
    click ConfigManager "https://github.com/quark-framework/quark/blob/main/src/ConfigManager.py"
    click Installer "https://github.com/quark-framework/quark/blob/main/src/Installer.py"
    click PluginLoader "https://github.com/quark-framework/quark/blob/main/src/modules/Core.py"
    click BenchmarkManager "https://github.com/quark-framework/quark/blob/main/src/BenchmarkManager.py"
    click Metrics "https://github.com/quark-framework/quark/blob/main/src/Metrics.py"
    click Plotter "https://github.com/quark-framework/quark/blob/main/src/Plotter.py"
    click OptimApps "https://github.com/quark-framework/quark/tree/main/src/modules/applications/optimization/"
    click QMLApps "https://github.com/quark-framework/quark/tree/main/src/modules/applications/qml/"
    click Solvers "https://github.com/quark-framework/quark/tree/main/src/modules/solvers/"
    click Devices "https://github.com/quark-framework/quark/tree/main/src/modules/devices/"
    click LegacyAdapter "https://github.com/quark-framework/quark/tree/main/src/quark2_adapter/"
    click Utils "https://github.com/quark-framework/quark/blob/main/src/utils.py"
    click MPIUtils "https://github.com/quark-framework/quark/blob/main/src/utils_mpi.py"
    click Results "https://github.com/quark-framework/quark/tree/main/results/"

    %% Styles
    classDef core fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef plugin fill:#FFF9C4,stroke:#FBC02D
    classDef metrics fill:#C8E6C9,stroke:#388E3C
    classDef persistence fill:#C8E6C9,stroke:#2E7D32
    classDef external fill:#ECEFF1,stroke:#607D8B
```
