How maxizampa/programacion4-practico3 works
1. Project shape
- This is a single Spring Boot 3.x REST API written in Java 17+, built with Maven (pom.xml, mvnw).
- The code is organized around one business area: product management under com.practicos.ejercicio3.
2. Application entrypoint
- Ejercicio3Application.java is the bootstrapping class.
- It starts the Spring container and wires the REST controller, service, validation, and exception-handling components.
3. API boundary
- controller/ProductoController.java is the external entry layer.
- It exposes the product endpoints and is the main boundary between HTTP clients and internal application logic.
- The repository does not show a separate frontend or client; this API is meant to be consumed by tools like Swagger UI or other HTTP clients.
4. DTO boundary for request/response
- dto/ProductoRequestDTO.java and dto/ProductoResponseDTO.java define the contract at the API boundary.
- Requests and responses are intentionally separated from the internal domain model to decouple the API format from the business object structure.
- This is the main data-shaping layer in the architecture.
5. Domain model
- model/Producto.java represents the product entity/object used internally by the service layer.
- The README explicitly highlights DTO usage and validation, so the model is not exposed directly to clients.
6. Business logic
- service/ProductoService.java contains the application’s core product logic.
- From the repository structure, this appears to be the central place for creating/validating/translating products before returning a response.
- No repository/data-access package is present, so the visible architecture is service-centric and does not currently show persistence infrastructure.
7. Validation flow
- src/main/resources/ValidationMessages.properties indicates custom validation messages for Jakarta Bean Validation.
- Validation is part of the request-processing flow: incoming DTOs are checked for required fields, positive prices, and minimum stock rules as described in the README.
- This suggests the controller accepts validated DTOs and rejects invalid input before it reaches deeper layers.
8. Error handling
- exception/GlobalExceptionHandler.java centralizes exception-to-HTTP-response mapping.
- This is the key cross-cutting boundary for returning consistent, user-friendly error messages instead of raw framework exceptions.
- It likely handles validation failures and other application exceptions in a uniform way.
9. Configuration and runtime resources
- src/main/resources/application.properties holds Spring Boot runtime configuration.
- The README mentions SpringDoc/Swagger for endpoint documentation/testing, so API docs are part of the intended runtime story even if no dedicated OpenAPI files are shown in the tree.
- Lombok is also part of the stack, reducing boilerplate in DTOs and models.
10. Tests and repository signal
- There is a test scaffold under src/test/java/.../ejercicio1/Ejercicio1ApplicationTests.java, which looks misaligned with the current ejercicio3 package.
- That suggests either a copied starter test or an incomplete test setup; the visible architecture currently has limited test coverage surfaced in the tree.
- Overall, the repo is a compact layered API: HTTP controller → DTO validation/translation → service logic → global exception handling, with no visible persistence layer.
Main entry points: ProductoController.java Controller · Ejercicio3Application.java App · ProductoService.java Service · ProductoRequestDTO.java Request DTO
Components 11
Application
Spring Boot entrypoint and runtime config
- App · Bootstraps the Spring container
src/main/java/com/practicos/ejercicio3/Ejercicio3Application.java - Config · Spring Boot application settings
src/main/resources/application.properties - Build · Project dependencies and build lifecycle
pom.xml - Tests · Misaligned starter test package
src/test/java/com/practicos/ejercicio1/Ejercicio1ApplicationTests.java
API Boundary
HTTP controller and DTO contracts
- Controller · HTTP entrypoint for product endpoints
src/main/java/com/practicos/ejercicio3/controller/ProductoController.java - Request DTO · Validated input payload for products
src/main/java/com/practicos/ejercicio3/dto/ProductoRequestDTO.java - Response DTO · Output payload returned to clients
src/main/java/com/practicos/ejercicio3/dto/ProductoResponseDTO.java
Core Logic
Domain model and service layer
Cross-Cutting
Validation and global error handling
- Errors · Maps exceptions to HTTP responses
src/main/java/com/practicos/ejercicio3/exception/GlobalExceptionHandler.java - Validation · Custom bean-validation messages
src/main/resources/ValidationMessages.properties
Connections 12
- Build → App: builds · Maven assembles the Spring Boot application
- App → Controller: wires · Application context discovers the REST controller
- Controller → Request DTO: accepts · Controller receives validated request DTOs
- Controller → Service: delegates · Controller forwards work to the service layer
- Service → Producto: uses · Service operates on the internal product model
- Service → Response DTO: returns · Service shapes product output for the API
- Controller → Errors: errors · Controller exceptions are normalized centrally
- Request DTO → Validation: messages · Validation annotations resolve custom messages
- Controller → Validation: validates · Incoming request payloads are checked before service logic
- App → Config: configures · Runtime properties are loaded at startup
- Controller → Config: docs/runtime · API behavior is influenced by application configuration
- Tests → App: targets · Test scaffold appears to reference the wrong package