# unaluz/tp-integrador-back architecture

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

- Interactive diagram: https://gitdiagram.com/unaluz/tp-integrador-back
- Repository: https://github.com/unaluz/tp-integrador-back

## Overview

The project is a Kotlin-based backend application built with Spring Boot, designed as a base template for Algo3 course assignments. It leverages Gradle (with a Kotlin DSL build script) for dependency management and builds, and includes essential integrations such as JUnit 5 for testing, JaCoCo for code coverage, and Swagger for API documentation. The project follows a layered architecture pattern, clearly segmented into controllers, services, data access (repositories), and domain models.

##### Main Components
- Backend Server: Represented by the main application class (ProyectoApplication.kt) that initializes the Spring Boot server (running on port 9000).
- Controllers: Folder (src/main/kotlin/ar/edu/unsam/algo3/controller) containing REST controllers such as GenericController.kt. These handle incoming HTTP requests.
- Services: Folder (src/main/kotlin/ar/edu/unsam/algo3/service) containing service classes (e.g., ContenidoService.kt, DescargaService.kt, EncuestaService.kt) that implement the business logic.
- Data Access Layer/Repositories: Folder (src/main/kotlin/ar/edu/unsam/algo3/dao) with repository interfaces (e.g., ContenidoRepository.kt, DescargaRepository.kt, etc.), which are used to interact with the underlying database.
- Domain Models: Folder (src/main/kotlin/ar/edu/unsam/algo3/domain) with classes (e.g., Contenido.kt, Descarga.kt, Encuesta.kt, Usuario.kt) encapsulating business entities.
- Database Connection/Configuration: The file DBConnection.kt in the data package and configuration files under src/main/resources (application.yml) that hold DB and server settings.
- Utilities: For example, Logger.kt in the utils package.
- Testing Components: The structure in src/test mirrors the main package, providing integration and unit tests to ensure correctness.

##### Relationships and Interactions
- Controllers call corresponding Services to process the request.
- Services interact with Repositories (Data Access Objects) to perform CRUD operations, possibly leveraging DBConnection.
- The Domain models serve as data carriers between the layers.
- The configuration (application.yml) under resources is loaded at startup, tying components such as the database connection to the repositories.
- Swagger adds an additional layer for API documentation, which is integrated into the web layer.

##### Architectural Patterns and Design Principles
- Layered Architecture: Separate web (controller), service (business logic), data access, and domain layers.
- Dependency Injection (via Spring Boot): Components are injected into each other, ensuring loose coupling and easier testing.
- Integration of external tools: Swagger for endpoint documentation and JaCoCo for code coverage.
- Testing: Presence of integration and controller tests ensures a robust test-driven architecture.

##### Capturing Essential Architectural Elements
- That controllers are annotated for Swagger documentation.
- Unit and integration test flows (from the tests directory) as validation mechanisms for the main components.
- Mention Gradle and build configuration elements that ensure dependencies like Spring Boot, JUnit 5, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    client["External HTTP Client"]:::external

    %% Application Initialization
    subgraph "Application Initialization"
        A["ProyectoApplication (Spring Boot)"]:::server
    end

    %% Controller Layer
    subgraph "Controller Layer"
        B["GenericController"]:::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        C1["ContenidoService"]:::service
        C2["DescargaService"]:::service
        C3["EncuestaService"]:::service
    end

    %% Repository Layer
    subgraph "Repository Layer"
        D1["ContenidoRepository"]:::repository
        D2["DescargaRepository"]:::repository
        D3["EncuestaRepository"]:::repository
        D4["EntidadRepository"]:::repository
    end

    %% Domain Models
    subgraph "Domain Models"
        E1["Contenido"]:::domain
        E2["Descarga"]:::domain
        E3["Encuesta"]:::domain
        E4["Usuario"]:::domain
    end

    %% Configuration/Database
    subgraph "Configuration/Database"
        F1["DBConnection"]:::config
        F2["application.yml"]:::config
    end

    %% Utilities
    subgraph "Utilities"
        G["Logger"]:::utility
    end

    %% Testing Components
    subgraph "Testing"
        H1["EjemploControllerTest"]:::testing
        H2["TestContenido"]:::testing
    end

    %% External Integrations
    subgraph "External Integrations"
        I1["Swagger"]:::external
        I2["JUnit5"]:::external
        I3["JaCoCo"]:::external
        I4["Gradle Build"]:::external
    end

    %% Connections
    client --> B
    A --> B
    B --> C1
    B --> C2
    B --> C3
    C1 --> D1
    C2 --> D2
    C3 --> D3
    C1 --> E1
    C2 --> E2
    C3 --> E3
    D1 --> E1
    D2 --> E2
    D3 --> E3
    D1 --> F1
    D2 --> F1
    D3 --> F1
    D4 --> F1
    F1 --> F2
    A --> F2
    A -- "logs" --> G
    I1 --> B
    I2 --> H1
    I3 --> H1
    I2 --> H2
    I3 --> H2
    I4 --> A
    I4 --> B
    I4 --> C1
    I4 --> C2
    I4 --> C3
    I4 --> D1

    %% Styles
    classDef server fill:#E0BBE4,stroke:#000,stroke-width:1px;
    classDef controller fill:#AEDFF7,stroke:#000,stroke-width:1px;
    classDef service fill:#A2E2B4,stroke:#000,stroke-width:1px;
    classDef repository fill:#FFCC99,stroke:#000,stroke-width:1px;
    classDef domain fill:#FFF4B2,stroke:#000,stroke-width:1px;
    classDef config fill:#B2D7FF,stroke:#000,stroke-width:1px;
    classDef utility fill:#CCCCCC,stroke:#000,stroke-width:1px;
    classDef testing fill:#FF9999,stroke:#000,stroke-width:1px;
    classDef external fill:#F3D1F4,stroke:#000,stroke-width:1px;

    %% Click Events
    click A "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/ProyectoApplication.kt"
    click B "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/controller/GenericController.kt"
    click C1 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/service/ContenidoService.kt"
    click C2 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/service/DescargaService.kt"
    click C3 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/service/EncuestaService.kt"
    click D1 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/dao/ContenidoRepository.kt"
    click D2 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/dao/DescargaRepository.kt"
    click D3 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/dao/EncuestaRepository.kt"
    click D4 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/dao/EntidadRepository.kt"
    click E1 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/domain/Contenido.kt"
    click E2 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/domain/Descarga.kt"
    click E3 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/domain/Encuesta.kt"
    click E4 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/domain/Usuario.kt"
    click F1 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/data/DBConnection.kt"
    click F2 "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/resources/application.yml"
    click G "https://github.com/unaluz/tp-integrador-back/blob/main/src/main/kotlin/ar/edu/unsam/algo3/utils/Logger.kt"
    click H1 "https://github.com/unaluz/tp-integrador-back/blob/main/src/test/kotlin/ar/edu/unsam/algo3/controller/EjemploControllerTest.kt"
    click H2 "https://github.com/unaluz/tp-integrador-back/blob/main/src/test/kotlin/ar/edu/unsam/algo3/data/TestContenido.kt"
```
