Skip to main content

Documentation 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.

The Despachos API is a Spring Boot REST microservice that manages all dispatch (despacho) operations for the Tienda de Perritos platform. It exposes a JSON API under api/v1/despachos, links every dispatch to a sale through the idCompra foreign key, and publishes interactive docs at /swagger-ui.html through Springdoc OpenAPI.

REST endpoints

Full endpoint reference with request and response schemas

Ventas API

The sales service that dispatch records reference via idCompra

Overview

Port

3002

Base path

api/v1/despachos

Framework

Spring Boot + JPA/Hibernate

Database

MySQL 8.0 (shared tienda schema)

The Despacho entity

Each dispatch record maps to a single Despacho row in MySQL. The idCompra field acts as a soft foreign key referencing the idVenta of a sale in the Ventas API.
Despacho.java
@Entity
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Despacho {
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long idDespacho;

    @DateTimeFormat(iso = DateTimeFormat.ISO.DATE)
    private LocalDate fechaDespacho;

    private String patenteCamion;
    private int intento;
    private Long idCompra;
    private String direccionCompra;
    private Long valorCompra;
    private boolean despachado = false;
}
FieldTypeNotes
idDespachoLongAuto-generated PK
fechaDespachoLocalDateDispatch date, ISO format YYYY-MM-DD
patenteCamionStringTruck license plate
intentointDelivery attempt number (1, 2, 3…)
idCompraLongReferences idVenta in the Ventas API
direccionCompraStringDelivery address copied from the sale
valorCompraLongPurchase value copied from the sale
despachadobooleantrue once the item is delivered, default false

REST endpoints

All endpoints are served at http://localhost:3002/api/v1/despachos. The controller uses @CrossOrigin(origins = "*") to allow cross-origin requests from the React frontend.
MethodPathDescription
POST/api/v1/despachosCreate a new dispatch record
GET/api/v1/despachosList all dispatch records
GET/api/v1/despachos/{idDespacho}Get a single dispatch by ID
PUT/api/v1/despachos/{idDespacho}Update an existing dispatch
DELETE/api/v1/despachos/{idDespacho}Delete a dispatch record
See the API Reference for full request/response schemas and the interactive Swagger playground.
PUT requests require @Valid on the request body. A 404 Not Found is returned when the given idDespacho does not exist (thrown as DespachoNotFoundException).

Docker build

The Despachos API uses the same two-stage Maven → JRE build pattern as the Ventas API.
Dockerfile
# Stage 1 — compile
FROM maven:3.9.9 AS builder
WORKDIR /app
COPY pom.xml .
COPY src ./src
RUN mvn -B -DskipTests package

# Stage 2 — runtime
FROM eclipse-temurin:17-jre AS runtime
WORKDIR /app
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
COPY --chown=appuser:appgroup --from=builder /app/target/*.jar /app/app.jar
USER appuser
EXPOSE 3002
ENV JAVA_TOOL_OPTIONS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0"
ENTRYPOINT ["java", "-jar", "/app/app.jar"]
1

Builder stage

maven:3.9.9 resolves dependencies and runs mvn -B -DskipTests package, producing a fat JAR under target/.
2

Runtime stage

eclipse-temurin:17-jre provides a minimal JRE. A dedicated non-root appuser owns the JAR file.
3

JVM tuning

JAVA_TOOL_OPTIONS enables container-aware memory limits and restricts heap to 75 % of the container’s available RAM.

Environment variables

These variables are injected by Docker Compose at runtime. Spring Boot maps them to the corresponding application.properties keys via relaxed binding.
VariableExample valueDescription
SPRING_DATASOURCE_URLjdbc:mysql://db:3306/tiendaJDBC connection string for the MySQL database
SPRING_DATASOURCE_USERNAMEtiendaDatabase username
SPRING_DATASOURCE_PASSWORDtienda123Database password
SPRING_JPA_HIBERNATE_DDL_AUTOupdateHibernate schema strategy (update, create, validate, or none)
docker-compose.yml (backend-despachos service)
backend-despachos:
  image: ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/tienda-backend-despachos:latest
  restart: always
  ports:
    - "3002:3002"
  environment:
    SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/tienda
    SPRING_DATASOURCE_USERNAME: tienda
    SPRING_DATASOURCE_PASSWORD: tienda123
    SPRING_JPA_HIBERNATE_DDL_AUTO: update
  depends_on:
    - db
Do not use SPRING_JPA_HIBERNATE_DDL_AUTO: create or create-drop in production — these options drop and recreate tables on every startup, destroying existing data.

Build docs developers (and LLMs) love