# hustlerx01/automated-security-pipeline-devsecops architecture

> Architecture diagram of the GitHub repository hustlerx01/automated-security-pipeline-devsecops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hustlerx01/automated-security-pipeline-devsecops
- Repository: https://github.com/hustlerx01/automated-security-pipeline-devsecops

## Overview

##### Project Type & Purpose
- This is a DevSecOps CI/CD pipeline repository embedding:
- A Spring Boot microservice (DemoApplication) built with Maven
- A Jenkins declarative Pipeline (Jenkinsfile + vars/helloWorld.groovy)
- Infrastructure manifests (Dockerfile, spring-boot-deployment.yaml)
- Documentation and setup scripts for Jenkins, SonarQube, Vault, Docker, Trivy, AWS S3, Kubernetes (Minikube), and Slack.
- Purpose: Automate code build, test, static analysis, containerization, vulnerability scanning, artifact publishing, deployment to Kubernetes, and notifications—while enforcing security best practices.

##### File Structure
- src/main/java/com/example/demo → Spring Boot application
- pom.xml & .mvn/ → Maven build config
- Jenkinsfile & vars/helloWorld.groovy → CI/CD pipeline definition & shared library
- Dockerfile → container image build
- spring-boot-deployment.yaml → Kubernetes Deployment & Service
- Other top-level: SonarQube, Vault, Slack, AWS integration scripts

##### Extract Key Architectural Insights from README
- Pipeline stages: Checkout → Build/Test (Maven/JUnit) → SonarQube scan & quality gate → Docker build → Trivy image scan → Push reports to AWS S3 → Push image to Docker Hub → Deploy to Kubernetes → Notify Slack
- External systems: GitHub (source), SonarQube server, Vault (secret store), AWS S3, Docker Hub, Kubernetes cluster (Minikube), Slack workspace
- Credentials managed via Jenkins credentials store & Vault AppRole

##### Main Components & Their Relationships
a. Source Control
- GitHub repo holds code, pipeline, infra-as-code
↓ triggers
b. CI/CD Orchestrator
- Jenkins master (with pipeline script, plugins, credentials)
1) Checks out code
2) Invokes Maven for compile & JUnit tests
3) Calls SonarQube scanner → SonarQube server → Quality Gate webhook back to Jenkins
4) Builds Docker image (Docker daemon)
5) Runs Trivy container scanner
6) Uses AWS CLI to upload the Trivy HTML report to S3
7) Logs into Docker Hub → pushes images
8) Applies Kubernetes manifests via kubernetesDeploy plugin (using kubeconfig credentials)
9) Notifies Slack via slackSend
c. Static Analysis & Quality
- SonarQube server & database (Postgres)
d. Secrets Management
- Hashicorp Vault (AppRole) → supplies Docker Hub, AWS, SonarQube, Slack secrets to Jenkins
e. Artifact Stores
- AWS S3 (reports), Docker Hub (images)
f. Runtime Environment
- Kubernetes cluster (Minikube) running the Spring Boot service
g. Notifications
- Slack channel reporting build/deploy status

##### Architectural Patterns & Design Principles
- “Pipeline as Code” in Jenkinsfile for reproducibility
- Immutable artifact promotion: container built once, scanned, then deployed
- Separation of concerns: build/test/scan/deploy stages
- Secrets externalized in Vault, retrieved at runtime
- Single‐responsibility microservice (Spring Boot) behind Kubernetes Service
- Observability via SonarQube dashboards, S3‐hosted Trivy reports, and Slack notifications

##### Detailed Element Checklist
- Source Control (GitHub)
- CI/CD Orchestrator (Jenkins + Shared Library)
- Build Tool & Tests (Maven, JUnit)
- Static Analysis (SonarQube + Quality Gate)
- Containerization (Dockerfile, Docker daemon)
- Vulnerability Scanner (Trivy)
- Artifact & Report Stores (AWS S3, Docker Hub)
- Secret Management (Hashicorp Vault)
- Container Orchestration (Kubernetes cluster)
- Notification Channel (Slack)
- Credentials & Configs (Jenkins Credentials, Vault AppRole, kubeconfig)
- Interactions: who calls whom, where data/files flow, where secrets are fetched

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Source Control
    subgraph "Source Control"
        GH["GitHub Repository"]:::external
    end

    %% CI/CD Orchestrator
    subgraph "CI/CD Orchestrator"
        Jenkins["Jenkins Master"]:::compute
        SharedLib["Shared Library"]:::compute
    end

    %% Build & Test Stage
    subgraph "Build & Test" 
        Maven["Maven"]:::buildTest
        JUnit["JUnit Tests"]:::buildTest
    end

    %% Static Analysis Stage
    subgraph "Static Analysis"
        SonarQube["SonarQube Server"]:::security
        Postgres["Postgres DB"]:::datastore
    end

    %% Containerization Stage
    subgraph "Containerization"
        DockerDaemon["Docker Daemon"]:::container
        DockerfileNode["Dockerfile"]:::container
    end

    %% Security Scanning Stage
    subgraph "Security Scanning"
        Trivy["Trivy Scanner"]:::security
        S3["AWS S3 (Reports)"]:::datastore
    end

    %% Artifact Registry
    subgraph "Artifact Registry"
        DockerHub["Docker Hub"]:::external
        S3
    end

    %% Deployment Stage
    subgraph "Deployment"
        K8s["Kubernetes Cluster (Minikube)"]:::deploy
        YAML["spring-boot-deployment.yaml"]:::deploy
    end

    %% Secrets Management
    Vault["Hashicorp Vault"]:::external

    %% Notifications
    Slack["Slack Channel"]:::notify

    %% Spring Boot Microservice
    subgraph "Spring Boot Microservice"
        DemoApp["DemoApplication.java"]:::compute
        AppProps["application.properties"]:::compute
        Jar["demo-0.0.1-SNAPSHOT.jar"]:::compute
    end

    %% Documentation & Scripts
    subgraph "Docs & Scripts"
        SonarDoc["sonarqube_installation_with_postgres_database.md"]:::external
        JenkinsDoc["Jenkins_installation.md"]:::external
        DockerDoc["docker_installation.md"]:::external
        ImagesDir["Images/"]:::external
    end

    %% Pipeline Flow
    GH -->|"code commit triggers"| Jenkins
    Jenkins -->|"checkout & build"| Maven
    Maven -->|"runs"| JUnit
    Jenkins -->|"invoke scan"| SonarQube
    SonarQube -->|"stores metrics"| Postgres
    SonarQube -->|"quality gate"| Jenkins
    Jenkins -->|"build image"| DockerDaemon
    DockerDaemon -->|"uses"| DockerfileNode
    Jenkins -->|"scan image"| Trivy
    Trivy -->|"upload report"| S3
    Jenkins -->|"push image"| DockerHub
    Jenkins -->|"deploy"| K8s
    K8s -->|"applies manifest"| YAML
    Jenkins -->|"fetch secrets"| Vault
    Jenkins -->|"notify"| Slack
    K8s -->|"runs service"| DemoApp
    DemoApp -->|"config from"| AppProps
    Jenkins -->|"produce artifact"| Jar

    %% Click Events
    click DemoApp "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/src/main/java/com/example/demo/DemoApplication.java"
    click AppProps "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/src/main/resources/application.properties"
    click Jar "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/target/demo-0.0.1-SNAPSHOT.jar"
    click Maven "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/pom.xml"
    click mvnw "https://github.com/hustlerx01/automated-security-pipeline-devsecops/tree/main/mvnw"
    click mwr "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/.mvn/wrapper/maven-wrapper.jar"
    click mwp "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/.mvn/wrapper/maven-wrapper.properties"
    click mvwcmd "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/mvnw.cmd"
    click Jenkinsfile "https://github.com/hustlerx01/automated-security-pipeline-devsecops/tree/main/Jenkinsfile"
    click SharedLib "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/vars/helloWorld.groovy"
    click DockerfileNode "https://github.com/hustlerx01/automated-security-pipeline-devsecops/tree/main/Dockerfile"
    click YAML "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/spring-boot-deployment.yaml"
    click JUnit "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/src/test/java/com/example/demo/DemoApplicationTests.java"
    click SonarDoc "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/sonarqube_installation_with_postgres_database.md"
    click JenkinsDoc "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/Jenkins_installation.md"
    click DockerDoc "https://github.com/hustlerx01/automated-security-pipeline-devsecops/blob/main/docker_installation.md"
    click ImagesDir "https://github.com/hustlerx01/automated-security-pipeline-devsecops/tree/main/Images/"

    %% Styles
    classDef compute fill:#f9f,stroke:#333,stroke-width:1px
    classDef datastore fill:#ccf,stroke:#333,stroke-width:1px
    classDef external fill:#cfc,stroke:#333,stroke-width:1px
    classDef buildTest fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef security fill:#90EE90,stroke:#333,stroke-width:1px
    classDef container fill:#FFA500,stroke:#333,stroke-width:1px
    classDef deploy fill:#DDA0DD,stroke:#333,stroke-width:1px
    classDef notify fill:#20B2AA,stroke:#333,stroke-width:1px
```
