RESTful API built with Spring Boot for managing orders.
The project demonstrates clean layered architecture, validation with meaningful error responses, database migrations with Flyway, API documentation via Swagger/OpenAPI, and Integration tests use Testcontainers to spin up a real PostgreSQL instance automatically, ensuring environment parity and reliable database validation.
This project was developed for study and portfolio purposes, following production-oriented practices.
- CRUD operations for orders
- Pagination and sorting with Spring Data Pageable
- API documentation with Swagger / OpenAPI
- Database versioning with Flyway
- PostgreSQL integration via Docker
- Java 17
- Spring Boot
- Spring Web + Spring Validation
- Spring Data JPA
- PostgreSQL
- Flyway (migrations)
- springdoc-openapi (Swagger UI)
- JUnit 5 + MockMvc
- Testcontainers (PostgreSQL)
- Java 17+
- Maven (or Maven Wrapper)
- PostgreSQL
- Docker (required only for integration tests with Testcontainers)
- DB:
ordersdb - User:
orders - Password:
orders
Update src/main/resources/application.properties accordingly.
docker-compose up -d./mvnw spring-boot:run./mvnw spring-boot:run-
Swagger UI: http://localhost:8080/swagger-ui/index.html
-
OpenAPI JSON: http://localhost:8080/v3/api-docs
{
"customerEmail": "teste@teste.com",
"totalCents": 1000
}Responses:
-
201 Created with an OrderResponse
-
400 Bad Request with ApiError + violations
Responses:
-
200 OK with an OrderResponse
-
404 Not Found with ApiError
Response:
- 200 OK with a Spring Page
{
"timestamp": "2026-01-03T06:07:17.451166600Z",
"status": 400,
"error": "Bad Request",
"message": "Validation failed",
"path": "/orders",
"violations": [
{ "field": "customerEmail", "message": "customerEmail deve ser um e-mail válido" },
{ "field": "totalCents", "message": "totalCents deve ser maior ou igual a 0" }
]
}- src/main/resources/db/migration
- Windows:
.\mvnw clean test- Mac/Linux:
./mvnw clean test-
Integration tests start a real PostgreSQL container automatically.
-
Docker must be running for Testcontainers-based tests.
-
controller/ REST endpoints
-
service/ business logic
-
repository/ persistence layer
-
entity/ JPA entities
-
dto/ request/response DTOs
-
exception/ custom exceptions and standardized error payload (ApiError)
Igor Carvalho
Backend developer focused on Java and Spring Boot.
This project was developed for learning and portfolio purposes.