# rabiaadel/cicd-petclinic architecture

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

- Interactive diagram: https://gitdiagram.com/rabiaadel/cicd-petclinic
- Repository: https://github.com/rabiaadel/cicd-petclinic

## Overview

##### Project type and purpose
- This is a full-stack Java web application (Spring PetClinic) extended with a dual CI/CD automation layer (Jenkins and GitHub Actions), containerization (Docker, Docker Compose), infrastructure provisioning (Terraform), Kubernetes deployment (K8s manifests), and monitoring (Prometheus, Grafana).
- Purpose: deliver the PetClinic application reliably and repeatedly through automated build, test, code-quality analysis, container registry publishing, and deployment to cloud infrastructure.

##### File structure
- Top-level source:
- src/main/java + resources → Spring Boot MVC application (controllers, repositories, entities, templates, static assets, configuration).
- src/test/java + jmeter → unit, integration, and performance tests.
- CI/CD definitions:
- Jenkinsfile (self-hosted Jenkins declarative pipeline).
- .github/workflows/*.yml → GitHub Actions workflows.
- Containerization & local deployment:
- Dockerfile + docker-compose.yml.
- Infra provisioning:
- infra/*.tf → Terraform scripts (VPC, EC2, security groups).
- Kubernetes deployment:
- k8s/db.yml + k8s/petclinic.yml.
- Monitoring & observability:
- prometheus.yml + grafana/provisioning/datasource.yml.

##### README insights
- CI/CD stages: checkout, build/compile, test, SonarQube quality gate, Docker build, push to Nexus, deploy via Docker Compose or SSH.
- GitHub Actions: build, test, SonarQube scan.
- Technologies: Maven, JDK17, SonarQube, Nexus, Docker, Jenkins, GitHub Actions.

##### Elements
- Source & version control (blue)
- CI/CD tools (orange)
- Infra provisioning (green)
- Container registry (purple)
- Runtime / cluster (teal)
- Monitoring (yellow)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Develop & Commit
    subgraph "Develop & Commit"
        dt1["Developer IDE & Git CLI"]:::source
        dt2["GitHub Repository"]:::source

        subgraph "Source Code"
            A1["PetClinicApplication"]:::source
            A2["MVC Controllers"]:::source
            A3["Domain Models & Repositories"]:::source
            A4["Config & Static Assets"]:::source
            A5["Unit & Integration Tests"]:::source
            A6["Performance Tests (JMeter)"]:::source
            A7["SonarQube Settings"]:::source
        end

        dt1 --> dt2
        dt2 --> A1
        dt2 --> A2
        dt2 --> A3
        dt2 --> A4
        dt2 --> A5
        dt2 --> A6
        dt2 --> A7
        dt2 --> JF
        dt2 --> GHW
    end

    %% CI/CD
    subgraph "CI/CD"
        GH["GitHub Actions Runner"]:::ci
        JM["Jenkins Master"]:::ci
        JMA["Jenkins Agents"]:::ci
        MV["Maven Build & Test"]:::ci
        SQ["SonarQube"]:::ci
        DK["Docker Build"]:::ci
        NX["Nexus Registry"]:::registry

        JF["Jenkinsfile"]:::ci
        GHW["GitHub Actions Workflows"]:::ci
        SONAR["sonar-project.properties"]:::ci
        DKF["Dockerfile"]:::ci

        dt2 --> GH
        dt2 --> JM
        GH --> MV
        GH --> SQ
        GH --> DK
        JM --> JMA
        MV --> SQ
        SQ --> DK
        DK --> NX
        DK --> DC
    end

    %% Local Deployment
    subgraph "Local Deployment"
        DC["Docker Compose"]:::infra
        DCF["docker-compose.yml"]:::infra
        DK --> DC
        DCF --> DC
    end

    %% Infrastructure Provisioning
    subgraph "Infrastructure Provisioning"
        TF["Terraform"]:::infra
        INF["infra/*.tf"]:::infra
        AWS["AWS VPC & EC2"]:::infra

        INF --> TF
        TF --> AWS
        TF --> K8API
    end

    %% Kubernetes Deployment
    subgraph "Kubernetes Deployment"
        K8API["Kubernetes API Server"]:::runtime
        K8m1["k8s/db.yml"]:::runtime
        K8m2["k8s/petclinic.yml"]:::runtime
        PCPod["PetClinic Pod"]:::runtime
        DBPod["Database Pod"]:::runtime
        DBService["Database Service"]:::runtime

        NX --> K8API
        K8API --> K8m1
        K8API --> K8m2
        K8API --> PCPod
        K8API --> DBPod
        DBPod --> DBService
    end

    %% Monitoring
    subgraph "Monitoring"
        PR["Prometheus"]:::monitor
        PRC["prometheus.yml"]:::monitor
        GF["Grafana"]:::monitor
        GFDS["grafana/provisioning/datasources/datasource.yml"]:::monitor

        K8API --> PR
        PRC --> PR
        PR --> GF
        GFDS --> GF
    end

    %% Click Events
    click A1 "https://github.com/rabiaadel/cicd-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java"
    click A2 "https://github.com/rabiaadel/cicd-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/**/*Controller.java"
    click A3 "https://github.com/rabiaadel/cicd-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/model/**/*.java"
    click A3 "https://github.com/rabiaadel/cicd-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/**/*Repository.java"
    click A4 "https://github.com/rabiaadel/cicd-petclinic/tree/main/src/main/resources/"
    click A5 "https://github.com/rabiaadel/cicd-petclinic/blob/main/src/test/java/org/springframework/samples/petclinic/**/*.java"
    click A6 "https://github.com/rabiaadel/cicd-petclinic/blob/main/src/test/jmeter/petclinic_test_plan.jmx"
    click A7 "https://github.com/rabiaadel/cicd-petclinic/blob/main/sonar-project.properties"
    click JF "https://github.com/rabiaadel/cicd-petclinic/tree/main/Jenkinsfile"
    click GHW "https://github.com/rabiaadel/cicd-petclinic/tree/main/.github/workflows/"
    click DKF "https://github.com/rabiaadel/cicd-petclinic/tree/main/Dockerfile"
    click DCF "https://github.com/rabiaadel/cicd-petclinic/blob/main/docker-compose.yml"
    click INF "https://github.com/rabiaadel/cicd-petclinic/blob/main/infra/*.tf"
    click K8m1 "https://github.com/rabiaadel/cicd-petclinic/blob/main/k8s/db.yml"
    click K8m2 "https://github.com/rabiaadel/cicd-petclinic/blob/main/k8s/petclinic.yml"
    click PRC "https://github.com/rabiaadel/cicd-petclinic/blob/main/prometheus.yml"
    click GFDS "https://github.com/rabiaadel/cicd-petclinic/blob/main/grafana/provisioning/datasources/datasource.yml"

    %% Styles
    classDef source fill:#cce5ff,stroke:#004085,color:#004085
    classDef ci fill:#ffe5b4,stroke:#ff8c00,color:#ff8c00
    classDef infra fill:#d4edda,stroke:#155724,color:#155724
    classDef registry fill:#e2d6f3,stroke:#6f42c1,color:#6f42c1
    classDef runtime fill:#d1ecf1,stroke:#0c5460,color:#0c5460
    classDef monitor fill:#fff3cd,stroke:#856404,color:#856404
```
