0% found this document useful (0 votes)
7 views2 pages

File-Based Transaction Management System

The document outlines the requirements for a File-Based Transaction Management System that simulates and processes financial transactions efficiently without loading entire files into memory. It specifies the creation of a TransactionManager class to handle transaction operations, including generation, persistence, and processing using a custom context manager and lazy loading with generators. Additionally, it emphasizes error handling, logging, and modular code design to ensure maintainability.

Uploaded by

gaurishankara006
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

File-Based Transaction Management System

The document outlines the requirements for a File-Based Transaction Management System that simulates and processes financial transactions efficiently without loading entire files into memory. It specifies the creation of a TransactionManager class to handle transaction operations, including generation, persistence, and processing using a custom context manager and lazy loading with generators. Additionally, it emphasizes error handling, logging, and modular code design to ensure maintainability.

Uploaded by

gaurishankara006
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Project Guide: File-Based Transaction Management System

Overview
You are required to build a minimal Transaction Management application that simulates, records, and processes
financial transactions efficiently. The system must be designed to handle large transaction files without loading them
entirely into memory.

Core Objective
Design a class-based Python application that generates random transactions, persists them to a file, processes
them lazily using generators, and ensures safe file handling using a custom context manager.

Application Structure
Create a TransactionManager class that encapsulates all transaction-related operations including balance
management, transaction generation, persistence, and processing.

Transaction Generation
1 Each transaction must include a transaction ID, type (CREDIT or DEBIT), amount, and resulting balance.
2 Transaction amounts must be generated randomly within a dynamic range based on the current balance.
3 Debit transactions must not exceed the available balance.
4 All transactions must be written to a file in a structured, comma-separated format.

File Handling (Custom Context Manager)


1 Implement a custom context manager to open and close the transaction file safely.
2 Ensure the file is always closed, even if an exception occurs.
3 Log file open and close operations using the logging module.

Transaction Processing (Generator)


1 Implement a generator function to read and yield one transaction at a time.
2 Convert raw file lines into structured data such as tuples or dictionaries.
3 Skip invalid records gracefully and log parsing errors.

Transaction Summary
1 Compute the total number of valid transactions.
2 Compute total credited and debited amounts.
3 Compute the final account balance after processing.

Error Handling and Logging


1 Use Python’s logging module to record errors and key events.
2 Handle malformed records using exception handling without stopping execution.

Constraints
1 The entire transaction file must not be loaded into memory.
2 File processing must be lazy using generators.
3 Do not use global variables.
4 Code must be modular, readable, and maintainable.

You might also like