# saurabh352/3tierapplicationdeplydevsecops architecture

> Architecture diagram of the GitHub repository saurabh352/3tierapplicationdeplydevsecops, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saurabh352/3tierapplicationdeplydevsecops
- Repository: https://github.com/saurabh352/3tierapplicationdeplydevsecops

## Overview

#### Purpose
This repository is an operational DevSecOps setup for deploying a three-tier application through Jenkins. It is primarily a sequence of shell scripts for provisioning Jenkins, Docker, Python/user prerequisites, vulnerability scanners, SonarQube integration, and Jenkins pipeline execution.

#### Entry Points and Execution Order
The numbered scripts express the intended bootstrap order:
1. Jenkins installation: `1st-Jenkins.sh`
2. Docker installation/configuration: `2nd-Docker.sh`
3. User and Python setup: `3rd-Adduser+python.sh`
4. Trivy installation/integration: `4th-Trivy.sh`
5. Docker Scout installation/integration: `5th-DockerScout.sh`
6. SonarQube setup: `6th-RunSonarQube`
7. Pipeline variants: `7th-Pipeline-WithoutTrivy`, `7th-pipeline-withTrivy`

#### Jenkins CI/CD Control Plane
Jenkins is the central orchestrator. The repository expects Jenkins plugins for pipeline execution, Docker interaction, Docker build steps, and SonarQube scanning. Pipeline definitions appear to be delivered or configured through:
- `7th-Pipeline-WithoutTrivy`
- `7th-pipeline-withTrivy`
- `1st-Jenkins.sh`

The two pipeline variants define a key policy boundary: standard build/deployment versus build/deployment including Trivy security scanning.

#### Container Build and Runtime Boundary
Docker is the packaging and runtime substrate for the application and likely for SonarQube. Docker setup is separated from Jenkins provisioning:
- `2nd-Docker.sh`
- `5th-DockerScout.sh`
- `6th-RunSonarQube`

Jenkins must be granted Docker access, making the Jenkins-to-Docker socket/API boundary a material privilege and security concern.

#### Security and Quality Gates
The repository introduces two container-security tools and one source-quality platform:
- Trivy vulnerability scanning: `4th-Trivy.sh`
- Docker Scout image analysis: `5th-DockerScout.sh`
- SonarQube service startup/integration: `6th-RunSonarQube`

The Trivy-enabled pipeline should act as the vulnerability-gating path before image promotion or deployment. SonarQube is an external quality-analysis service invoked from Jenkins through the SonarQube Scanner plugin.

#### Identity, Credentials, and External Services
Provisioning includes a dedicated user/Python environment in `3rd-Adduser+python.sh`, likely supporting Jenkins agent execution or deployment automation. External integrations include Docker Hub authentication and SonarQube token-based access. Credentials should be stored in Jenkins credentials management rather than embedded in scripts or pipeline definitions.

#### Primary Flow
Infrastructure bootstrap progresses from Jenkins and Docker installation to agent permissions, scanner installation, SonarQube startup, and pipeline configuration. At run time, Jenkins coordinates source analysis with SonarQube, container image build via Docker, security scanning through Trivy and/or Docker Scout, registry authentication/push, and final application deployment. The principal deployment decision point is whether the selected pipeline includes the Trivy security gate.

Main entry points: [`7th-pipeline-withTrivy`](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/7th-pipeline-withTrivy) (Trivy-gated pipeline), [`1st-Jenkins.sh`](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/1st-Jenkins.sh) (Install Jenkins), [`2nd-Docker.sh`](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/2nd-Docker.sh) (Install Docker), [`3rd-Adduser+python.sh`](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/3rd-Adduser%2Bpython.sh) (Set up user and Python)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bootstrap["Bootstrap scripts"]
  node_install_jenkins["Install Jenkins<br/>bootstrap script<br/>[1st-Jenkins.sh]"]
  node_install_docker["Install Docker<br/>bootstrap script<br/>[2nd-Docker.sh]"]
  node_setup_user_python["Set up user and Python<br/>bootstrap script"]
  node_install_trivy["Install Trivy<br/>bootstrap script<br/>[4th-Trivy.sh]"]
  node_install_scout["Install Docker Scout<br/>bootstrap script<br/>[5th-DockerScout.sh]"]
  node_start_sonarqube["Start SonarQube<br/>bootstrap script"]
end

subgraph group_jenkins["Jenkins control plane"]
  node_jenkins{{"Jenkins<br/>CI/CD orchestrator"}}
  node_jenkins_credentials[("Credentials store<br/>Jenkins credentials")]
  node_standard_pipeline["Standard pipeline<br/>pipeline definition"]
  node_trivy_pipeline["Trivy-gated pipeline<br/>pipeline definition"]
end

subgraph group_quality["Quality and security"]
  node_sonarqube[("SonarQube<br/>quality analysis service")]
  node_trivy{{"Trivy<br/>vulnerability scanner"}}
  node_docker_scout{{"Docker Scout<br/>image analysis service"}}
end

subgraph group_delivery["Container delivery"]
  node_docker{{"Docker engine<br/>container runtime"}}
  node_container_image["Container image<br/>build artifact"]
  node_docker_hub[("Docker Hub<br/>container registry")]
  node_application["Three-tier application<br/>deployment target"]
end

node_install_jenkins -->|"provisions"| node_jenkins
node_install_docker -->|"provisions"| node_docker
node_setup_user_python -->|"prepares execution access"| node_jenkins
node_install_trivy -->|"installs"| node_trivy
node_install_scout -->|"installs"| node_docker_scout
node_start_sonarqube -->|"starts"| node_sonarqube
node_jenkins -->|"runs"| node_standard_pipeline
node_jenkins -->|"runs"| node_trivy_pipeline
node_jenkins -->|"reads credentials"| node_jenkins_credentials
node_jenkins -->|"runs source analysis"| node_sonarqube
node_jenkins -->|"builds via Docker access"| node_docker
node_docker -->|"builds"| node_container_image
node_trivy_pipeline -->|"enforces scan"| node_trivy
node_trivy -->|"scans"| node_container_image
node_jenkins -.->|"analyzes image"| node_docker_scout
node_docker_scout -.->|"assesses"| node_container_image
node_container_image -->|"pushes"| node_docker_hub
node_jenkins_credentials -->|"registry authentication"| node_docker_hub
node_container_image -->|"deploys"| node_application

click node_install_jenkins "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/1st-Jenkins.sh"
click node_install_docker "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/2nd-Docker.sh"
click node_setup_user_python "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/3rd-Adduser%2Bpython.sh"
click node_install_trivy "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/4th-Trivy.sh"
click node_install_scout "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/5th-DockerScout.sh"
click node_start_sonarqube "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/6th-RunSonarQube"
click node_standard_pipeline "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/7th-Pipeline-WithoutTrivy"
click node_trivy_pipeline "https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/7th-pipeline-withTrivy"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_install_jenkins,node_install_docker,node_setup_user_python,node_install_trivy,node_install_scout,node_start_sonarqube toneBlue
class node_jenkins,node_jenkins_credentials,node_standard_pipeline,node_trivy_pipeline toneAmber
class node_sonarqube,node_trivy,node_docker_scout toneMint
class node_docker,node_container_image,node_docker_hub,node_application toneRose
```

## Components

### Bootstrap scripts

Numbered scripts establish the delivery environment.

- [Install Jenkins](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/1st-Jenkins.sh): bootstrap script · `1st-Jenkins.sh`
- [Install Docker](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/2nd-Docker.sh): bootstrap script · `2nd-Docker.sh`
- [Set up user and Python](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/3rd-Adduser%2Bpython.sh): bootstrap script · Prepares the execution identity and Python environment. · `3rd-Adduser+python.sh`
- [Install Trivy](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/4th-Trivy.sh): bootstrap script · `4th-Trivy.sh`
- [Install Docker Scout](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/5th-DockerScout.sh): bootstrap script · `5th-DockerScout.sh`
- [Start SonarQube](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/6th-RunSonarQube): bootstrap script · `6th-RunSonarQube`

### Jenkins control plane

Jenkins runs the selected delivery pipeline.

- **Jenkins**: CI/CD orchestrator · Selects and executes the configured pipeline.
- **Credentials store**: Jenkins credentials · Holds registry authentication and SonarQube tokens.
- [Standard pipeline](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/7th-Pipeline-WithoutTrivy): pipeline definition · Builds and deploys without the Trivy gate. · `7th-Pipeline-WithoutTrivy`
- [Trivy-gated pipeline](https://github.com/saurabh352/3tierapplicationdeplydevsecops/blob/main/7th-pipeline-withTrivy): pipeline definition · Requires vulnerability scanning before promotion. · `7th-pipeline-withTrivy`

### Quality and security

Analysis services and image-security gates.

- **SonarQube**: quality analysis service
- **Trivy**: vulnerability scanner
- **Docker Scout**: image analysis service

### Container delivery

Image publication and application rollout.

- **Docker engine**: container runtime · Builds images and hosts containerized services.
- **Container image**: build artifact
- **Docker Hub**: container registry
- **Three-tier application**: deployment target

## Connections

- Install Jenkins → Jenkins: provisions
- Install Docker → Docker engine: provisions
- Set up user and Python → Jenkins: prepares execution access
- Install Trivy → Trivy: installs
- Install Docker Scout → Docker Scout: installs
- Start SonarQube → SonarQube: starts
- Jenkins → Standard pipeline: runs
- Jenkins → Trivy-gated pipeline: runs
- Jenkins → Credentials store: reads credentials
- Jenkins → SonarQube: runs source analysis
- Jenkins → Docker engine: builds via Docker access · This is the privileged Docker API/socket boundary.
- Docker engine → Container image: builds
- Trivy-gated pipeline → Trivy: enforces scan
- Trivy → Container image: scans
- Jenkins → Docker Scout: analyzes image
- Docker Scout → Container image: assesses
- Container image → Docker Hub: pushes
- Credentials store → Docker Hub: registry authentication
- Container image → Three-tier application: deploys
