# qupath/qupath architecture

> Architecture diagram of the GitHub repository qupath/qupath, 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/qupath/qupath
- Repository: https://github.com/qupath/qupath

## Overview

##### Main components
- Core Modules: There are several “core” components. For example, “qupath-core” and “qupath-core-processing” contain the central libraries for image analysis, segmentation, detection algorithms, ROI tools, measurements, and data handling.
- Application Module: The “qupath-app” package forms the entry point for the executable application that ties the core processing, GUI, and extensions together.
- GUI Module: “qupath-gui-fx” contains the code for the Graphical User Interface (using JavaFX) including menus, toolbars, image viewers, dialog components, and other interactive elements.
- External Interfaces: Integration points to external software (for example, ImageJ and Image.sc forum links) and external APIs often come through plugins.

##### Architectural Patterns & Design Principles
- Plugin-based architecture, suggesting that the application can be easily extended for new file formats, processing techniques, or integration functionalities.
- Use of convention-over-configuration in build scripts (as seen in the “buildSrc” module’s Kotlin and Java convention files).
- Point out that many of the sub-components follow a layered architecture: user presentation (GUI) on one layer, business logic (core processing, algorithms) in the middle, and extension/integration plugins at a peripheral layer.
- The system also makes use of dependency injection/registration for plugins (check for use of “service” files in META-INF services).

##### Relevant Technologies and Frameworks
- Java and JavaFX (seen in qupath-gui-fx)
- Gradle (build scripts in build.gradle.kts and buildSrc)
- Integration with third-party libraries (e.g., ImageJ, Bio-Formats, OpenSlide) is supported via specific extension modules.
- The modular system may also use Java’s module system (module-info files are present) for controlling strong encapsulation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Modules
    subgraph "Core Modules"
        core1["qupath-core"]:::core
        core2["qupath-core-processing"]:::core
    end

    %% Application Module
    subgraph "Application Module"
        app["qupath-app"]:::app
    end

    %% GUI Module
    subgraph "GUI Module"
        gui["qupath-gui-fx (JavaFX)"]:::gui
    end

    %% Plugin/Extension Modules
    subgraph "Plugin Extensions"
        ext1["Bio‐Formats Extension"]:::extension
        ext2["OpenSlide Extension"]:::extension
        ext3["Processing Extension"]:::extension
        ext4["Script Editor Extension"]:::extension
        ext5["SVG Extension"]:::extension
    end

    %% Build & Deployment Infrastructure
    subgraph "Build & Deployment"
        build_gradle["build.gradle.kts"]:::build
        build_src["buildSrc"]:::build
        gradle_node["gradle"]:::build
        jpackage_node["jpackage"]:::build
        workflows[".github/workflows"]:::build
    end

    %% Relationships between modules
    %% qupath-app depends on Core Modules
    app -->|"dependsOn"| core1
    app -->|"dependsOn"| core2

    %% GUI interacts with Application and Core
    app <-->|"integratesWith"| gui
    gui -->|"triggersProcessing"| core1
    gui -->|"triggersProcessing"| core2

    %% Plugin Extensions register with Application Module
    ext1 -->|"registersWith"| app
    ext2 -->|"registersWith"| app
    ext3 -->|"registersWith"| app
    ext4 -->|"registersWith"| app
    ext5 -->|"registersWith"| app

    %% Build & Deployment drives the build process for the Application Module
    build_gradle -->|"builds"| app
    build_src -->|"builds"| app
    gradle_node -->|"builds"| app
    jpackage_node -->|"packages"| app
    workflows -->|"triggersCI"| app

    %% Styles
    classDef core fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef app fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef gui fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef extension fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef build fill:#87CEFA,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click core1 "https://github.com/qupath/qupath/tree/main//qupath-core"
    click core2 "https://github.com/qupath/qupath/tree/main//qupath-core-processing"
    click app "https://github.com/qupath/qupath/tree/main//qupath-app"
    click gui "https://github.com/qupath/qupath/tree/main//qupath-gui-fx"
    click ext1 "https://github.com/qupath/qupath/tree/main//qupath-extension-bioformats"
    click ext2 "https://github.com/qupath/qupath/tree/main//qupath-extension-openslide"
    click ext3 "https://github.com/qupath/qupath/tree/main//qupath-extension-processing"
    click ext4 "https://github.com/qupath/qupath/tree/main//qupath-extension-script-editor"
    click ext5 "https://github.com/qupath/qupath/tree/main//qupath-extension-svg"
    click build_gradle "https://github.com/qupath/qupath/blob/main//build.gradle.kts"
    click build_src "https://github.com/qupath/qupath/tree/main//buildSrc"
    click gradle_node "https://github.com/qupath/qupath/tree/main//gradle"
    click jpackage_node "https://github.com/qupath/qupath/tree/main//jpackage"
    click workflows "https://github.com/qupath/qupath/tree/main/.github/workflows"
```
