How disilab-frba-utn-edu-ar/ejemplo-inicial-springboot works
Main Components
• Application Entry Point:
• Application.java – marks the starting point of the Spring Boot application.
• REST Controllers:
• Controllers such as TurnoController and GlobalExceptionHandlerController that expose the API endpoints.
• Service Layer:
• Interfaces and their implementations (e.g., ITurnosService and TurnosService) that encapsulate business logic.
• Data Transfer Objects:
• DTO classes for input and output (e.g., TurnoInputDTO and TurnoOutputDTO) that are used to transfer data to/from the API.
• Data Mapping:
• Mappers (like TurnoMapper) to convert between entities and DTOs.
• Persistence/Repository Layer:
• Entities (e.g., Turno) and repositories (e.g., TurnoRepository) using Spring Data JPA for database operations.
• Exception Handling:
• Custom exception classes (e.g., NotFoundException) and a global exception controller.
• Database:
• The configuration indicates usage of H2 for in-memory testing, with options to switch to MySQL or PostgreSQL.
• Testing:
• Test directory (src/test) that can be represented as unit/integration tests verifying the components.
Defining Relationships and Interactions
• The Application entry point initializes the Spring context and loads all the components.
• REST controllers receive HTTP requests and pass the data (often in the form of DTOs) to the service layer.
• The service layer applies business rules and uses repositories to interact with the database.
• Repositories leverage JPA to map entity objects to persistent data.
• Mappers provide conversion between domain models and DTOs.
• Global Exception Handler captures and processes any exceptions that arise during request processing.
• External configuration (in application.properties and application-test.properties) informs the database setup, which should be illustrated as a connection between the application and the H2 database (with optional links to MySQL/PostgreSQL for production deployments).
Architectural Patterns and Principles
• MVC Pattern: Although this is a backend application, the separation of concerns between controllers (presentation), services (business logic), and repositories/models (data access) follows the MVC pattern.
• Layered Architecture: Clearly delineating controllers, services, and repositories.
• Dependency Injection: Managed by Spring Boot across components.
• Exception Handling: Centralized via a global exception controller.
• A top-level node labeled “Spring Boot Application” (starting with Application.java).
• Side-by-side or layered arrangement showing:
• REST API Controllers (global exception controller, TurnoController)
• Services (business logic in TurnosService)
• Data Mapping (TurnoMapper)
• Persistence layer, including Entities (Turno) and Repositories (TurnoRepository)
• Database (H2, with noted possibility for MySQL/PostgreSQL).
• Annotations noting external technologies (Java 17, Spring Boot 3, Spring Data JPA, Maven, Lombok) that help power the framework.
• Testing component demonstrating that unit tests (found under src/test) ensure the integrity of these modules.