This project consists of a RESTful API for customer management and financial transfers.
- Java 25
- Spring Boot 4
- H2
- Maven
- Prerequisites: Make sure you have JDK 21 and Maven installed.
- Clone the repository:
git clone https://github.com/barcellos-pedro/api-transferencia.git
cd api-transferencia- Compile and run:
mvn spring-boot:run- Access the API: The application will be available at
http://localhost:8080. - Interactive Documentation (Swagger): Access
http://localhost:8080/swagger-ui/index.htmlto test the endpoints in the browser
The API follows RESTful patterns and URL versioning (/v1/...):
Customers:
GET /v1/customers: General customer listing.POST /v1/customers: Register new customer.GET /v1/customers/{account}: Search Customer by account number.GET /v1/customers/{account}/transfers: History ordered by descending date, including failures.POST /v1/customers/{account}/transfers: Perform transfer between accounts (Limit of R$ 10,000.00).
GET /api-docs- OpenAPI specification in JSON.GET /actuator/health: Application health check.GET /swagger-ui/index.html: Visual interface to test API endpoints.
The API uses Spring Boot Actuator to provide metrics and health status, essential for production environments and observability.
Diagnostic Endpoints (Actuator)
| Endpoint | Description | Purpose |
|---|---|---|
| GET /actuator/health | Application Health | Checks if App, DB and Disk are operational. |
| GET /actuator/metrics | Metrics | Lists available metrics (JVM, CPU, HTTP Requests). |
| GET /actuator/info | Information | Custom data about project version and build. |
As requested, unsuccessful transfers are also stored. To ensure that the failure record is
persisted even when the financial transaction suffers rollback, I used REQUIRES_NEW propagation in the audit
service. This guarantees the integrity of the history for banking compliance.
To meet the concurrency control requirement in the transfer operation, the following was implemented:
- Pessimistic Locking (or Optimistic Locking with
@Version): To avoid the "Lost Update" problem when two processes try to debit from the same account simultaneously.
The rules of sufficient balance and maximum limit of R$ 10,000.00 per operation were centralized in the service layer, ensuring that the database state remains consistent.
Test coverage was prioritized to ensure the reliability of transfers:
- Unit Tests: Validation of business logic and balance calculations.
- Integration Tests: Complete transfer flow simulating concurrency and database rollback.
Run the tests with:
mvn testThe project was structured using Spring Initializr.
Technology Stack and Dependencies
Below, the main components selected to meet the API requirements: