Case study · 12 / 12
Mini Bank
A banking system in plain Python
- Year
- 2024
- Focus
- Python
- Status
- Complete
A banking system written in pure Python for my MSc software development module: accounts, deposits, withdrawals, transfers and management reports, run from the command line with no libraries beyond the standard one.
A bank is a good test of a programmer, because money forgives nothing. A balance cannot go missing, a withdrawal cannot exceed what is there, and not every member of staff should see every figure. I built Mini Bank to get those rules right with the fewest tools possible: Python, its standard library and a terminal. The design is object-oriented. A customer account guards its own balance behind private fields, so nothing outside the account can change it except a deposit or a withdrawal that passes the checks. An admin signs in and works through a menu: move money between customers, update or close an account, print one customer or all of them, and save the whole bank to a file. A management report adds it up, with the number of customers, the total held, the interest due over a year and the overdrafts outstanding, and only an admin with full rights may run it. Then I tried to break it, with twenty written test cases covering good input and bad, and it held.
What it does
- 01Signs admins in with a username and password
- 02Deposits to and withdraws from any customer account
- 03Transfers money between two customers
- 04Updates a customer's details, or closes the account
- 05Prints one customer's record, or every customer's
- 06Saves all accounts to a CSV file and loads them back
- 07Produces a management report: customers, total balance, yearly interest and overdrafts
How it was solved
- 01Modelled the bank as three classes: the bank system, the customer account and the admin
- 02Kept each balance private to its account, reachable only through deposit and withdraw
- 03Rejected bad money at the door: no zero or negative amounts, and no withdrawal above the balance
- 04Checked the sender's balance before a transfer moves a penny
- 05Caught bad input and missing files, so a typing slip never crashes the program
- 06Restricted the management report to admins with full rights
- 07Stored the data with Python's own csv module, so the system runs anywhere Python does
- 08Wrote a 20-case test table, from a failed login to a refused transfer, and passed every case
20 of 20 test cases passed, on nothing but the Python standard library.
Stack
- Language
- Python 3
- Standard library
- csvException handlingFile input and output
- Design
- Object-oriented programmingEncapsulationRole-based accessMenu-driven command line
- Testing
- Manual test-case tableInput validation tests
- #python
- #oop
- #command-line
- #banking
- #csv
That is the work. Now meet the person who built it.