# sonarsource/sonar-custom-plugin-example architecture

> Architecture diagram of the GitHub repository sonarsource/sonar-custom-plugin-example, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonarsource/sonar-custom-plugin-example
- Repository: https://github.com/sonarsource/sonar-custom-plugin-example

## Overview

##### Main Components Identification
The system should be divided into two primary sections:

A. Backend Components (Java):
- Plugin Core (ExamplePlugin.java)
- Feature Modules:
- Hooks (Quality Gate Status)
- Languages (Foo Language Support)
- Measures (Size computations)
- Rules (Java analysis rules)
- Settings (Properties and configurations)
- Web (Page definitions)

B. Frontend Components (JavaScript):
- Four Extension Pages:
- Portfolio Page (React)
- Admin Page (React)
- Project Page (Backbone)
- Global Page (Vanilla JS)

**┌─ SonarQube Server ──────────────────────────────────────┐**

- ┌─ Example Plugin ─────────────────────────────────┐   │

- Frontend Layer                                  │   │
- Portfolio Page                              │   │
- Admin Page                                  │   │
- Project Page                                │   │
- Global Page                                 │   │

- Backend Layer                                  │   │
- Plugin Core                                 │   │
- Hooks                                       │   │
- Languages                                   │   │
- Measures                                    │   │
- Rules                                       │   │
- Settings                                    │   │
- Web Definitions                             │   │

- ┘   │

- ┘

##### Component Relationships

- Frontend-Backend communication through SonarQube's exposed APIs
- Plugin integration points with SonarQube Server
- Internal component dependencies

##### Technical Details
- NodeJS/Java environment requirements
- Build tools (Maven, Webpack)
- Framework versions (React 16)
- Extension point registration mechanism
- Static resource locations

##### Integration Points
- How the plugin connects to SonarQube's extension system
- Exposed helper APIs (window.SonarRequest)
- Demonstrate localization integration
- Build output placement (extensions/plugins/)

- High-level architecture visibility
- Detailed component relationships
- Build/deployment flow
- Runtime behavior

This plugin-specific architecture requires special attention to:
- Extension point registration
- Resource bundling
- Multi-language support
- Frontend-Backend integration
- Build process flow

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph SQ[SonarQube Server]
        subgraph EP[Example Plugin]
            subgraph FL[Frontend Layer]
                RP["React Pages<br/>(Admin/Portfolio)"]:::frontend
                BP["Backbone<br/>Project Page"]:::frontend
                VP["Vanilla JS<br/>Global Page"]:::frontend
                CU["Common Utils"]:::frontend
            end

            subgraph BL[Backend Layer]
                PC["Plugin Core<br/>(ExamplePlugin)"]:::backend
                
                subgraph Modules[Plugin Modules]
                    HK["Hooks"]:::backend
                    LG["Languages"]:::backend
                    MS["Measures"]:::backend
                    RL["Rules"]:::backend
                    ST["Settings"]:::backend
                    WD["Web Definitions"]:::backend
                end
            end

            subgraph BC[Build Configuration]
                WP["Webpack"]:::build
                JC["Jest"]:::build
                BS["Build Scripts"]:::build
            end

            subgraph RS[Resources]
                L10["Localization"]:::resource
            end
        end
    end

    %% Relationships
    RP & BP & VP --> CU
    CU --> PC
    PC --> HK & LG & MS & RL & ST & WD
    WP & JC --> BS

    %% Click Events
    click PC "https://github.com/SonarSource/sonar-custom-plugin-example/blob/10.x/src/main/java/org/sonarsource/plugins/example/ExamplePlugin.java"
    click HK "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/java/org/sonarsource/plugins/example/hooks/"
    click LG "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/java/org/sonarsource/plugins/example/languages/"
    click MS "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/java/org/sonarsource/plugins/example/measures/"
    click RL "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/java/org/sonarsource/plugins/example/rules/"
    click ST "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/java/org/sonarsource/plugins/example/settings/"
    click WD "https://github.com/SonarSource/sonar-custom-plugin-example/blob/10.x/src/main/java/org/sonarsource/plugins/example/web/MyPluginPageDefinition.java"
    click RP "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/js/portfolio_page/"
    click BP "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/js/project_page/"
    click VP "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/js/global_page/"
    click CU "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/js/common/"
    click WP "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/conf/webpack/"
    click JC "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/conf/jest/"
    click BS "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/scripts/"
    click L10 "https://github.com/SonarSource/sonar-custom-plugin-example/tree/10.x/src/main/resources/org/sonar/l10n/"

    %% Styling
    classDef frontend fill:#2196F3,stroke:#1565C0,color:white
    classDef backend fill:#4CAF50,stroke:#2E7D32,color:white
    classDef build fill:#FFA726,stroke:#F57C00,color:white
    classDef resource fill:#9C27B0,stroke:#6A1B9A,color:white

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        B["Backend Component"]:::backend
        BU["Build Component"]:::build
        R["Resource"]:::resource
    end
```
