# syehab/spring-petclinic architecture

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

- Interactive diagram: https://gitdiagram.com/syehab/spring-petclinic
- Repository: https://github.com/syehab/spring-petclinic

## Overview

##### Project type and purpose
- This is a monolithic, full-stack Spring Boot sample application (Spring PetClinic).
- It exposes a web UI (Thymeleaf + static assets) backed by a layered Java backend (Controllers → Services → Repositories) and supports multiple RDBMS (H2, MySQL, PostgreSQL) via profiles.

##### File structure
- src/main/java/org/springframework/samples/petclinic
- model: JPA entities
- owner, vet, system: Controllers, Formaters, Validators, Config classes
- repository interfaces (Spring Data JDBC/JPA)
- src/main/resources
- application-*.properties for profiles
- templates (Thymeleaf views) and static resources (CSS, fonts, images)
- SQL scripts for each database flavor
- build scripts & configs
- Maven (pom.xml, .mvn) and Gradle (build.gradle, gradle/)
- Docker Compose (docker-compose.yml)
- Kubernetes manifests (k8s/)
- CI/CD workflows (GitHub Actions, Jenkinsfile)
- src/test
- unit/integration tests (JUnit, Testcontainers, Docker Compose)
- JMeter performance tests

##### README for additional insights
- Emphasizes Spring Boot, profile-based DB configuration, containerization via Spring Boot build plugin, optional Docker Compose or Kubernetes deployment.
- Mentions integration test strategy: Testcontainers for MySQL, Docker Compose for Postgres.

##### Elements
– Components labeled: Browser, Web Controller, Service Layer, Repository Layer, Database, Cache, CI/CD Orchestrator, Docker Compose, Kubernetes.
- Browser → Controller (HTTP request)
- Controller → Service → Repository (method calls)
- Repository → Database (JDBC queries)
- CI/CD → Build → Test → Deploy
- Rectangles for components (UI, Controllers, Services)
- Rounded rectangles for external tools (Testcontainers, JMeter)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    Browser["User’s Web Browser"]:::ui

    subgraph "Spring Boot Monolith" 
        direction TB
        Entry[/"PetClinicApplication\n(src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java)"/]:::backend
        Presentation["Thymeleaf Templates\n(src/main/resources/templates)"]:::ui
        Static["Static Assets\n(src/main/resources/static/resources)"]:::ui

        subgraph "Web Layer"
            direction TB
            OwnerCtrl["OwnerController"]:::backend
            PetCtrl["PetController"]:::backend
            VisitCtrl["VisitController"]:::backend
            VetCtrl["VetController"]:::backend
            CrashCtrl["CrashController"]:::backend
            WelcomeCtrl["WelcomeController"]:::backend
        end

        subgraph "Service & Validation Layer"
            direction TB
            Services["Business Services"]:::backend
            PetTypeFmt["PetTypeFormatter"]:::backend
            PetVal["PetValidator"]:::backend
        end

        subgraph "Configuration"
            direction TB
            CacheCfg["CacheConfiguration"]:::backend
            WebCfg["WebConfiguration"]:::backend
        end

        subgraph "Data Access Layer"
            direction TB
            OwnerRepo["OwnerRepository"]:::backend
            PetTypeRepo["PetTypeRepository"]:::backend
            VetRepo["VetRepository"]:::backend
        end

        subgraph "Domain Model"
            direction TB
            Entities["JPA Entities"]:::backend
        end

        Entry --> Presentation
        Entry --> Static
        Presentation --> OwnerCtrl
        Static --> OwnerCtrl
        OwnerCtrl --> Services
        PetCtrl --> Services
        VisitCtrl --> Services
        VetCtrl --> Services
        CrashCtrl --> Services
        WelcomeCtrl --> Services
        Services --> PetTypeFmt
        Services --> PetVal
        Services --> OwnerRepo
        Services --> PetTypeRepo
        Services --> VetRepo
        OwnerRepo --> Entities
        PetTypeRepo --> Entities
        VetRepo --> Entities
        CacheCfg --> Services
        WebCfg --> Presentation
    end

    %% Database Options
    subgraph "Relational Databases" 
        direction TB
        H2["H2 Database"]:::infra
        MySQL["MySQL"]:::infra
        PostgreSQL["PostgreSQL"]:::infra
        H2Console["H2 Console"]:::external
        H2 --> H2Console
    end

    %% Infrastructure & Deploy
    subgraph "Infrastructure & Deployment"
        direction TB
        DC["Docker Compose\n(docker-compose.yml)"]:::infra
        K8s["Kubernetes\n(k8s/ )"]:::infra
        CI["CI/CD Orchestrator"]:::infra
        GA["GitHub Actions"]:::infra
        Jenk["Jenkins Pipeline"]:::infra
        CI --> GA
        CI --> Jenk
        CI --> DC
        CI --> K8s
    end

    %% Testing Tools
    subgraph "Testing Tools"
        direction TB
        Testcont["Testcontainers"]:::external
        JMeter["JMeter"]:::external
    end

    %% Interactions
    Browser -->|"HTTP/S"| OwnerCtrl
    Browser -->|"HTTP/S"| PetCtrl
    Browser -->|"HTTP/S"| VisitCtrl
    Browser -->|"HTTP/S"| VetCtrl
    Browser -->|"HTTP/S"| WelcomeCtrl

    OwnerRepo -->|"JDBC"| H2
    OwnerRepo -->|"JDBC"| MySQL
    OwnerRepo -->|"JDBC"| PostgreSQL

    CI -->|"Build & Test"| Testcont
    CI -->|"Performance Test"| JMeter
    DC --> MySQL
    DC --> PostgreSQL
    K8s --> H2
    K8s --> MySQL
    K8s --> PostgreSQL

    %% Click Events
    click Presentation "https://github.com/syehab/spring-petclinic/tree/main/src/main/resources/templates"
    click Static "https://github.com/syehab/spring-petclinic/tree/main/src/main/resources/static/resources"
    click Entry "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/PetClinicApplication.java"
    click OwnerCtrl "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java"
    click PetCtrl "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/PetController.java"
    click VisitCtrl "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/VisitController.java"
    click VetCtrl "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/vet/VetController.java"
    click CrashCtrl "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/system/CrashController.java"
    click WelcomeCtrl "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java"
    click PetTypeFmt "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/PetTypeFormatter.java"
    click PetVal "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/PetValidator.java"
    click CacheCfg "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/system/CacheConfiguration.java"
    click WebCfg "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/system/WebConfiguration.java"
    click OwnerRepo "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/OwnerRepository.java"
    click PetTypeRepo "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/owner/PetTypeRepository.java"
    click VetRepo "https://github.com/syehab/spring-petclinic/blob/main/src/main/java/org/springframework/samples/petclinic/vet/VetRepository.java"
    click DC "https://github.com/syehab/spring-petclinic/blob/main/docker-compose.yml"
    click K8s "https://github.com/syehab/spring-petclinic/tree/main/k8s/"
    click GA "https://github.com/syehab/spring-petclinic/blob/main/.github/workflows/maven-build.yml"
    click Jenk "https://github.com/syehab/spring-petclinic/tree/main/Jenkinsfile"
    click Testcont "https://github.com/syehab/spring-petclinic/blob/main/src/test/java/org/springframework/samples/petclinic/*IntegrationTests.java"
    click JMeter "https://github.com/syehab/spring-petclinic/blob/main/src/test/jmeter/petclinic_test_plan.jmx"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef backend fill:#d4edda,stroke:#333,stroke-width:1px
    classDef infra fill:#fff3cd,stroke:#333,stroke-width:1px
    classDef external fill:#e2e3e5,stroke:#333,stroke-width:1px
```
