# gabrielcornejob/spring-tasks-api-rest architecture

> Architecture diagram of the GitHub repository gabrielcornejob/spring-tasks-api-rest, 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/gabrielcornejob/spring-tasks-api-rest
- Repository: https://github.com/gabrielcornejob/spring-tasks-api-rest

## Overview

##### Main Components
- Frontend/API Entry-Point: Although there isn’t a separate frontend UI, the REST API layer serves as the entry/interface for client interactions.
- Application/Service Layer: Represented by the “applications/app-service” which contains the MainApplication class and configuration classes (such as ExceptionsConfig and UseCasesConfig). This acts as the Spring Boot application starting point.
- Domain Layer: Split between “domain/model” for the entities (like Task, exceptions, task constants) and “domain/usecase” for the business rules and logic (like TaskUseCase).
- Infrastructure Layer: Which includes two primary parts:
- Driven Adapters: Found under “infrastructure/driven-adapters/task,” which connect to external systems (e.g., data persistence or other services) via repository adapters.
- Entry Points: Under “infrastructure/entry-points/api-rest,” which contains the REST controllers (such as TaskController) and DTOs for handling incoming HTTP requests.

##### Relationships & Interactions
- The API entry point (TaskController) receives HTTP requests and routes them to the appropriate use cases.
- The Application layer (MainApplication with associated configurations) initializes the system, wiring the controllers, use cases, and adapters.
- Use Cases (TaskUseCase) encapsulate business logic that primarily interacts with the domain entities and is independent of how data is stored or exposed.
- Driven Adapters (TaskRepositoryAdapter) implement gateway interfaces defined in the domain (e.g., TaskRepository) and provide concrete methods for persistence or external communication.

##### Architectural Patterns and Design Principles
- Clean Architecture: Clearly separate the business logic (domain and use cases) from the infrastructure and framework concerns. Mark the internal layers (domain/usecase and domain/model) as independent from external concerns.
- Layering: Use concentric layers or aligned horizontal layers that indicate inward dependency (i.e., controllers and adapters depend on use cases and domain interfaces, but the domain does not depend on any outer layers).
- Dependency Inversion: Illustrate interfaces in the domain that are implemented by the adapters, emphasizing that the high-level business logic does not depend on low-level details.

##### Relevant Technologies and Frameworks
- Spring Boot: Implied from the MainApplication and configuration files.
- Gradle: The build system, as evidenced by multiple build.gradle files.
- REST: The API endpoints defined in the README, showing HTTP routes.
- Logging: Mention log4j2.properties for logging configuration.
- Testing: Highlight the presence of test directories within each module (e.g., tests under "applications/app-service/src/test" and tests in other layers).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "API Layer"
        API["API REST Controller"]:::controller
    end

    subgraph "Application Layer"
        MA["MainApplication"]:::app
        EC["ExceptionsConfig"]:::app
        UC["UseCasesConfig"]:::app
    end

    subgraph "Domain Layer"
        subgraph "Domain - Use Cases"
            TU["TaskUseCase"]:::usecase
        end
        subgraph "Domain - Model"
            TE["Task Entity"]:::model
            DC["Task Constants & Exceptions"]:::model
        end
    end

    subgraph "Infrastructure Layer"
        TRA["Task Repository Adapter"]:::adapter
    end

    %% Connections between layers
    API -->|"calls"| TU
    TU -->|"processes"| TE
    TU -->|"validates"| DC
    TU -.->|"delegates persistence"| TRA

    MA -->|"configures"| API
    MA -->|"configures"| TU
    MA -->|"configures"| TRA

    %% Click Events
    click API "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/infrastructure/entry-points/api-rest/src/main/java/co/com/bancolombia/api/TaskController.java"
    click MA "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/applications/app-service/src/main/java/co/com/bancolombia/MainApplication.java"
    click EC "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/applications/app-service/src/main/java/co/com/bancolombia/config/ExceptionsConfig.java"
    click UC "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/applications/app-service/src/main/java/co/com/bancolombia/config/UseCasesConfig.java"
    click TE "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/domain/model/src/main/java/co/com/bancolombia/model/task/Task.java"
    click DC "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/domain/model/src/main/java/co/com/bancolombia/model/task/constants/Constants.java"
    click TU "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/domain/usecase/src/main/java/co/com/bancolombia/usecase/task/TaskUseCase.java"
    click TRA "https://github.com/gabrielcornejob/spring-tasks-api-rest/blob/trunk/infrastructure/driven-adapters/task/src/main/java/co/com/bancolombia/task/TaskRepositoryAdapter.java"

    %% Styles
    classDef controller fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef app fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef usecase fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef model fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef adapter fill:#FFA07A,stroke:#000,stroke-width:2px;
```
