A robust, enterprise-grade financial management system built in Java to demonstrate advanced Object-Oriented Programming (OOP), Domain-Driven Design (DDD) principles, thread-safe memory storage, and clean architecture separation.
The Financial System OOP simulates a core banking transaction engine. Designed as a production-grade backend application rather than a simple script, it decouples user interactions from domain business logic using a strict 4-tier architecture (UI, Service, Repository, Domain).
The system solves common domain integrity challenges by enforcing official Brazilian CPF algorithm validation, handling deadlock-free concurrent PIX transfers, managing overdraft limits, and maintaining an active investment portfolio growth engine.
- 🏦 Polymorphic Account Management:
ContaCorrente: Transactional account with overdraft (Cheque Especial) limits and maintenance tax calculation (Tributavel).ContaPoupanca: Savings account with automatic monthly compound interest calculations (Rendivel).ContaInvestimento: Investment portfolio tracking asset positions (CDBs, Treasury, FIIs, Equities) with yield simulation and partial or full redemptions.
- ⚡ Deadlock-Free PIX Transfers:
- Transfer funds using account numbers or registered PIX keys (CPF, Email, Phone).
- Implements canonical lock ordering on account IDs to prevent deadlocks under concurrent transactions.
- 🛡️ Domain Integrity & Validation:
- Official Modulo-11 checksum validation algorithm for Brazilian CPFs (
CpfValidator). - Immutable transaction logging (
Transacao) stamped with UUID identifiers and timestamps.
- Official Modulo-11 checksum validation algorithm for Brazilian CPFs (
- 📦 Repository Pattern & Thread Safety:
- In-memory data access decoupled via interfaces (
ClienteRepository,ContaRepository). - Thread-safe storage powered by
ConcurrentHashMapwith indexed lookup methods.
- In-memory data access decoupled via interfaces (
- 🧪 100% Automated Test Coverage:
- Comprehensive unit and integration test suite using JUnit 5 and AssertJ.
- Language: Java (JDK 17+)
- Build Tool: Apache Maven
- Testing Frameworks: JUnit 5, AssertJ
- Architecture: Layered Architecture (UI -> Service -> Repository -> Domain)
src/
├── main/java/com/banco/
│ ├── Main.java # Entry point
│ ├── exception/ # Custom domain exceptions
│ │ ├── FinancialSystemException.java
│ │ ├── SaldoInsuficienteException.java
│ │ ├── CpfInvalidoException.java
│ │ └── ...
│ ├── model/ # Core domain entities & interfaces
│ │ ├── Cliente.java
│ │ ├── Conta.java # Abstract base class
│ │ ├── ContaCorrente.java
│ │ ├── ContaPoupanca.java
│ │ ├── ContaInvestimento.java
│ │ ├── Investimento.java
│ │ ├── Transacao.java
│ │ ├── Rendivel.java # Interface
│ │ └── Tributavel.java # Interface
│ ├── repository/ # Data access abstractions & implementations
│ │ ├── ClienteRepository.java # Interface
│ │ ├── ContaRepository.java # Interface
│ │ ├── InMemoryClienteRepository.java
│ │ └── InMemoryContaRepository.java
│ ├── service/ # Business logic layer
│ │ ├── ClienteService.java
│ │ ├── ContaService.java
│ │ ├── InvestimentoService.java
│ │ └── ExtratoService.java
│ ├── ui/ # Presentation layer
│ │ └── Menu.java # Console UI with ANSI colors & safe input handling
│ └── util/ # Validation utilities
│ ├── CpfValidator.java # Brazilian CPF Modulo-11 algorithm
│ └── ValidationUtils.java
└── test/java/com/banco/ # Unit and integration test suite
├── model/
├── service/
└── util/
graph TD
UI[Console UX - Menu.java] --> Services[Service Layer]
subgraph Services [Business Services]
CS[ClienteService]
CoS[ContaService]
IS[InvestimentoService]
ES[ExtratoService]
end
Services --> Repositories[Repository Layer]
subgraph Repositories [In-Memory Repositories]
CR[InMemoryClienteRepository]
CoR[InMemoryContaRepository]
end
Services --> Domain[Domain Layer]
subgraph Domain [Domain Models & Entities]
Client[Cliente & CpfValidator]
Accounts[Conta -> CC, CP, CI]
Assets[Investimento Portfolio Engine]
Tx[Transacao Log]
end
- Java Development Kit (JDK): Version 17 or higher (JDK 24 recommended)
- Apache Maven: Version 3.8 or higher
-
Clone the repository:
git clone https://github.com/your-username/Java-Financial-System-OOP.git cd Java-Financial-System-OOP -
Run unit & integration tests:
mvn clean test -
Compile and execute the application:
mvn clean compile exec:java
Alternatively, package and run as a standalone JAR:
mvn clean package java -jar target/sistema-bancario-1.0-SNAPSHOT.jar
Felipe da Silva Spinola
Software Engineer & Backend Developer