# dhiresh-git/java-webapp-ci-cd-project architecture

> Architecture diagram of the GitHub repository dhiresh-git/java-webapp-ci-cd-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhiresh-git/java-webapp-ci-cd-project
- Repository: https://github.com/dhiresh-git/java-webapp-ci-cd-project

## Overview

##### Project type and purpose
- From the file tree and README, this is a Java Spring Boot web application (com.example.demo) whose sole controller (`WebAppController.java`) serves HTTP requests.
- The primary focus of the project is on setting up an automated CI/CD pipeline: whenever code is pushed to GitHub, Jenkins picks it up, runs Maven build/tests, builds a Docker image, and deploys it to an AWS EC2 instance.

##### File structure
- Top‐level files:
- `pom.xml` – Maven build descriptor
- `mvnw`, `mvnw.cmd`, `.mvn/wrapper` – Maven wrapper
- `Dockerfile` – containerizes the Spring Boot app
- `Jenkinsfile` – pipeline-as-code defining build/test/deploy stages
- Source tree under `src/main/java/com/example/demo`:
- `WebAppApplication.java` – Spring Boot entry point
- `WebAppController.java` – REST controller
- `src/main/resources/application.properties` – runtime configuration
- Tests under `src/test/java/...` mirror the application package

##### README for additional insights
- Describes an automated CI/CD pipeline using Jenkins, Docker, and AWS EC2

a. Main components
- Developer Workstation / IDE
- GitHub (Code Repository + Webhook)
- Jenkins (Master + Build Agents)
- Docker Engine (on Jenkins agent)
- Container Registry (optional AWS ECR or Docker Hub)
- AWS EC2 Instance (Docker Host running the container)
- Spring Boot Application (embedded Tomcat inside container)
b. Relationships and interactions
1. Developer pushes to GitHub
2. GitHub webhook triggers Jenkins pipeline
3. Jenkins agent checks out code and runs Maven: `clean package`, `test`
4. On success, Jenkins builds Docker image from `Dockerfile`
5. Jenkins pushes image to a registry (or directly SSHs into EC2)
6. Jenkins (or EC2 user data) pulls the new image on AWS EC2
7. EC2 Docker Engine runs the container; the Spring Boot app listens on port 8080
c. Architectural patterns and design principles
- Pipeline-as-code (Jenkinsfile)
- Containerization (Dockerfile + 12-factor principles)
- Infrastructure as code / immutable infrastructure (spin up new containers on deploy)
d. Relevant technologies/frameworks
- Spring Boot (Java)
- Maven (build & dependency management)
- Docker (build & runtime)
- Jenkins (CI/CD orchestrator)
- AWS EC2 (target compute)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Developer Zone" 
        Dev["Developer Workstation / IDE"]:::developer
    end
    Dev -->|"git push"| GitHub["GitHub Repository"]:::repo

    subgraph "GitHub Repository" 
        WF["WebAppApplication.java"]:::code
        WC["WebAppController.java"]:::code
        AP["application.properties"]:::code
        UT["WebAppApplicationTests.java"]:::code
        POM["pom.xml"]:::code
        MVN["mvnw, mvnw.cmd, .mvn/*"]:::code
        DF["Dockerfile"]:::code
        JF["Jenkinsfile"]:::code
        RD["README.md"]:::code
    end

    GitHub -->|"webhook"| JM["Jenkins Master"]:::ci

    subgraph "CI/CD Zone"
        JM --> JA["Jenkins Agent\n(Docker Engine)"]:::ci
        JA --> MB["Maven Build & Test"]:::build
        MB --> DB["Docker Build"]:::build
        DB --> RP["Push Docker Image\nto Registry"]:::registry
    end

    RP -->|"docker image"| EC2h["AWS EC2 Docker Host"]:::cloud

    subgraph "Production Zone"
        EC2h --> App["Spring Boot App\n(container port 8080)"]:::app
    end

    click WF "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/src/main/java/com/example/demo/WebAppApplication.java"
    click WC "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/src/main/java/com/example/demo/WebAppController.java"
    click AP "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/src/main/resources/application.properties"
    click UT "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/src/test/java/com/example/demo/WebAppApplicationTests.java"
    click POM "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/pom.xml"
    click MVN "https://github.com/dhiresh-git/java-webapp-ci-cd-project/tree/main/mvnw"
    click MVN "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/mvnw.cmd"
    click MVN "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/.mvn/wrapper/maven-wrapper.jar"
    click MVN "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/.mvn/wrapper/maven-wrapper.properties"
    click DF "https://github.com/dhiresh-git/java-webapp-ci-cd-project/tree/main/Dockerfile"
    click JF "https://github.com/dhiresh-git/java-webapp-ci-cd-project/tree/main/Jenkinsfile"
    click RD "https://github.com/dhiresh-git/java-webapp-ci-cd-project/blob/main/README.md"

    classDef developer fill:#E8F0FE,stroke:#1E40AF,color:#1E40AF
    classDef repo fill:#D0E8FF,stroke:#1E3A8A,color:#1E3A8A
    classDef ci fill:#F3F4F6,stroke:#374151,color:#374151
    classDef build fill:#C6F6D5,stroke:#22543D,color:#22543D
    classDef registry fill:#FEEBC8,stroke:#92400E,color:#92400E
    classDef cloud fill:#FDE68A,stroke:#92400E,color:#92400E
    classDef app fill:#A7F3D0,stroke:#065F46,color:#065F46
    classDef code fill:#E2E8F0,stroke:#1F2937,color:#1F2937
```
