# tmontaigu/cloudcompare-pythonruntime architecture

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

- Interactive diagram: https://gitdiagram.com/tmontaigu/cloudcompare-pythonruntime
- Repository: https://github.com/tmontaigu/cloudcompare-pythonruntime

## Overview

##### Main Components

- Core Application & UI Layer
- Derived mainly from the C++ code in the src directory.
- Components include UI dialogs (under src/Ui) like AboutDialog, ActionLauncher, PythonEditor, and PackageManager.
- The CodeEditor module is its own subcomponent, providing a text/code editing interface, managing settings, and context menus.

- Python Integration Subsystem
- This subsystem is made up of several modules in the src directory:
- PythonInterpreter, PythonActionLauncher, PythonPlugin, PythonPluginManager, and PythonRepl.
- Their function is to embed, initialize, and manage a Python interpreter within the CloudCompare runtime.
- The integration is further supported by the “PythonRuntimeSettings” for configuration management.
- The pybind11 dependency (mentioned in the README) is the bridge between the C++ layers and Python.

- Wrappers for CloudCompare’s Core Functionalities
- Located under the wrapper directory, with two parts:
▪ cccorelib: This wraps essential CloudCompare functionalities in C++ and provides a lower-level API.
▪ pycc: This provides higher-level Python APIs (with a focus on plugins), accessible via a Python package.
- These wrappers likely expose the C++ backend functionalities to Python scripts and plugin modules.

- Plugin and Script Examples
- The “script_examples” folder includes various automation scripts and demos.
- These examples, along with the “plugin_examples” subdirectory, demonstrate how external plugins can be integrated and interact with the runtime.
- They serve as use-case scenarios for the Python API exposed by the wrappers.

- Build, Testing, and Deployment Infrastructure
- CMake is the primary build tool, with configuration files in CMakeLists.txt at several levels (root, installer, src, wrapper, etc.) and additional cmake helpers.
- Dockerfiles (Debug & Release) and GitHub workflows provide CI/CD pipelines.
- The installer directory (containing scripts, CMake configs, and WiX installer files) manages packaging for Windows.
- The tests directory includes a set of unit tests and script tests to validate core functionalities.
- Documentation (in docs) is generated using Sphinx (with conf.py) and integrated with GitHub pages.

##### Relationships and Interactions

- UI Layer ↔ Python Integration
- The UI components trigger actions (e.g., launching the Python REPL, editing scripts) that are carried out by the Python Integration subsystem.
- The PythonActionLauncher and PackageManager essentially serve as a bridge from user interactions to Python-driven automation.

- Core Application ↔ Wrappers
- The core C++ application interacts with the wrapper libraries (cccorelib and pycc) to expose CloudCompare’s features.
- This design follows a plugin architecture where the C++ backend exposes flexibility for Python plugins to extend its functionality.

- Python Plugins and External Scripts ↔ Python Interpreter
- Scripts and plugins (from script_examples and plugin_examples) run inside the embedded Python runtime.
- They call functions provided by the Python wrappers to interact with CloudCompare’s internals.

- Build/Deployment & Testing Infrastructure
- Build files (CMakeLists.txt, Dockerfiles, GitHub workflows) coordinate version control, continuous integration, and deployment for both the C++ and Python components.
- Automated tests ensure integration consistency between components (tests verifying command-line and API functionalities).

##### Architectural Patterns and Design Principles

- Modular and Layered Design
- Clear separation between UI, runtime logic, and binding layers.
- Dedicated directories for wrappers, examples, and tests aid in modularity.

- Plugin Architecture and Extensibility
- The system allows different plugins or scripts (both in C++ and Python) to be dynamically loaded and executed within the runtime.
- This is achieved using dynamic binding via pybind11.

- Cross-Platform Build and Deployment
- Use of CMake, Docker, and WiX installer files indicates emphasis on cross-platform compatibility and streamlined deployment.

##### Relevant Technologies, Frameworks, and Libraries

- C++ with Qt (likely) for UI components.
- Python integrated via an embedded interpreter, with pybind11 bridging the gap.
- CMake as the build system.
- GitHub workflows for CI/CD and Dockerfiles for environment consistency.
- WiX toolset for Windows installer packaging.
- Sphinx for documentation (as inferred from docs/conf.py).
- Additional tools like clang-format, cmake-format for code style enforcement.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application & UI Layer
    subgraph "Core Application & UI Layer"
        CC_UI["CloudCompare UI (src)"]:::core
        UIDialog["UI Dialogs (src/Ui)"]:::core
        CodeEditor["CodeEditor Module (src/CodeEditor)"]:::core
    end

    %% Python Integration Subsystem
    subgraph "Python Integration Subsystem"
        PyInterp["Python Interpreter & Integration (src)"]:::python
    end

    %% Wrappers for CloudCompare’s Core Functionalities
    subgraph "Wrappers"
        CCCoreLib["cccorelib (Wrapper)"]:::wrapper
        PyCC["pycc (Python API)"]:::wrapper
    end

    %% Plugin and Script Examples
    subgraph "Plugin and Script Examples"
        Scripts["Plugin and Script Examples (script_examples)"]:::plugin
    end

    %% Build, Testing & Deployment Infrastructure
    subgraph "Build, Testing & Deployment Infrastructure"
        BuildSys["Build System & CI/CD (CMake, Docker, .github/workflows)"]:::build
        Installer["Installer & Packaging (installer)"]:::build
        Tests["Testing (tests)"]:::build
        Docs["Documentation (docs)"]:::build
        InfraSupport["Infrastructure Support"]:::build
    end

    %% Relationships between Core Application & UI Layer and Python Integration
    CC_UI -->|"triggers"| PyInterp
    UIDialog -->|"launches"| PyInterp
    CodeEditor -->|"executes"| PyInterp

    %% Relationships between Core Application and Wrappers
    CC_UI -->|"accesses"| CCCoreLib

    %% Relationships between Python Integration and Wrappers
    PyInterp -->|"calls"| PyCC
    PyInterp -->|"calls"| CCCoreLib

    %% Relationship between Plugin Examples and Python Integration
    Scripts -->|"runs_on"| PyInterp

    %% Build/Deployment Infrastructure supporting main components
    InfraSupport ---|"builds"| CC_UI
    InfraSupport ---|"builds"| PyInterp
    InfraSupport ---|"packages"| CCCoreLib
    InfraSupport ---|"packages"| PyCC
    InfraSupport ---|"tests"| Scripts

    %% Styling classes
    classDef core fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef python fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef wrapper fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef plugin fill:#F5CBA7,stroke:#C0392B,stroke-width:2px;
    classDef build fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;

    %% Click Events for Core Application & UI Layer
    click CC_UI "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/src"
    click UIDialog "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/src/Ui"
    click CodeEditor "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/src/CodeEditor"

    %% Click Event for Python Integration Subsystem
    click PyInterp "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/src/PythonInterpreter.cpp/h"

    %% Click Events for Wrappers
    click CCCoreLib "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/wrapper/cccorelib"
    click PyCC "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/wrapper/pycc"

    %% Click Event for Plugin and Script Examples
    click Scripts "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/script_examples"

    %% Click Events for Build, Testing & Deployment Infrastructure
    click BuildSys "https://github.com/tmontaigu/cloudcompare-pythonruntime/blob/master/CMakeLists.txt"
    click Installer "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/installer"
    click Tests "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/tests"
    click Docs "https://github.com/tmontaigu/cloudcompare-pythonruntime/tree/master/docs"
```
