# zetaaztra/gitlab_cicd_sonarqube_aws_eks architecture

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

- Interactive diagram: https://gitdiagram.com/zetaaztra/gitlab_cicd_sonarqube_aws_eks
- Repository: https://github.com/zetaaztra/gitlab_cicd_sonarqube_aws_eks

## Overview

##### Main Components
- Developer Actions: Represent the manual processes such as creating Issues, feature branches, and Merge Requests in GitLab.
– Triggering on Merge Requests to the main branch.
– Jobs that include unit tests (Test Job), SonarQube code analysis (SonarQube Scan Job), and, if all tests pass, building a Docker image and pushing it to DockerHub.
- SonarQube Server: As a separate component (often self-hosted or deployed via Docker Compose as noted) that receives analysis reports from the CI/CD.
- DockerHub Registry: Where a successful build’s Docker image is pushed, which is then later used for deployment.
- AWS EKS Cluster: The Kubernetes-based environment where the Flask web application will finally run.
- ArgoCD: The deployment orchestrator inside the AWS environment that pulls updated configurations/images and deploys the application. Also note the involvement of an external LoadBalancer for both ArgoCD’s UI access and the Flask application itself.

##### Relationships and Data Flow
- Merge Request: When a merge request is made, it triggers the GitLab CI/CD pipeline.
- CI/CD Pipeline Flow:
- First, the Testing job runs.
- Then, a SonarQube Scan job verifies code quality – even if the build fails, a report gets sent to the SonarQube server.
- On passing, the pipeline builds a Docker image and pushes it to DockerHub.
- Deployment Flow:
- Post-build, the configuration is picked up by ArgoCD.
- ArgoCD applies updates to AWS EKS, which in turn creates a new LoadBalancer service for the Flask app.
- The LoadBalancer then exposes the updated Flask web application to external users.
- Connection with SonarQube: Show how CI/CD communicates with SonarQube by sending scan results, regardless of the overall CI/CD outcome.

##### Architectural Patterns and Design Principles
- Modular Pipeline: The clear division between testing, scanning, image build, and deployment points to a modular pipeline design.
- Separation of Concerns: Each component (code repository, CI/CD process, testing/analysis, container registry, and cluster deployment) is isolated yet connected via defined interfaces (APIs, pipelines, webhooks).
- Automated Deployment with GitOps: The use of ArgoCD for continuous deployment into AWS EKS emphasizes a GitOps pattern.
- Fault Tolerance and Feedback Loops: The integration of SonarQube ensures that even failed jobs provide useful feedback via code quality reports.

##### Specify Relevant Technologies and Tools
- GitLab as the source code repository and CI/CD engine.
- Python/Flask for the web application.
- SonarQube for static code analysis.
- Docker for containerization.
- DockerHub as the image registry.
- AWS EKS for container orchestration.
- ArgoCD to manage Kubernetes application deployments.
- (Optionally) LoadBalancer services in AWS for exposing the applications.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Subgraph: Development
    subgraph "Development"
        Developer["Developer (issues,branches,merge_requests)"]:::user
    end

    %% Subgraph: CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        GitLabRepo["GitLab Repository & CI/CD Pipeline"]:::ci
        TestJob["Test Job (unit_tests)"]:::ci
        SonarJob["SonarQube Scan Job"]:::ci
        DockerJob["Docker Build & Push Job"]:::ci
    end

    %% Subgraph: Quality Analysis
    subgraph "Quality Analysis"
        SonarQube["SonarQube Server"]:::analysis
    end

    %% Subgraph: Deployment
    subgraph "Deployment"
        DockerHub["DockerHub Registry"]:::container
        ArgoCD["ArgoCD (GitOps)"]:::deployment
        EKSC["AWS EKS Cluster"]:::deployment
        LoadBalancer["LoadBalancer (Flask_App)"]:::deployment
    end

    %% Connections: Development -> CI/CD Pipeline
    Developer -->|"create_merge_request"| GitLabRepo

    %% CI/CD Pipeline flow
    GitLabRepo -->|"trigger_pipeline"| TestJob
    TestJob -->|"on_success"| SonarJob
    SonarJob -->|"send_analysis"| SonarQube
    SonarJob -->|"if_pass"| DockerJob

    %% Deployment flow
    DockerJob -->|"push_image"| DockerHub
    DockerHub -->|"trigger_deployment"| ArgoCD
    ArgoCD -->|"deploy_update"| EKSC
    EKSC -->|"expose_app"| LoadBalancer

    %% Click events for mapped components
    click GitLabRepo "https://github.com/zetaaztra/gitlab_cicd_sonarqube_aws_eks/blob/main/README.md"

    %% Styles
    classDef user fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef ci fill:#aed6f1,stroke:#1f618d,stroke-width:2px;
    classDef analysis fill:#f5cba7,stroke:#b9770e,stroke-width:2px;
    classDef container fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
    classDef deployment fill:#a9dfbf,stroke:#196f3d,stroke-width:2px;
```
