# maxizampa/programacion4-practico3 architecture

> Architecture diagram of the GitHub repository maxizampa/programacion4-practico3, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maxizampa/programacion4-practico3
- Repository: https://github.com/maxizampa/programacion4-practico3

## Overview

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: [`src/main/java/com/practicos/ejercicio3/controller/ProductoController.java`](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/controller/ProductoController.java) (Controller), [`src/main/java/com/practicos/ejercicio3/Ejercicio3Application.java`](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/Ejercicio3Application.java) (App), [`src/main/java/com/practicos/ejercicio3/service/ProductoService.java`](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/service/ProductoService.java) (Service), [`src/main/java/com/practicos/ejercicio3/dto/ProductoRequestDTO.java`](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/dto/ProductoRequestDTO.java) (Request DTO)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_node1(("App<br/>spring-boot entrypoint"))
  node_node9["Config"]
  node_node10["Build<br/>[pom.xml]"]
  node_node11["Tests<br/>test scaffold"]
end

subgraph group_api["API Boundary"]
  node_node2["Controller"]
  node_node3["Request DTO<br/>request contract"]
  node_node4["Response DTO<br/>response contract"]
end

subgraph group_core["Core Logic"]
  node_node5["Service"]
  node_node6["Producto<br/>domain model<br/>[Producto.java]"]
end

subgraph group_cross["Cross-Cutting"]
  node_node7["Errors<br/>exception handler"]
  node_node8["Validation<br/>message bundle"]
end

node_node10 -->|"builds"| node_node1
node_node1 -->|"wires"| node_node2
node_node2 -->|"accepts"| node_node3
node_node2 -->|"delegates"| node_node5
node_node5 -->|"uses"| node_node6
node_node5 -->|"returns"| node_node4
node_node2 -->|"errors"| node_node7
node_node3 -->|"messages"| node_node8
node_node2 -->|"validates"| node_node8
node_node1 -->|"configures"| node_node9
node_node2 -.->|"docs/runtime"| node_node9
node_node11 -.->|"targets"| node_node1

click node_node1 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/Ejercicio3Application.java"
click node_node2 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/controller/ProductoController.java"
click node_node3 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/dto/ProductoRequestDTO.java"
click node_node4 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/dto/ProductoResponseDTO.java"
click node_node5 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/service/ProductoService.java"
click node_node6 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/model/Producto.java"
click node_node7 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/exception/GlobalExceptionHandler.java"
click node_node8 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/resources/ValidationMessages.properties"
click node_node9 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/resources/application.properties"
click node_node10 "https://github.com/maxizampa/programacion4-practico3/blob/main/pom.xml"
click node_node11 "https://github.com/maxizampa/programacion4-practico3/blob/main/src/test/java/com/practicos/ejercicio1/Ejercicio1ApplicationTests.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node1,node_node9,node_node10,node_node11 toneBlue
class node_node2,node_node3,node_node4 toneAmber
class node_node5,node_node6 toneMint
class node_node7,node_node8 toneRose
```

## Components

### Application

Spring Boot entrypoint and runtime config

- [App](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/Ejercicio3Application.java): spring-boot entrypoint · Bootstraps the Spring container · `src/main/java/com/practicos/ejercicio3/Ejercicio3Application.java`
- [Config](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/resources/application.properties): runtime config · Spring Boot application settings · `src/main/resources/application.properties`
- [Build](https://github.com/maxizampa/programacion4-practico3/blob/main/pom.xml): maven build · Project dependencies and build lifecycle · `pom.xml`
- [Tests](https://github.com/maxizampa/programacion4-practico3/blob/main/src/test/java/com/practicos/ejercicio1/Ejercicio1ApplicationTests.java): test scaffold · Misaligned starter test package · `src/test/java/com/practicos/ejercicio1/Ejercicio1ApplicationTests.java`

### API Boundary

HTTP controller and DTO contracts

- [Controller](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/controller/ProductoController.java): REST controller · HTTP entrypoint for product endpoints · `src/main/java/com/practicos/ejercicio3/controller/ProductoController.java`
- [Request DTO](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/dto/ProductoRequestDTO.java): request contract · Validated input payload for products · `src/main/java/com/practicos/ejercicio3/dto/ProductoRequestDTO.java`
- [Response DTO](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/dto/ProductoResponseDTO.java): response contract · Output payload returned to clients · `src/main/java/com/practicos/ejercicio3/dto/ProductoResponseDTO.java`

### Core Logic

Domain model and service layer

- [Service](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/service/ProductoService.java): business service · Core product logic and translation · `src/main/java/com/practicos/ejercicio3/service/ProductoService.java`
- [Producto](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/model/Producto.java): domain model · Internal product representation · `src/main/java/com/practicos/ejercicio3/model/Producto.java`

### Cross-Cutting

Validation and global error handling

- [Errors](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/java/com/practicos/ejercicio3/exception/GlobalExceptionHandler.java): exception handler · Maps exceptions to HTTP responses · `src/main/java/com/practicos/ejercicio3/exception/GlobalExceptionHandler.java`
- [Validation](https://github.com/maxizampa/programacion4-practico3/blob/main/src/main/resources/ValidationMessages.properties): message bundle · Custom bean-validation messages · `src/main/resources/ValidationMessages.properties`

## Connections

- 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
