Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Financial System OOP 💸

Java Maven JUnit5 Build Status License

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.


📋 Overview

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.


✨ Key Features

  • 🏦 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.
  • 📦 Repository Pattern & Thread Safety:
    • In-memory data access decoupled via interfaces (ClienteRepository, ContaRepository).
    • Thread-safe storage powered by ConcurrentHashMap with indexed lookup methods.
  • 🧪 100% Automated Test Coverage:
    • Comprehensive unit and integration test suite using JUnit 5 and AssertJ.

🛠️ Tech Stack

  • Language: Java (JDK 17+)
  • Build Tool: Apache Maven
  • Testing Frameworks: JUnit 5, AssertJ
  • Architecture: Layered Architecture (UI -> Service -> Repository -> Domain)

📂 Project Structure

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/

🏗️ Architecture & Data Flow

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
Loading

🚀 Getting Started

Prerequisites

  • Java Development Kit (JDK): Version 17 or higher (JDK 24 recommended)
  • Apache Maven: Version 3.8 or higher

Installation & Build

  1. Clone the repository:

    git clone https://github.com/your-username/Java-Financial-System-OOP.git
    cd Java-Financial-System-OOP
  2. Run unit & integration tests:

    mvn clean test
  3. 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

👨‍💻 Author

Felipe da Silva Spinola
Software Engineer & Backend Developer

About

A robust banking & financial transaction engine in Java demonstrating OOP principles, deadlock-free PIX transfers, thread-safe repositories, and investment portfolio management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages