# josdem/vetlog-spring-boot architecture

> Architecture diagram of the GitHub repository josdem/vetlog-spring-boot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/josdem/vetlog-spring-boot
- Repository: https://github.com/josdem/vetlog-spring-boot

## Overview

1. This is a single Spring Boot monolith for pet/veterinary record management. The core user stories are: register users, manage pets and vet logs, list pets for adoption, and adopt a pet. It is not an API-only service; the main UI is server-rendered.

2. The presentation layer is built around Spring MVC controllers and Thymeleaf templates. Controllers such as `UserController`, `PetController`, `PetLogController`, `AdoptionController`, `LoginController`, `RecoveryController`, `VetController`, `LocationController`, and `GoogleMapController` route browser requests to views under `src/main/resources/templates`. Static assets live under `src/main/resources/static`.

3. Form handling is separated from domain entities using command objects and binders. The `command` package contains request/view models like `UserCommand`, `PetCommand`, `PetLogCommand`, `RecoveryPasswordCommand`, `ChangePasswordCommand`, and adoption/telephone-related commands. Custom binders in `binder` convert request input into domain types, and validators enforce input rules before service logic runs.

4. The core business domain centers on `User`, `Pet`, `PetLog`, `Vaccination`, `Breed`, `PetAdoption`, `PetImage`, `PetMedicine`, `RegistrationCode`, and `Location`. These models represent account data, pet history, adoption state, photos, and location metadata.

5. Persistence is repository-driven. The `repository` package uses Spring Data repositories for the main aggregates, while Flyway migrations in `src/main/resources/db/migration` evolve the schema. This indicates a relational database as the system of record, with versioned SQL migrations rather than schema generation.

6. The service layer holds the main orchestration logic. Services such as `PetService`, `PetLogService`, `UserService`, `AdoptionService`, `RegistrationService`, `RecoveryService`, `VaccinationService`, `BreedService`, `LocationService`, and `TelephoneService` sit between controllers and repositories. Their `impl` counterparts contain the concrete workflows.

7. There are several important integration boundaries. `EmailService` integrates with a third-party mailer service mentioned in the README, `GoogleStorageWriter` and `PetImageService` handle pet image storage, and `GoogleService`/`RestService` support external HTTP-based lookups such as Google-related data or geolocation. `ClientConfiguration` and related properties classes centralize those connection settings.

8. Security is a first-class subsystem. `WebSecurityConfig`, `UserDetailsServiceImpl`, and the `Role` enum define authentication and authorization. Recovery and password-change flows are separate features, backed by `RecoveryController`, `RecoveryService`, and password-related command/validator classes.

9. Vaccination logic uses a strategy pattern. `VaccinationStrategyConfig` selects between `CatVaccinationStrategy` and `DogVaccinationStrategy`, allowing pet-type-specific vaccination schedules and formatting without hard-coding the rules into controllers or repositories.

10. Cross-cutting concerns are handled outside the main business flow. `AfterThrowingAdvice` and the `exception` package provide centralized error handling, while helpers/utilities such as `LocaleResolver`, `TemplateLocaleResolver`, `VaccinationHelper`, `UserUtil`, and formatters keep presentation and business classes smaller. Internationalization is supported through `messages.properties` and `messages_es.properties`.

11. Operationally, the project is built with Gradle, has Docker support, and includes GitHub Actions CI. The structure and tests suggest a well-layered, heavily unit-tested codebase with clear separation between UI, business logic, persistence, and external services.

Main entry points: [`src/main/java/com/josdem/vetlog/controller`](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/controller) (Controllers), [`src/main/java/com/josdem/vetlog/service`](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/service) (Services), [`src/main/java/com/josdem/vetlog/config`](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/config) (Configuration), [`src/main/java/com/josdem/vetlog/model`](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/model) (Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web UI"]
  node_web_ctrl["Controllers<br/>mvc layer"]
  node_web_tpl["Thymeleaf<br/>server views"]
  node_web_static["Static Assets<br/>frontend assets"]
end

subgraph group_app["Application"]
  node_app_cmd["Commands<br/>form models"]
  node_app_bind["Binders<br/>input binding"]
  node_app_val["Validators<br/>input rules"]
  node_app_svc["Services<br/>orchestration"]
  node_app_impl["Service Impl<br/>workflows"]
end

subgraph group_domain["Domain"]
  node_domain_model[("Models<br/>entities")]
  node_domain_repo["Repositories<br/>data access"]
  node_domain_enum(("Enums<br/>domain types"))
end

subgraph group_integrations["Integrations"]
  node_integration_mail["Email Service<br/>mailer integration<br/>[EmailService.java]"]
  node_integration_storage["Image Storage<br/>cloud storage"]
  node_integration_http["HTTP/Google<br/>external lookup<br/>[GoogleService.java]"]
end

subgraph group_infra["Infrastructure"]
  node_app_main(("VetlogApplication<br/>boot app"))
  node_infra_sec["Security<br/>authn/z"]
  node_infra_cfg["Configuration<br/>settings"]
  node_infra_adv["Advice & Errors<br/>cross-cutting"]
  node_infra_mig["Flyway Migrations<br/>schema evolution"]
end

node_app_main -->|"starts"| node_web_ctrl
node_web_ctrl -->|"renders"| node_web_tpl
node_web_ctrl -->|"binds"| node_app_cmd
node_web_ctrl -->|"uses"| node_app_bind
node_web_ctrl -->|"validates"| node_app_val
node_app_bind -->|"maps to"| node_domain_model
node_app_val -->|"checks"| node_app_cmd
node_web_ctrl -->|"delegates"| node_app_svc
node_app_svc -->|"implements"| node_app_impl
node_app_impl -->|"persists"| node_domain_repo
node_domain_repo -->|"stores"| node_domain_model
node_domain_model -->|"uses"| node_domain_enum
node_app_svc -->|"sends mail"| node_integration_mail
node_app_svc -->|"stores images"| node_integration_storage
node_app_svc -->|"calls out"| node_integration_http
node_app_svc -->|"secured by"| node_infra_sec
node_infra_cfg -->|"configures"| node_integration_mail
node_infra_cfg -->|"configures"| node_integration_http
node_infra_cfg -->|"configures"| node_integration_storage
node_infra_adv -->|"handles failures"| node_web_ctrl
node_infra_mig -->|"supports"| node_domain_repo
node_web_ctrl -.->|"serves"| node_web_static

click node_app_main "https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/VetlogApplication.java"
click node_web_ctrl "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/controller"
click node_web_tpl "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/resources/templates"
click node_web_static "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/resources/static"
click node_app_cmd "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/command"
click node_app_bind "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/binder"
click node_app_val "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/validator"
click node_app_svc "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/service"
click node_app_impl "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/service/impl"
click node_domain_model "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/model"
click node_domain_repo "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/repository"
click node_domain_enum "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/enums"
click node_integration_mail "https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/service/EmailService.java"
click node_integration_storage "https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/client/GoogleStorageWriter.java"
click node_integration_http "https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/service/GoogleService.java"
click node_infra_sec "https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/config/WebSecurityConfig.java"
click node_infra_cfg "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/config"
click node_infra_adv "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/advice"
click node_infra_mig "https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/resources/db/migration"

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_web_ctrl,node_web_tpl,node_web_static toneBlue
class node_app_cmd,node_app_bind,node_app_val,node_app_svc,node_app_impl toneAmber
class node_domain_model,node_domain_repo,node_domain_enum toneMint
class node_integration_mail,node_integration_storage,node_integration_http toneRose
class node_app_main,node_infra_sec,node_infra_cfg,node_infra_adv,node_infra_mig toneIndigo
```

## Components

### Web UI

Spring MVC controllers, templates, and browser-facing flows.

- [Controllers](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/controller): mvc layer · Browser-facing request handlers for users, pets, adoption, recovery, location, and vet views. · `src/main/java/com/josdem/vetlog/controller`
- [Thymeleaf](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/resources/templates): server views · Rendered HTML templates for forms, lists, login, recovery, maps, and adoption pages. · `src/main/resources/templates`
- [Static Assets](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/resources/static): frontend assets · CSS, JavaScript, images, and theme resources served directly to the browser. · `src/main/resources/static`

### Application

Use-case orchestration, validation, binders, and commands.

- [Commands](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/command): form models · Request and view models that decouple forms from entities. · `src/main/java/com/josdem/vetlog/command`
- [Binders](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/binder): input binding · Custom binders that convert incoming form data into domain-friendly types. · `src/main/java/com/josdem/vetlog/binder`
- [Validators](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/validator): input rules · Validation layer for user, pet, adoption, and password flows. · `src/main/java/com/josdem/vetlog/validator`
- [Services](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/service): orchestration · Main use-case orchestration across users, pets, logs, adoption, recovery, and vaccination. · `src/main/java/com/josdem/vetlog/service`
- [Service Impl](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/service/impl): workflows · Concrete service workflows and coordination logic. · `src/main/java/com/josdem/vetlog/service/impl`

### Domain

Core entities, repositories, and business rules.

- [Models](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/model): entities · Core domain objects for users, pets, logs, adoption, vaccines, images, medicine, codes, and locations. · `src/main/java/com/josdem/vetlog/model`
- [Repositories](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/repository): data access · Spring Data repositories for the main aggregates. · `src/main/java/com/josdem/vetlog/repository`
- [Enums](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/enums): domain types · Shared domain state such as roles, pet status, vaccination status, and units. · `src/main/java/com/josdem/vetlog/enums`

### Integrations

External services, storage, mail, and HTTP lookups.

- [Email Service](https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/service/EmailService.java): mailer integration · Outbound email integration used by recovery and registration flows. · `src/main/java/com/josdem/vetlog/service/EmailService.java`
- [Image Storage](https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/client/GoogleStorageWriter.java): cloud storage · Pet image upload and storage integration. · `src/main/java/com/josdem/vetlog/client/GoogleStorageWriter.java`
- [HTTP/Google](https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/service/GoogleService.java): external lookup · Google and REST-based lookups such as geolocation and related data. · `src/main/java/com/josdem/vetlog/service/GoogleService.java`

### Infrastructure

Security, configuration, migrations, and cross-cutting concerns.

- [VetlogApplication](https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/VetlogApplication.java): boot app · Spring Boot entrypoint. · `src/main/java/com/josdem/vetlog/VetlogApplication.java`
- [Security](https://github.com/josdem/vetlog-spring-boot/blob/main/src/main/java/com/josdem/vetlog/config/WebSecurityConfig.java): authn/z · Authentication, authorization, and user details loading. · `src/main/java/com/josdem/vetlog/config/WebSecurityConfig.java`
- [Configuration](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/config): settings · Application, client, template, Google, Gmail, and strategy configuration. · `src/main/java/com/josdem/vetlog/config`
- [Advice & Errors](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/java/com/josdem/vetlog/advice): cross-cutting · Centralized exception handling and after-throwing advice. · `src/main/java/com/josdem/vetlog/advice`
- [Flyway Migrations](https://github.com/josdem/vetlog-spring-boot/tree/main/src/main/resources/db/migration): schema evolution · Versioned SQL migrations for the relational database schema. · `src/main/resources/db/migration`

## Connections

- VetlogApplication → Controllers: starts · Bootstraps the web application.
- Controllers → Thymeleaf: renders · Controllers return server-rendered views.
- Controllers → Commands: binds · Controllers populate command objects for forms and views.
- Controllers → Binders: uses · Custom binders prepare request data.
- Controllers → Validators: validates · Input is validated before business logic executes.
- Binders → Models: maps to · Binders convert request values into domain types.
- Validators → Commands: checks · Validators enforce command object constraints.
- Controllers → Services: delegates · Controllers hand off use cases to services.
- Services → Service Impl: implements · Service interfaces are realized by concrete workflows.
- Service Impl → Repositories: persists · Services read and write through repositories.
- Repositories → Models: stores · Repositories manage core aggregates.
- Models → Enums: uses · Entities depend on shared enum state.
- Services → Email Service: sends mail · Recovery and registration notifications.
- Services → Image Storage: stores images · Pet photos are uploaded externally.
- Services → HTTP/Google: calls out · External data and geolocation lookups.
- Services → Security: secured by · Authentication and authorization gate the app.
- Configuration → Email Service: configures · Mail client settings.
- Configuration → HTTP/Google: configures · HTTP/client and Google settings.
- Configuration → Image Storage: configures · Storage credentials and client options.
- Advice & Errors → Controllers: handles failures · Centralized controller-adjacent error handling.
- Flyway Migrations → Repositories: supports · Migrations define the schema used by repositories.
- Controllers → Static Assets: serves · Controllers and templates are complemented by static assets.
