# grupo3-eoi/pawhome architecture

> Architecture diagram of the GitHub repository grupo3-eoi/pawhome, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/grupo3-eoi/pawhome
- Repository: https://github.com/grupo3-eoi/pawhome

## Overview

##### Main Components and Their Responsibilities
- Application Core Layer:
- Spring Boot application (the main entry point in Application.java) that orchestrates the entire flow.
- Clearly defined layers such as Controllers (handling REST endpoints and user interactions), Services (containing business logic), and Repositories (managing persistence operations).
- Data Transfer Objects (DTOs) and Entities that define the data models.
- Loader classes used for initializing data for different environments (e.g., AlejandroDataLoader, DesarrolloDataLoader, etc.).

- Configuration and Profile Management:
- Various properties files (application.properties, application-local.properties, application-desarrollo.properties, application-produccion.properties) that support Spring Profiles (default, dev, prod).
- SecurityConfig, which illustrates how security is configured in the application.

- Persistence and Database Components:
- Database layer with MySQL (aimed to be instantiated via Docker Compose). Indicate how the Docker Compose files (compose.yaml, compose-desarrollo.yaml, compose-produccion.yaml) and additional MySQL-specific Compose files contribute to setting up the local and specific environment databases.

- Testing Frameworks:
- Components for the testing strategy. Represent the integration tests (in src/test/java), unit tests, and especially the usage of TestContainers to create isolated containerized environments for integration testing.

- CI/CD and Quality Gate Integration:
- External services such as GitHub Actions for automated testing, build, and deployment.
- SonarQube as the tool used to analyze the code quality, documentation of metrics (quality gates, coverage, maintainability, etc.), and how it fits into the automated pipeline.

- Deployment Automation:
- Docker Compose configuration that automatically brings up the required services (notably MySQL) when running the application.
- IntelliJ IDEA “.run” profiles and how they mirror the deployment on remote environments (development and production).

##### Relationships and Interactions
- Data flow from the external client (which might be a web browser serving static HTML pages from the templates/static folders) to the Controllers.
- How Controllers call Services, which in turn use Repositories to interact with the database.

##### Architectural Patterns and Design Principles
- Layered approach (MVC-like) used to separate concerns within the code.
- Use of SOLID principles and DRY, as outlined in the README, to maintain low coupling and high cohesion.
- The Repository Pattern is of note here, as well as the use of DTOs for clean data transfer between layers.
- IoC (Inversion of Control) provided by Spring, which manages dependencies in the system.

##### Technologies, Frameworks, and Tools
- Also, note IntelliJ IDEA as the integrated development environment with prebuilt .run configurations that help manage local deployments.
- GitHub and its workflows for continuous integration/continuous deployment (with GitHub Actions YAML files).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Application Core Layer
    subgraph "Application Core"
        A["Application (Application.java)"]:::core
        subgraph "Presentation Layer"
            CLIENT["Client (Browser/Static HTML)"]:::external
            CTRL["Controller: DefaultController"]:::core
        end
        subgraph "Business Layer"
            S["Services (EntidadHijaService, EntidadPadreService)"]:::core
            R["Repositories (EntidadHijaRepository, EntidadPadreRepository)"]:::core
            subgraph "Data Models"
                ENT["Entities (EntidadHija, EntidadPadre)"]:::core
                DTO["DTO (EntidadPadreDto)"]:::core
            end
            L["Data Loaders (AlejandroDataLoader, DesarrolloDataLoader, LocalDataLoader, ProductionDataLoader)"]:::core
        end
    end

    %% Configuration and Environment Profiles
    subgraph "Configuration & Profiles"
        PF["Properties Files (application.properties, application-local.properties, application-desarrollo.properties, application-produccion.properties)"]:::config
        SEC["SecurityConfig"]:::config
    end

    %% Persistence and Database Setup
    subgraph "Persistence & DB Setup"
        DC["Docker Compose Configs (compose.yaml, compose-desarrollo.yaml, compose-produccion.yaml)"]:::persistence
        MC["MySQL Compose Configs (mysql/compose-mysql.yaml, mysql/compose-desarrollo-mysql.yaml, mysql/compose-produccion-mysql.yaml)"]:::persistence
        DB["MySQL Database"]:::database
    end

    %% Testing Frameworks
    subgraph "Testing Frameworks"
        TESTS["Test Sources (ApplicationTest, EntidadPadreRepositoryTest, ApplicationIT)"]:::testing
        TC["TestContainers (PostgreSQLContainerTest)"]:::testing
    end

    %% CI/CD and Quality Gate Integration
    subgraph "CI/CD & Quality Gate"
        GH["GitHub Actions Workflows (.github/workflows: SubirDesarrollo.yml, SubirProduccion.yml)"]:::cicd
        SQ["SonarQube Integration (compose-sonarqube.yaml)"]:::cicd
    end

    %% Deployment Automation
    subgraph "Deployment Automation"
        IDE["IntelliJ IDEA Run Configurations (.run: AplicaciónEnLocal.run.xml, ComposeDesarrollo.run.xml, ComposeProduccion.run.xml, DATALOADProduccion.run.xml)"]:::deployment
    end

    %% Flow Connections
    CLIENT --> CTRL
    A --> CTRL
    CTRL --> S
    S --> R
    R --> DB
    A --> L
    PF --> L
    GH --> IDE

    %% Optional dotted test flows indicating test validation of core
    TESTS --- A
    TC --- A

    %% Class Definitions for Colors
    classDef core fill:#f9e79f,stroke:#b7950b,stroke-width:2px;
    classDef external fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef config fill:#d7bde2,stroke:#6c3483,stroke-width:2px;
    classDef persistence fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef testing fill:#f9e79f,stroke:#b9770e,stroke-width:2px;
    classDef cicd fill:#fadbd8,stroke:#cb4335,stroke-width:2px;
    classDef deployment fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef database fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;

    %% Click Events
    click A "https://github.com/grupo3-eoi/pawhome/blob/main/src/main/java/com/atm/buenas_practicas_java/Application.java"
    click CTRL "https://github.com/grupo3-eoi/pawhome/blob/main/src/main/java/com/atm/buenas_practicas_java/controllers/DefaultController.java"
    click S "https://github.com/grupo3-eoi/pawhome/tree/main/src/main/java/com/atm/buenas_practicas_java/services"
    click R "https://github.com/grupo3-eoi/pawhome/tree/main/src/main/java/com/atm/buenas_practicas_java/repositories"
    click ENT "https://github.com/grupo3-eoi/pawhome/tree/main/src/main/java/com/atm/buenas_practicas_java/entities"
    click DTO "https://github.com/grupo3-eoi/pawhome/tree/main/src/main/java/com/atm/buenas_practicas_java/dtos"
    click L "https://github.com/grupo3-eoi/pawhome/tree/main/src/main/java/com/atm/buenas_practicas_java/loaders"
    click PF "https://github.com/grupo3-eoi/pawhome/tree/main/src/main/resources"
    click SEC "https://github.com/grupo3-eoi/pawhome/blob/main/src/main/java/com/atm/buenas_practicas_java/config/SecurityConfig.java"
    click DC "https://github.com/grupo3-eoi/pawhome/blob/main/compose.yaml"
    click MC "https://github.com/grupo3-eoi/pawhome/blob/main/mysql/compose-mysql.yaml"
    click TESTS "https://github.com/grupo3-eoi/pawhome/tree/main/src/test/java/com/atm/buenas_practicas_java"
    click TC "https://github.com/grupo3-eoi/pawhome/blob/main/src/test/java/com/atm/buenas_practicas_java/PostgreSQLContainerTest.java"
    click GH "https://github.com/grupo3-eoi/pawhome/tree/main/.github/workflows"
    click SQ "https://github.com/grupo3-eoi/pawhome/blob/main/sonarqube/compose-sonarqube.yaml"
    click IDE "https://github.com/grupo3-eoi/pawhome/blob/main/.run"
```
