# qua-platform/py-qua-tools architecture

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

- Interactive diagram: https://gitdiagram.com/qua-platform/py-qua-tools
- Repository: https://github.com/qua-platform/py-qua-tools

## Overview

##### Main Project Components
- Core Package (qualang_tools): This is the heart of the project. Almost every module (loops, plotting, results, units, analysis, bakery, video mode, configuration tools, control panel, macros, digital filters, voltage gates, wirer, etc.) is located under this umbrella.
- Submodules/Components: Each subdirectory under qualang_tools is essentially a distinct component or library with a specific purpose. For example:
- QUA Loops Tools (qualang_tools/loops)
- Plotting Tools (qualang_tools/plot)
- Results/Data Handling Tools (qualang_tools/results)
- Units Tools (qualang_tools/units)
- Analysis Tools (qualang_tools/analysis)
- Octave Tools (qualang_tools/octave_tools)
- Multi-user Tools (qualang_tools/multi_user)
- Simulator Tools (qualang_tools/simulator)
- Bakery (for waveform building)
- External Frameworks integration (qualang_tools/external_frameworks, notably QCoDeS)
- Video Mode (qualang_tools/video_mode)
- Addons (qualang_tools/addons including calibration and interactive plotting)
- Config Tools (qualang_tools/config, with further clusters for integration weights, waveform tools, GUI, and builder)
- Control Panel (qualang_tools/control_panel)
- Macros (qualang_tools/macros)
- Digital Filters (qualang_tools/digital_filters)
- Voltage Gates (qualang_tools/voltage_gates)
- Wirer (qualang_tools/wirer, which automates channel allocation)

##### Out Relationships and Interactions
- That the core qualang_tools package acts as a container where each module offers its API. Modules are designed to be used individually, but they also interact when a user is setting up experiments.
- That certain modules interact directly:
- “Config Tools” are critical for setting up experimental parameters and are used to generate configuration files that are then consumed by “Control Panel”, “Bakery”, “Voltage Gates”, etc.
- “External Frameworks” module enables integration with frameworks such as QCoDeS, providing drivers that link external control software with the experimental setup.
- “Simulator Tools” and “Multi-user Tools” provide additional support for either testing or collaborative environments.
- Optionally, sketch a separate cluster/collection illustrating the “Examples” and “Tests” directories. This shows how the tools are validated (using unit tests and integration tests) and demonstrated (through example usage).

##### Architectural Patterns
- Layered/Abstraction Layers: There is a distinction between lower level “configuration and control” (e.g., Config Tools, Control Panel) and higher-level “analysis and visualization” (e.g., Results, Plotting, Analysis Tools).
- Integration with External Services: The external integration (like QCoDeS for instrument drivers) is represented as standalone components that plug into the system through clearly defined APIs.

##### Relevant Technologies and Tools
- Python: This is the primary language (indicated by pyproject.toml, tests written in Python, etc.)
- Dependencies for extras: For example, “Interactive Plot Library” or additional packages like cirq for two-qubit randomized benchmarking (as mentioned in the README).
- Unit Testing and CI: Show that the “tests” and “.github/workflows” directories are in place, representing the project's CI/CD pipelines.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Qualang Tools Package"
        core["qualang_tools"]
        subgraph "Modules"
            loops["QUA Loops Tools"]
            plot["Plotting Tools"]
            results["Results/Data Handling Tools"]
            units["Units Tools"]
            analysis["Analysis Tools"]
            octave["Octave Tools"]
            multi["Multi-user Tools"]
            simulator["Simulator Tools"]
            bakery["Bakery"]
            extframework["External Frameworks Integration"]
            video["Video Mode"]
            addons["Addons"]
            config["Config Tools"]
            control["Control Panel"]
            macros["Macros"]
            filters["Digital Filters"]
            voltage["Voltage Gates"]
            wirer["Wirer"]
        end
    end

    subgraph "Validation & CI/CD"
        examples["Examples"]
        tests["Tests"]
        ci["GitHub Workflows"]
    end

    %% Interactions
    config -->|"config_flow"| control
    config -->|"config_flow"| bakery
    config -->|"config_flow"| voltage

    results -->|"data_processing"| analysis
    results -->|"data_processing"| plot

    extframework -->|"integration"| control
    control -->|"integration"| extframework

    %% Click Events
    click core "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/"
    click loops "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/loops/"
    click plot "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/plot/"
    click results "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/results/"
    click units "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/units/"
    click analysis "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/analysis/"
    click octave "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/octave_tools/"
    click multi "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/multi_user/"
    click simulator "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/simulator/"
    click bakery "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/bakery/"
    click extframework "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/external_frameworks/qcodes/"
    click video "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/video_mode/"
    click addons "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/addons/"
    click config "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/config/"
    click control "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/control_panel/"
    click macros "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/macros/"
    click filters "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/digital_filters/"
    click voltage "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/voltage_gates/"
    click wirer "https://github.com/qua-platform/py-qua-tools/tree/main/qualang_tools/wirer/"

    %% Styling Classes
    classDef config fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef control fill:#e8f5e9,stroke:#1b5e20,stroke-width:2px;
    classDef postprocess fill:#f1f8e9,stroke:#33691e,stroke-width:2px;
    classDef others fill:#fce4ec,stroke:#880e4f,stroke-width:2px;

    class loops,units,config config;
    class control,video,bakery,voltage,wirer control;
    class results,analysis,plot postprocess;
    class octave,multi,simulator,extframework,addons,macros,filters others;
```
