# angelichazu/krugger_vacunas architecture

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

- Interactive diagram: https://gitdiagram.com/angelichazu/krugger_vacunas
- Repository: https://github.com/angelichazu/krugger_vacunas

## Overview

##### Main Components
- Docker & Docker Compose: Represent the orchestration of containers.
- One container for the PostgreSQL database (including the initialization script in dockerPostgres).
- One container for running the Spring Boot application.
- Spring Boot Backend Application:
- Controllers: For handling HTTP requests (e.g., EmpleadoController, LoginController).
- Services: Business logic implementation (like EmpleadoService).
- Repositories: Data persistence layer managing CRUD operations using JPA interfaces (e.g., EmpleadoRepository, RolRepository, etc.).
- Entities/Models: Domain objects (Empleado, Rol, Usuario, Vacuna, etc.) and Data Transfer Objects (EmpleadoDto, VacunaDto).
- Configurations: Including security (SecurityConfig), Swagger documentation (SwaggerConfig), and user configuration (UsuarioConfig).
- External Clients:
- Swagger UI: A web client used for testing the API endpoints.
- Any other client consuming the web services.

##### Relationships and Interactions
- Clients (like Swagger UI) send HTTP requests to the backend.
- Controllers receive and process these requests. They may call respective service components to handle the business logic.
- Services interact with repository components to perform database operations against the PostgreSQL container.
- The database container holds the persistent data as defined in the SQL initialization scripts.
- Additionally, the configuration layer (including security configurations) plays a crucial role in controlling access to endpoints as indicated (e.g., ADMIN vs. USER access).

##### Architectural Patterns & Design Principles
- Layered (MVC) Architecture: Segregate responsibilities into Controller, Service, and Repository layers.
- Containerization: Use of Docker and docker-compose to encapsulate environment specifics.
- API Documentation: Swagger integration ensures clear exposure of endpoints for testing and integration.
- Security: Via SecurityConfig, the application implements role-based access control.

##### Incorporate Technologies, Frameworks, and Tools
- Java (JDK 11) and Spring Boot for core development.
- Maven for build and dependency management.
- PostgreSQL as the database.
- Docker for containerization along with docker-compose for orchestration.
- Swagger for API documentation and interactive tests.
- Spring Security as configured in SecurityConfig for managing authentication and authorization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Docker Orchestration
    subgraph "Docker Orchestration"
        DC["Docker Compose"]:::docker
        DC --> DB["PostgreSQL (dockerPostgres)"]:::docker
        DB --> DB_D["Dockerfile"]:::docker
        DB --> DB_Init["Init Script"]:::docker
        DC --> SB["Spring Boot Application Container"]:::springboot
    end

    %% Spring Boot Application Container Layers
    subgraph "Spring Boot Application Container"
        MainApp["Spring Boot Application"]:::springboot

        subgraph "Presentation Layer (Controllers)"
            EC["EmpleadoController"]:::controller
            LC["LoginController"]:::controller
        end

        subgraph "Business Logic Layer (Services)"
            ES["EmpleadoService"]:::service
        end

        subgraph "Data Access Layer (Repositories)"
            ER["EmpleadoRepository"]:::repository
            RR["RolRepository"]:::repository
            TVR["TipoVacunaRepository"]:::repository
            UR["UsuarioRepository"]:::repository
            VR["VacunaRepository"]:::repository
        end

        subgraph "Domain Layer (Entities/Models)"
            E["Empleado"]:::entity
            R["Rol"]:::entity
            TV["TipoVacuna"]:::entity
            U["Usuario"]:::entity
            V["Vacuna"]:::entity
            ED["EmpleadoDto"]:::dto
            VD["VacunaDto"]:::dto
        end

        subgraph "Configuration Layer"
            SC["SecurityConfig"]:::config
            SW["SwaggerConfig"]:::config
            UC["UsuarioConfig"]:::config
        end
    end

    %% External Clients
    subgraph "External Clients"
        SU["Swagger UI"]:::external
    end

    %% Relationships from External Client to Controllers
    SU -->|"HTTPRequests"| EC
    SU -->|"HTTPRequests"| LC

    %% Controllers to Service
    EC -->|"calls"| ES
    LC -->|"calls"| ES

    %% Service to Repositories
    ES -->|"calls"| ER
    ES -->|"calls"| RR
    ES -->|"calls"| TVR
    ES -->|"calls"| UR
    ES -->|"calls"| VR

    %% Repositories to Database
    ER -->|"persist"| DB
    RR -->|"persist"| DB
    TVR -->|"persist"| DB
    UR -->|"persist"| DB
    VR -->|"persist"| DB

    %% Styling Classes
    classDef docker fill:#d0e9ff,stroke:#0277bd,stroke-width:2px;
    classDef springboot fill:#e1f5fe,stroke:#039be5,stroke-width:2px;
    classDef controller fill:#ffebee,stroke:#c62828,stroke-width:2px;
    classDef service fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;
    classDef repository fill:#e3f2fd,stroke:#1565c0,stroke-width:2px;
    classDef entity fill:#fff3e0,stroke:#ef6c00,stroke-width:2px;
    classDef dto fill:#fffde7,stroke:#f9a825,stroke-width:2px;
    classDef config fill:#f3e5f5,stroke:#8e24aa,stroke-width:2px;
    classDef external fill:#e0f7fa,stroke:#00838f,stroke-width:2px;

    %% Click Events for Docker Orchestration
    click DC "https://github.com/angelichazu/krugger_vacunas/blob/main/docker-compose.yml"
    click DB_D "https://github.com/angelichazu/krugger_vacunas/blob/main/dockerPostgres/db.Dockerfile"
    click DB_Init "https://github.com/angelichazu/krugger_vacunas/blob/main/dockerPostgres/init.sql"

    %% Click Event for Spring Boot Main Application
    click MainApp "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/VacunasApplication.java"

    %% Click Events for Controllers
    click EC "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/controller/EmpleadoController.java"
    click LC "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/controller/LoginController.java"

    %% Click Event for Service
    click ES "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/services/EmpleadoService.java"

    %% Click Events for Repositories
    click ER "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/repository/EmpleadoRepository.java"
    click RR "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/repository/RolRepository.java"
    click TVR "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/repository/TipoVacunaRepository.java"
    click UR "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/repository/UsuarioRepository.java"
    click VR "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/repository/VacunaRepository.java"

    %% Click Events for Entities/Models
    click E "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/entity/Empleado.java"
    click R "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/entity/Rol.java"
    click TV "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/entity/TipoVacuna.java"
    click U "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/entity/Usuario.java"
    click V "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/entity/Vacuna.java"
    click ED "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/modelDto/EmpleadoDto.java"
    click VD "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/modelDto/VacunaDto.java"

    %% Click Events for Configurations
    click SC "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/config/SecurityConfig.java"
    click SW "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/config/SwaggerConfig.java"
    click UC "https://github.com/angelichazu/krugger_vacunas/blob/main/src/main/java/com/krugger/vacunas/config/UsuarioConfig.java"
```
