A comprehensive, production-ready bank management system demonstrating advanced Object-Oriented Programming (OOP) principles in Python. This project showcases inheritance, polymorphism, encapsulation, abstraction, exception handling, and professional software development practices.
# Clone the repository
git clone https://github.com/pyenthusiasts/Bank-Management-OOP.git
cd Bank-Management-OOP
# Install the package
pip install -e .
# Or install with development dependencies
pip install -e ".[dev]"
pip install bank-management-oop
from bank_management import Bank
# Create a bank instance
bank = Bank(name="Python Bank")
# Create a checking account
checking = bank.create_account(
account_type="checking",
account_number="CHK12345",
account_holder="John Doe",
initial_balance=1000.0
)
# Perform operations
checking.deposit(500.0)
checking.withdraw(200.0)
# Check balance
print(f"Balance: ${checking.get_balance():.2f}") # Balance: $1300.00
# View transaction history
for transaction in checking.get_transaction_history():
print(transaction)
# Launch the interactive CLI
bank-cli
# Or run directly with Python
python -m bank_management.cli
checking = bank.create_account(
account_type="checking",
account_number="CHK001",
account_holder="John Doe",
initial_balance=1000.0,
overdraft_limit=500.0, # Overdraft protection
transaction_fee=1.0, # Fee after free transactions
free_transactions=5 # Free transactions per month
)
savings = bank.create_account(
account_type="savings",
account_number="SAV001",
account_holder="Jane Smith",
initial_balance=5000.0,
interest_rate=0.03, # 3% annual interest
minimum_balance=500.0, # Minimum balance requirement
withdrawal_limit=6 # Monthly withdrawal limit
)
# Apply interest
interest = savings.add_interest()
print(f"Interest earned: ${interest:.2f}")
business = bank.create_account(
account_type="business",
account_number="BUS001",
account_holder="Bob Johnson",
business_name="Tech Solutions Inc.",
tax_id="12-3456789",
initial_balance=10000.0,
monthly_fee=25.0 # Monthly maintenance fee
)
# Transfer money between accounts
bank.transfer(
from_account_number="CHK001",
to_account_number="SAV001",
amount=500.0
)
# Save all accounts to disk
bank.save()
# Load accounts from disk
bank.load()
# Create backup
backup_path = bank.storage.backup()
print(f"Backup created: {backup_path}")
from bank_management.exceptions import (
InsufficientFundsError,
InvalidAmountError,
AccountNotFoundError
)
try:
account.withdraw(10000.0)
except InsufficientFundsError as e:
print(f"Error: {e}")
print(f"Available balance: ${e.balance:.2f}")
The system includes a full-featured interactive command-line interface:
==================================================
Python Bank - Banking System
==================================================
1. Create Account
2. View Account Details
3. Deposit Money
4. Withdraw Money
5. Transfer Money
6. View Transaction History
7. Apply Interest (Savings Accounts)
8. List All Accounts
9. Bank Statistics
10. Save Data
11. Load Data
0. Exit
==================================================
Comprehensive documentation is available:
The examples/ directory contains working examples:
python examples/basic_usage.py
Demonstrates:
python examples/advanced_usage.py
Demonstrates:
pytest
pytest --cov=bank_management --cov-report=html
# Test specific module
pytest tests/test_models.py
# Test specific class
pytest tests/test_models.py::TestCheckingAccount
# Test specific method
pytest tests/test_models.py::TestCheckingAccount::test_deposit
Bank-Management-OOP/
├── bank_management/ # Main package
│ ├── __init__.py # Package initialization
│ ├── models.py # Account models
│ ├── bank.py # Bank management class
│ ├── exceptions.py # Custom exceptions
│ ├── storage.py # Data persistence
│ ├── logger.py # Logging configuration
│ └── cli.py # CLI interface
├── tests/ # Test suite
│ ├── __init__.py
│ ├── test_models.py
│ ├── test_bank.py
│ ├── test_storage.py
│ └── test_exceptions.py
├── examples/ # Example scripts
│ ├── basic_usage.py
│ └── advanced_usage.py
├── docs/ # Documentation
│ ├── API.md
│ ├── USAGE.md
│ └── CONTRIBUTING.md
├── .github/ # GitHub workflows
│ └── workflows/
│ ├── ci.yml
│ └── release.yml
├── setup.py # Package setup
├── requirements.txt # Dependencies
├── requirements-dev.txt # Dev dependencies
├── pytest.ini # Pytest configuration
├── .gitignore # Git ignore rules
├── LICENSE # MIT License
└── README.md # This file
BankAccount (ABC)
├── CheckingAccount
├── SavingsAccount
└── BusinessAccount
Bank
└── manages multiple BankAccount instances
BankStorage
└── handles data persistence
Transaction
└── tracks individual transactions
Contributions are welcome! Please see our Contributing Guide for details.
# Clone repository
git clone https://github.com/pyenthusiasts/Bank-Management-OOP.git
cd Bank-Management-OOP
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -e ".[dev]"
# Run tests
pytest
We use:
# Format code
black bank_management tests
# Sort imports
isort bank_management tests
# Lint
flake8 bank_management
# Type check
mypy bank_management
This project is licensed under the MIT License - see the LICENSE file for details.
Made with dedication by the Bank Management Team
Star this repository if you find it useful!