# donhui/python-sonarqube architecture

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

- Interactive diagram: https://gitdiagram.com/donhui/python-sonarqube
- Repository: https://github.com/donhui/python-sonarqube

## Overview

##### Main components
- Client Scripts: These include files like generateReport.py, issues_send_dingding.py, sonarqube_branches_clean.py, and sonarqube_users_group.py. They serve as entry points and make use of the core library functions.
- Core Library (sonarqube_utils): This directory contains modules that encapsulate various SonarQube functionalities:
- Base and common modules (base_api.py, common.py, config.py, exceptions.py) managing API connections, configuration, and error handling.
- Functional modules such as ce.py, components.py, duplications.py, issues.py, measures.py, notifications.py, permissions.py, and others, which represent different SonarQube API endpoints (e.g., managing projects, quality profiles, user groups, project branches, and rules).
- External Service: The actual SonarQube server, which is being interfaced via the web API.

##### Out interactions and relationships
- Within the sonarqube_utils library, illustrate how the utility modules depend on a foundational base (base_api and common modules) for handling standardized API calls, configuration, and error handling.

##### Architectural patterns and design principles
- Modular design: The separation of concerns is evident by grouping related SonarQube API functionalities into individual modules.
- Wrapping/Facade pattern: The utility modules provide a simplified interface for interacting with the complex underlying SonarQube API.
- Configuration and Error-Handling practices are centralized in specific modules (config.py and exceptions.py), ensuring consistency across the library.

##### Relevant technologies and tools
- Python as the primary programming language.
- External dependencies listed in requirements.txt (even if not explicitly detailed here, they support the functioning of the API calls).
- The SonarQube web API as an external component with which this library interacts.

##### Detail elements to be included
- Clear labels for each component (Client Scripts, Core API Modules, External SonarQube Server).
- How commands and data pass from the client scripts to the core library and onward to the SonarQube server.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Scripts
    subgraph "Client Scripts"
        GR["generateReport.py"]
        ISD["issues_send_dingding.py"]
        SBC["sonarqube_branches_clean.py"]
        SUG["sonarqube_users_group.py"]
    end

    %% Core Library
    subgraph "SonarQube Utils Library"
        %% Base and Common Modules
        subgraph "Base & Common Modules"
            baseAPI["base_api.py"]
            COMMON["common.py"]
            CONFIG["config.py"]
            EXCEPT["exceptions.py"]
        end

        %% Functional Modules
        subgraph "Functional Modules"
            CE["ce.py"]
            COMPONENTS["components.py"]
            DUPLICATIONS["duplications.py"]
            ISSUES["issues.py"]
            MEASURES["measures.py"]
            NOTIFICATIONS["notifications.py"]
            PERMISSIONS["permissions.py"]
            PROJ_BRANCHES["project_branches.py"]
            PROJ_LINKS["project_links.py"]
            PROJECTS["projects.py"]
            QUALITYGATES["qualitygates.py"]
            QUALITYPROFILES["qualityprofiles.py"]
            RULES["rules.py"]
            USER_GROUPS["user_groups.py"]
            USERS["users.py"]
        end
    end

    %% External Service
    SQ["SonarQube Server"]

    %% Interactions: Client Scripts call Functional Modules (using ISSUES as representative)
    GR -->|"calls"| ISSUES
    ISD -->|"calls"| ISSUES
    SBC -->|"calls"| ISSUES
    SUG -->|"calls"| ISSUES

    %% Functional Modules depend on Base module (representative dependency)
    ISSUES -.->|"depends"| baseAPI

    %% Functional Modules communicate with External Service
    ISSUES -->|"API_request"| SQ

    %% Styles
    classDef client fill:#a0c4ff,stroke:#000,stroke-width:2px;
    classDef library fill:#caffbf,stroke:#000,stroke-width:2px;
    classDef external fill:#ffadad,stroke:#000,stroke-width:2px;

    class GR,ISD,SBC,SUG client;
    class baseAPI,COMMON,CONFIG,EXCEPT,CE,COMPONENTS,DUPLICATIONS,ISSUES,MEASURES,NOTIFICATIONS,PERMISSIONS,PROJ_BRANCHES,PROJ_LINKS,PROJECTS,QUALITYGATES,QUALITYPROFILES,RULES,USER_GROUPS,USERS library;
    class SQ external;

    %% Click Events for Client Scripts
    click GR "https://github.com/donhui/python-sonarqube/blob/master//generateReport.py"
    click ISD "https://github.com/donhui/python-sonarqube/blob/master//issues_send_dingding.py"
    click SBC "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_branches_clean.py"
    click SUG "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_users_group.py"

    %% Click Events for Base and Common Modules
    click baseAPI "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/base_api.py"
    click COMMON "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/common.py"
    click CONFIG "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/config.py"
    click EXCEPT "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/exceptions.py"

    %% Click Events for Functional Modules
    click CE "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/ce.py"
    click COMPONENTS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/components.py"
    click DUPLICATIONS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/duplications.py"
    click ISSUES "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/issues.py"
    click MEASURES "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/measures.py"
    click NOTIFICATIONS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/notifications.py"
    click PERMISSIONS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/permissions.py"
    click PROJ_BRANCHES "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/project_branches.py"
    click PROJ_LINKS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/project_links.py"
    click PROJECTS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/projects.py"
    click QUALITYGATES "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/qualitygates.py"
    click QUALITYPROFILES "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/qualityprofiles.py"
    click RULES "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/rules.py"
    click USER_GROUPS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/user_groups.py"
    click USERS "https://github.com/donhui/python-sonarqube/blob/master//sonarqube_utils/users.py"
```
