The Ventas API is a Spring Boot REST microservice that handles all sales (ventas) operations for the Tienda de Perritos platform. It exposes a JSON API underDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/DevOpsDuoc/Evaluacion02_Devop_Innovatech/llms.txt
Use this file to discover all available pages before exploring further.
api/v1/ventas, persists data to a shared MySQL database via JPA/Hibernate, and publishes interactive API docs at /swagger-ui.html through Springdoc OpenAPI.
REST endpoints
Full endpoint reference with request and response schemas
Docker setup
How all services are orchestrated with Docker Compose
Overview
Port
3001Base path
api/v1/ventasFramework
Spring Boot + JPA/Hibernate
Database
MySQL 8.0 (shared
tienda schema)The Venta entity
Each sale record maps to a single Venta row in MySQL. The table is created or updated automatically by Hibernate at startup based on SPRING_JPA_HIBERNATE_DDL_AUTO.
Venta.java
| Field | Type | Constraints | Notes |
|---|---|---|---|
idVenta | Long | Auto-generated PK | GenerationType.AUTO |
direccionCompra | String | @NotBlank | Purchase delivery address |
valorCompra | int | — | Purchase amount |
fechaCompra | LocalDate | @NotNull, ISO date | Format: YYYY-MM-DD |
despachoGenerado | Boolean | @NotNull, default false | Set to true once a dispatch is created |
REST endpoints
All endpoints are served athttp://localhost:3001/api/v1/ventas. The controller uses @CrossOrigin(origins = "*") so the frontend can reach it from any origin.
| Method | Path | Description |
|---|---|---|
POST | /api/v1/ventas | Create a new sale |
GET | /api/v1/ventas | List all sales |
GET | /api/v1/ventas/{idVenta} | Get a single sale by ID |
PUT | /api/v1/ventas/{idVenta} | Update an existing sale |
DELETE | /api/v1/ventas/{idVenta} | Delete a sale |
POST and PUT requests require a valid Content-Type: application/json header and must include all @NotBlank / @NotNull fields. Validation errors return 400 Bad Request.Docker build
The Ventas API uses a two-stage Docker build to keep the runtime image small. Maven compiles the JAR in the builder stage; the final image contains only the JRE.Dockerfile
Builder stage
maven:3.9.9 downloads dependencies and runs mvn -B -DskipTests package, producing a fat JAR under target/.Runtime stage
eclipse-temurin:17-jre provides a minimal JRE. A dedicated non-root appuser is created and the JAR is copied with correct ownership.Environment variables
These variables are set indocker-compose.yml and must be present at runtime. Spring Boot maps them directly to application.properties keys via its relaxed binding.
| Variable | Example value | Description |
|---|---|---|
SPRING_DATASOURCE_URL | jdbc:mysql://db:3306/tienda | JDBC connection string for the MySQL database |
SPRING_DATASOURCE_USERNAME | tienda | Database username |
SPRING_DATASOURCE_PASSWORD | tienda123 | Database password |
SPRING_JPA_HIBERNATE_DDL_AUTO | update | Hibernate schema strategy (update, create, validate, or none) |
docker-compose.yml (backend service)