A RESTful API for a simple banking system, built with Spring Boot, heavily focused on best practices like Clean Architecture, SOLID principles, and Clean Code.
- Java 17
- Spring Boot 3.2.5 (Web, Data JPA, Validation)
- H2 Database (In-memory for DEV, persistent for PROD)
- Springdoc OpenAPI (Swagger) for interactive documentation
- Lombok to reduce boilerplate
- JUnit 5 / Mockito for unit testing
- TestRestTemplate / @SpringBootTest for integration testing
- JPA Auditing for automatic creation/modification timestamps tracking
- Clients: Account creation associated with client registration; custom CPF validation; paginated listing (
Pageable). - Accounts: Support for Account Types (CHECKING/SAVINGS).
- Operations: Withdrawals, Deposits, and Transfers with atomic balance calculations.
- Transactions: Automatic and auditable recording of movements; paginated bank statements.
- Error Handling: Global Exception Handler (
@ControllerAdvice) managing rich messages to the client,@Validfield validations, etc. - Structured Logging: Systemic interception with SLF4J at every transactional step.
- Layer Segregation: Code divided clearly into
domain,application,presentation, andinfrastructurelayers. - "Tell, Don't Ask": Domain business logic (e.g., depositing and withdrawing balance) is cohesively encapsulated directly inside the relational
Conta(Account) class. - DTOs & Records: Protection of the transactional application layer using isolated, immutable contracts (Request/Response) via Java Records.
The application has two main active profiles configured: dev (default) and prod.
- Clone the repository
- Run the Maven command at the root:
mvn spring-boot:run
- The API will be available at
http://localhost:8080/api.
- Access
http://localhost:8080/docsto inspect, generate mock requests, and freely interact with the endpoints.
- Access
http://localhost:8080/h2-console - Username:
sa - Password: (empty)
- JDBC URL:
jdbc:h2:mem:bancodb
The tests for this API consist of:
- Unit Tests: Tests running with injected independent mocks from Mockito, simulating
infrastructurecontracts (repositories) to ensure logic conditions and@ThrowExceptions. - Integration Tests: Randomized web environment that builds the full Spring container and executes tests calling endpoints directly on Controllers using
TestRestTemplate, verifying database persistence integrity and preciseHttpStatusbehaviors.
mvn testThis project was completed as an incremental proof of concept involving 30 meticulous steps of structural evolution and corporate backend best practices.