Skip to content

3mrotaha/Banking-System-Console-App

Repository files navigation

Banking System – Console Application

A modular banking system demonstrating core Object-Oriented Programming (OOP) principles and SOLID design patterns. Built with clean architecture separation between business logic, data access, and presentation layers. Focuses on maintainability, extensibility, and type-safe transaction handling with event-driven architecture.

Core Features

  • Account Management: Create, suspend, activate, and deactivate accounts (Credit/Debit)
  • Customer Management: Register customers with multiple account associations
  • Transaction Operations: Deposit, withdrawal, and transfer with validation
  • Balance Tracking: Real-time balance updates with account limit enforcement
  • Transaction History: Query transactions by account or customer with persistent storage
  • Input Validation: Account status checks, balance verification, limit enforcement
  • Exception Handling: Null checks, insufficient funds, inactive account detection
  • Event-Driven Architecture: Transaction completion events with custom event args

System Design

Architecture Overview

The system follows a layered architecture with strict separation of concerns:

BankingSystem/
├── Core/                   # Domain entities and business rules
│   ├── Entities/          # Account, Customer, Transaction abstractions
│   └── Events/            # Event handling for transaction lifecycle
├── Services/              # Business logic orchestration
│   ├── AccountService
│   ├── CustomerService
│   └── TransactionService
├── Data/                  # Data access layer with repository pattern
│   ├── IRepository<T>
│   ├── AccountRepository
│   ├── CustomerRepository
│   └── TransactionRepository
└── ConsoleUI/             # Presentation layer

MainApp/
└── Program.cs             # Dependency injection & bootstrapping

Design Decisions

  • Abstract Base Classes: Account and Transaction<TEventArgs> provide polymorphic behavior for account types and transaction types
  • Interface Segregation: Separate service interfaces (IAccountService, ICustomerService, ITransactionService) for independent operations
  • Repository Pattern: Generic IRepository<T> abstracts data storage, enabling future persistence implementations (database, file system)
  • Event-Driven Transactions: Transactions trigger TransactionCompleted events for logging, auditing, or notification extensions
  • Dependency Injection: Services accept repository interfaces via constructor injection, enabling testability and flexibility

OOP Principles Applied

Encapsulation

  • Private setters on ID properties prevent external modification
  • Balance protected setter ensures only Account methods modify state
  • Accounts collection in Customer managed through AssignAccount() method

Abstraction

  • Account abstract class defines contract for all account types with AccLimitExceeded() abstract method
  • ITransaction interface standardizes transaction behavior (Execute(), status tracking)
  • Transaction<TEventArgs> generic base class provides template for transaction implementation

Inheritance

  • CreditAccount and DebitAccount inherit from Account with specialized limit logic
  • DepositeTransaction, WithdrawTransaction, TransferTransaction inherit from Transaction<TEventArgs>
  • Repository implementations (AccountRepository, CustomerRepository, TransactionRepository) implement IRepository<T>

Polymorphism

  • Account.AccLimitExceeded() overridden by derived classes for different business rules
  • Transaction.Execute() polymorphic behavior for deposit, withdrawal, transfer operations
  • IRepository<T> allows service layer to work with any repository implementation

SOLID Principles Applied

Single Responsibility Principle (SRP)

  • Account: Manages balance and account state only
  • Transaction: Handles transaction execution logic
  • Service Classes: Each service focuses on one entity type (Account, Customer, Transaction)
  • Repository Classes: Only responsible for data storage/retrieval

Open/Closed Principle (OCP)

  • New account types can be added by extending Account without modifying existing code
  • New transaction types extend Transaction<TEventArgs> (system extensible for loan payments, fees, etc.)
  • Event system allows adding observers without modifying transaction logic

Liskov Substitution Principle (LSP)

  • All Account derivatives (CreditAccount, DebitAccount) can substitute base class
  • Any ITransaction implementation works interchangeably in TransactionService
  • Repository pattern ensures any IRepository<T> implementation is substitutable

Interface Segregation Principle (ISP)

  • Separate interfaces for services (IAccountService, ICustomerService, ITransactionService)
  • Clients depend only on the interface methods they use
  • IRepository<T> provides minimal CRUD operations without forcing unnecessary methods

Dependency Inversion Principle (DIP)

  • Services depend on IRepository<T> abstraction, not concrete implementations
  • Program.cs injects repository implementations into services
  • High-level modules (services) don't depend on low-level modules (repositories)

Design Patterns

Repository Pattern

  • Generic IRepository<T> interface with concrete implementations for each entity
  • Abstracts data access from business logic
  • Enables future migration to database storage (Entity Framework, Dapper)

Template Method Pattern

  • Transaction<TEventArgs> defines transaction lifecycle with Execute() abstract method
  • Derived classes implement specific execution logic while inheriting common behavior

Observer Pattern

  • Event system (TransactionCompleted) allows decoupled notification of transaction outcomes
  • Services subscribe to transaction events for logging/auditing without tight coupling

Technologies

  • Language: C# 12
  • Framework: .NET 8
  • Application Type: Console Application
  • Architecture: Layered (Core/Services/Data/UI separation)

How to Run

  1. Clone the repository:

    git clone <repository-url>
    
  2. Open the solution in Visual Studio 2022 or later

  3. Build the solution:

    • Right-click solution → Build Solution
    • Or press Ctrl+Shift+B
  4. Run the MainApp project:

    • Set MainApp as startup project if not already
    • Press F5 to run

Project Structure

  • BankingSystem.csproj: Core library containing domain models, services, and data layer
  • MainApp.csproj: Entry point application with dependency wiring and UI initialization

About

Layered banking system built with C# and .NET 8 demonstrating OOP, SOLID principles, Repository pattern, and event-driven transaction handling in a console application.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages