# imran9m/python-sonarqube-example architecture

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

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

## Overview

##### Project Type Analysis
This is a quality assurance and testing infrastructure project that demonstrates the integration of various code quality tools with SonarQube for a simple Python calculator application.

##### Main Components

A. Development Environment:
- Python Source Code (calculator.py)
- Python Test Files (test_calculator.py)
- Virtual Environment (.penvsonar)

B. Quality Analysis Tools:
- Pylint (Static Code Analysis)
- Bandit (Security Analysis)
- Coverage.py (Code Coverage)
- Pytest (Testing Framework)

C. Infrastructure:
- Docker Network (sonar-network)
- SonarQube Container
- Sonar Scanner Container

##### Source Code Layer (Green Rectangle)
- Calculator.py and test_calculator.py
- Requirements files
- Virtual environment

##### Quality Analysis Layer (Blue Rectangle)
- Pylint → pylint-report.txt
- Bandit → bandit-report.json
- Coverage/Pytest → coverage.xml, pytest-report.xml

##### Infrastructure Layer (Orange Rectangle)
- Docker Network
- SonarQube Container (Port 9000)
- Sonar Scanner Container

Relationships:
**Source Code → Quality Tools → Reports → Sonar Scanner → SonarQube**

##### Additional Elements

- File types (source, test, report)
- Container components
- Network connections
- Tool purposes

##### Important Details

- Docker network name: sonar-network
- SonarQube port: 9000
- Volume mounting points
- Environment variables

## Diagram (Mermaid)

```mermaid
flowchart TB
    title[Python SonarQube Integration Architecture]
    
    subgraph Source
        calc["Calculator Source"]
        test["Test Files"]
        reqs["Test Dependencies"]
        sonarconf["SonarQube Config"]
    end
    
    subgraph "Quality Analysis Tools"
        pylint["Pylint Analysis"]
        bandit["Bandit Security Scan"]
        coverage["Coverage.py"]
        pytest["Pytest Framework"]
    end
    
    subgraph "Analysis Reports"
        pylintReport["pylint-report.txt"]
        banditReport["bandit-report.json"]
        coverageReport["coverage.xml"]
        pytestReport["pytest-report.xml"]
    end
    
    subgraph "Infrastructure"
        network["Docker Network<br/>(sonar-network)"]
        scanner["Sonar Scanner<br/>Container"]
        sonarqube["SonarQube Server<br/>(Port 9000)"]
    end
    
    %% Relationships
    calc --> pylint
    calc --> bandit
    calc --> coverage
    test --> pytest
    
    pylint --> pylintReport
    bandit --> banditReport
    coverage --> coverageReport
    pytest --> pytestReport
    
    pylintReport --> scanner
    banditReport --> scanner
    coverageReport --> scanner
    pytestReport --> scanner
    
    scanner --> sonarqube
    network --- scanner
    network --- sonarqube
    
    %% Click Events
    click calc "https://github.com/imran9m/python-sonarqube-example/blob/main/src/calculator.py"
    click test "https://github.com/imran9m/python-sonarqube-example/blob/main/tests/test_calculator.py"
    click sonarconf "https://github.com/imran9m/python-sonarqube-example/blob/main/sonar-project.properties"
    click reqs "https://github.com/imran9m/python-sonarqube-example/blob/main/requirements-test.txt"
    
    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef source fill:#e1f5e1,stroke:#333
    classDef tools fill:#e1e1f5,stroke:#333
    classDef reports fill:#f5e1e1,stroke:#333
    classDef infra fill:#f5f5e1,stroke:#333
    
    class calc,test,reqs,sonarconf source
    class pylint,bandit,coverage,pytest tools
    class pylintReport,banditReport,coverageReport,pytestReport reports
    class network,scanner,sonarqube infra
    
    %% Legend
    subgraph Legend
        source1["Source Files"]:::source
        tools1["Analysis Tools"]:::tools
        reports1["Report Files"]:::reports
        infra1["Infrastructure"]:::infra
    end
```
