DEV Community

Sajjad Rahman
Sajjad Rahman

Posted on Edited on

Protect 01

Project Title: Smart Banking Transaction Monitoring System

Project Type: Console-Based Python Application

Domain: FinTech, Banking, Financial Transaction Monitoring and Fraud Detection

Technology: Python (Built-in Modules)

2. Problem Statement

Develop a Python-based Smart Banking Transaction Monitoring System that manages customer information, bank accounts and financial transactions through a menu-driven console application.

The system will allow users to register customers, create bank accounts, deposit and withdraw money, transfer funds between accounts and maintain transaction histories.

Additionally, the application will calculate transaction statistics and identify potentially suspicious financial activities using predefined business rules.

The application will initially be developed using Python fundamentals and built-in data structures. As development progresses, advanced Python concepts, object-oriented programming, exception handling, file handling and modular software architecture will be incorporated to improve its functionality, reliability and maintainability.

The final application should demonstrate how fundamental and intermediate Python programming concepts can be applied to solve a practical financial monitoring problem.

3. Primary Objectives

  1. Apply Python fundamentals to solve a real-world financial problem.
  2. Practise data structures for managing customer and transaction information.
  3. Develop reusable functions and modular code.
  4. Implement object-oriented programming to represent real-world banking entities.
  5. Apply advanced OOP concepts to improve code organization.
  6. Implement exception handling to manage invalid operations and unexpected situations.
  7. Use file handling and JSON to maintain persistent application data.
  8. Develop transaction monitoring and rule-based suspicious activity detection.
  9. Build a structured, maintainable and functional Python console application.

4. Project Development Requirements

Stage 01: Python Fundamentals

Topics:

  • Variables and data types
  • Conditional statements (if, elif, else)
  • Loops (for and while)
  • Lists and dictionaries
  • Nested dictionaries
  • Basic functions
  • Basic OOP concepts

Functional Requirements:

  1. Register new customers.
  2. Generate unique customer IDs.
  3. Create savings and current accounts.
  4. Display registered customers.
  5. Deposit money into an account.
  6. Withdraw money from an account.
  7. Check account balances.
  8. Build a menu-driven console interface.

Suggested Functions to Implement:

Function Purpose
display_menu() Display the main application menu
get_user_choice() Get the user's menu selection
register_customer() Register a new customer
generate_customer_id() Generate a unique customer ID
view_all_customers() Display all registered customers
search_customer() Search for a customer
create_account() Create a new bank account
deposit_money() Deposit money into an account
withdraw_money() Withdraw money from an account
check_balance() Display the current account balance
main() Control the overall application flow

Python Built-in Functions to Practise:

print(), input(), int(), float(), str(), type(), len(), range(), enumerate(), sum().

Stage 02: Advanced Python Data Structures

Topics:

  • Lists
  • Tuples
  • Sets
  • Dictionaries
  • Nested data structures
  • Data structure methods and iteration

Functional Requirements:

  1. Maintain multiple customer records.
  2. Store multiple bank accounts.
  3. Maintain transaction histories.
  4. Store transaction details using dictionaries.
  5. Use sets to maintain unique identifiers.
  6. Use tuples for fixed transaction categories or other suitable fixed data.
  7. Retrieve and filter transaction records.
  8. Calculate total deposits, withdrawals and transaction counts.

Suggested Functions to Implement:

Function Purpose
add_transaction() Add a transaction to the transaction collection
get_customer_transactions() Retrieve transactions belonging to a customer
filter_transactions() Filter transactions by type or other criteria
get_transactions_by_type() Retrieve deposits, withdrawals or transfers
calculate_total_deposits() Calculate total deposited money
calculate_total_withdrawals() Calculate total withdrawn money
count_transactions() Calculate the number of transactions
get_unique_customers() Retrieve unique customer identifiers
sort_transactions() Sort transactions by amount or another field
display_transaction_history() Display transaction records

Python Data Structure Methods to Practise:

  • Lists: append(), extend(), insert(), remove(), pop(), sort(), reverse(), count(), index()
  • Dictionaries: get(), keys(), values(), items(), update(), pop(), setdefault()
  • Sets: add(), update(), remove(), discard(), union(), intersection()
  • Tuples: count(), index()

Stage 03: Functions and Advanced Function Concepts

Topics:

  • Parameters and arguments
  • Positional and keyword arguments
  • Default parameters
  • Return statements
  • Local and global scope
  • *args and **kwargs
  • Lambda functions

Functional Requirements:

  1. Develop reusable deposit and withdrawal functions.
  2. Implement money transfer functionality.
  3. Create customer search functions.
  4. Develop transaction filtering functions.
  5. Calculate transaction statistics using reusable functions.
  6. Use flexible function arguments for transaction reports.
  7. Separate business logic into individual functions.

Suggested Functions to Implement:

Function Purpose
transfer_money() Transfer money between two accounts
search_customer() Search customers using different parameters
generate_transaction_report() Generate flexible transaction reports
filter_transactions() Filter transactions using multiple criteria
calculate_account_summary() Calculate an account's financial summary
calculate_average_transaction() Calculate average transaction value
get_largest_transaction() Find the largest transaction
get_smallest_transaction() Find the smallest transaction
get_transactions_by_date() Retrieve transactions within a date range
apply_transaction_filters() Apply optional filtering conditions

Specific Function Concepts to Practise:

  1. Positional arguments:

deposit_money(account_id, amount)

  1. Keyword arguments:

generate_transaction_report(customer_id=1001, transaction_type="Deposit")

  1. Default parameters:

view_transaction_history(customer_id, limit=10)

  1. Variable-length positional arguments:

calculate_transaction_totals(*amounts)

  1. Variable-length keyword arguments:

generate_report(**filters)

  1. Lambda functions:
  • Sort transactions by amount.
  • Filter transactions based on conditions.
  • Sort customers by account balance.
  1. Scope:

Understand the difference between local and global variables, and avoid unnecessary global state.

Stage 04: Object-Oriented Programming (OOP)

Topics:

  • Classes and objects
  • Attributes and methods
  • Constructors (__init__)
  • self
  • Instance and class attributes

Functional Requirements:

  1. Create a Customer class.
  2. Create a BankAccount class.
  3. Create a Transaction class.
  4. Create a Bank class.
  5. Implement customer and account management through class methods.
  6. Implement deposit, withdrawal and transfer operations.
  7. Maintain transaction records through objects.

Suggested Classes and Methods:

Customer Class

  • __init__() – Initialize customer information.
  • display_details() – Display customer information.
  • update_details() – Update customer information.
  • get_customer_id() – Return customer ID.

BankAccount Class

  • __init__() – Initialize account information.
  • deposit() – Deposit money.
  • withdraw() – Withdraw money.
  • get_balance() – Return account balance.
  • display_account_details() – Display account information.

Transaction Class

  • __init__() – Initialize transaction information.
  • generate_transaction_id() – Generate a transaction ID.
  • display_transaction() – Display transaction details.

Bank Class

  • __init__() – Initialize bank collections.
  • register_customer() – Register customers.
  • create_account() – Create bank accounts.
  • find_customer() – Find a customer.
  • find_account() – Find an account.
  • transfer_money() – Transfer money between accounts.
  • get_all_customers() – Retrieve all customers.
  • get_transaction_history() – Retrieve transaction records.

Stage 05: Advanced OOP Concepts

Topics:

  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction

Functional Requirements:

  1. Create SavingsAccount and CurrentAccount subclasses.
  2. Implement account-specific transaction rules.
  3. Apply encapsulation to protect account attributes.
  4. Use polymorphism for different account operations.
  5. Introduce abstraction where appropriate.
  6. Improve code reusability through inheritance.

Suggested Classes and Methods:

Class / Method Purpose
SavingsAccount Represent savings accounts
CurrentAccount Represent current accounts
Account Common parent or abstract account class
calculate_interest() Calculate savings account interest where applicable
get_withdrawal_limit() Return the applicable withdrawal limit
withdraw() Implement account-specific withdrawal behaviour
display_account_details() Override account details display
get_account_summary() Return account information

Additional Practice:

  • Use super() to access parent class functionality.
  • Use @property and setter methods for controlled attribute access.
  • Use @classmethod for suitable class-level operations.
  • Use @staticmethod for utility operations that do not require instance or class state.
  • Use ABC and @abstractmethod from the built-in abc module to practise abstraction.
  • Override methods to demonstrate polymorphism.

Stage 06: Exception Handling

Topics:

  • try
  • except
  • else
  • finally
  • raise
  • Built-in exceptions
  • Custom exceptions

Functional Requirements:

  1. Handle invalid customer IDs.
  2. Prevent negative or zero transaction amounts.
  3. Handle insufficient account balances.
  4. Prevent transactions involving nonexistent accounts.
  5. Handle invalid menu selections.
  6. Create custom exceptions, such as:
    • InsufficientBalanceError
    • InvalidAccountError
    • InvalidTransactionError
  7. Display meaningful error messages.
  8. Ensure recoverable errors do not terminate the application unexpectedly.

Suggested Functions and Methods to Implement:

Function / Method Purpose
validate_customer_id() Validate customer identifiers
validate_account_id() Validate account identifiers
validate_amount() Validate transaction amounts
validate_account_exists() Check whether an account exists
validate_sufficient_balance() Check available account balance
validate_menu_choice() Validate menu selections
handle_transaction_error() Handle transaction-related errors
log_error() Record error information

Custom Exception Classes:

  • InsufficientBalanceError
  • InvalidAccountError
  • InvalidTransactionError
  • CustomerNotFoundError

Built-in Exceptions to Practise:

  • ValueError
  • TypeError
  • KeyError
  • IndexError
  • FileNotFoundError
  • PermissionError
  • ZeroDivisionError

Use raise to generate meaningful errors and finally to execute cleanup operations where necessary.

Stage 07: Python Engineering Fundamentals

Topics:

  • Modules
  • Packages
  • Imports
  • Virtual environments
  • File handling
  • Reading and writing files
  • JSON serialization and deserialization
  • Project directory organization

Functional Requirements:

  1. Organize the application into multiple Python modules.
  2. Create separate packages for customers, accounts and transactions.
  3. Import and reuse functions and classes across modules.
  4. Set up a Python virtual environment.
  5. Save customer information in JSON files.
  6. Save transaction histories in JSON files.
  7. Load previously saved information when the application starts.
  8. Update stored information after successful transactions.
  9. Handle file-related exceptions.
  10. Maintain transaction logs.

Suggested Functions to Implement:

Function Purpose
save_customers() Save customer information to JSON
load_customers() Load customer information from JSON
save_accounts() Save account information
load_accounts() Load account information
save_transactions() Save transaction records
load_transactions() Load transaction records
backup_data() Create a backup of application data
initialize_data_files() Create required data files if missing
write_log() Write application events to a log
read_log() Read existing log records

Python Built-in Functions and Modules to Practise:

File handling:

  • open()
  • read()
  • readline()
  • readlines()
  • write()
  • writelines()
  • close()

JSON module:

  • json.dump() – Write Python objects into JSON files.
  • json.load() – Read JSON files into Python objects.
  • json.dumps() – Convert Python objects into JSON strings.
  • json.loads() – Convert JSON strings into Python objects.

Other built-in modules:

  • os – Work with directories and file paths.
  • pathlib – Manage file and directory paths.
  • logging – Maintain application logs.
  • datetime – Work with transaction dates and timestamps.
  • uuid – Generate unique identifiers where appropriate.

Expected Project Structure:

smart_banking/
│
├── main.py
│
├── customers/
│   ├── __init__.py
│   └── customer.py
│
├── accounts/
│   ├── __init__.py
│   └── bank_account.py
│
├── transactions/
│   ├── __init__.py
│   └── transaction.py
│
├── services/
│   ├── __init__.py
│   └── banking_service.py
│
├── monitoring/
│   ├── __init__.py
│   └── fraud_detection.py
│
├── utils/
│   ├── __init__.py
│   └── validators.py
│
├── data/
│   ├── customers.json
│   ├── accounts.json
│   └── transactions.json
│
├── logs/
│   └── banking.log
│
├── .venv/
└── requirements.txt
Enter fullscreen mode Exit fullscreen mode

5. Stage 08: Transaction Monitoring and Rule-Based Fraud Detection

Topics:

  • Conditional business rules
  • Transaction filtering
  • Data aggregation
  • Transaction statistics
  • Risk classification
  • Historical transaction analysis

Functional Requirements:

  1. Identify transactions exceeding predefined thresholds.
  2. Detect repeated high-value transactions.
  3. Identify multiple transactions within a simulated time window.
  4. Categorize transactions based on risk levels.
  5. Maintain a list of suspicious transactions.
  6. Generate transaction monitoring reports.
  7. Display customer transaction statistics.
  8. Store flagged transactions for further review.

Suggested Functions to Implement:

Function Purpose
detect_high_value_transaction() Identify transactions above a threshold
detect_repeated_transactions() Identify repeated transactions
detect_rapid_transactions() Identify multiple transactions within a time window
calculate_risk_score() Calculate a basic rule-based risk score
classify_transaction_risk() Assign risk categories
get_suspicious_transactions() Retrieve flagged transactions
generate_risk_report() Generate a risk analysis report
save_flagged_transactions() Store suspicious transaction records

Example Risk Classification:

Transaction Amount Risk Level
Below 20,000 Normal
20,000–50,000 Medium Risk
Above 50,000 High Risk

Note: These are educational business rules, not actual banking fraud detection standards.

6. Main Application Menu

The final console application should provide the following interface:

========================================
    SMART BANKING MONITORING SYSTEM
========================================

CUSTOMER MANAGEMENT
1. Register New Customer
2. View All Customers
3. Search Customer

ACCOUNT MANAGEMENT
4. Create Bank Account
5. View Account Details
6. Check Account Balance

BANKING OPERATIONS
7. Deposit Money
8. Withdraw Money
9. Transfer Money

TRANSACTION MANAGEMENT
10. View Transaction History
11. Analyze Transactions
12. Generate Transaction Report

TRANSACTION MONITORING
13. Check Suspicious Transactions
14. Generate Risk Report

15. Exit

========================================
Choose an option:
Enter fullscreen mode Exit fullscreen mode

7. Technical Constraints and Development Rules

  1. Use Python as the primary programming language.
  2. Initially use only built-in Python functionality and modules.
  3. Do not use Pandas, NumPy or Scikit-learn.
  4. Do not integrate an external database.
  5. Use dictionaries and lists for initial data storage.
  6. Introduce JSON file storage during the engineering stage.
  7. Use functions and classes instead of writing all logic in one file.
  8. Implement proper input validation and exception handling.
  9. Develop each feature incrementally.
  10. Test individual functionalities before integrating them.
  11. Maintain project progress through Git commits.
  12. Do not copy a complete solution from GitHub.

8. Expected Final Outcome

At the end of this project, the application should be a fully functional, menu-driven Python console system capable of:

  • Managing customers and bank accounts.
  • Performing banking transactions.
  • Maintaining transaction histories.
  • Calculating financial statistics.
  • Detecting potentially suspicious transactions using predefined rules.
  • Handling invalid operations and unexpected errors.
  • Persisting customer and transaction information using JSON files.
  • Maintaining a modular and reusable Python codebase.

The project is intended to demonstrate practical proficiency in Python fundamentals, advanced data structures, functions, OOP, exception handling, file handling and Python engineering fundamentals.

Top comments (0)