π¦ A modern dual-interface Python banking system showcasing clean architecture, OOP, Pydantic v2 validation, SQLite persistence, secure PIN authentication, and seamless CLI + Web experiences.
PyBank lets you register customers, open secured bank accounts, perform deposits, withdrawals, transfers, close accounts, and view detailed transaction histories with passbook-style statements. Built for learning and demonstration of production-grade patterns in Python.
Status: π Early-stage educational project. Explore the Architecture Guide and User Guide for deeper insights.
- β¨ Features
- ποΈ Project Structure
- π Getting Started
- π» Usage
- ποΈ Data Model
- π Documentation
- π οΈ Development
- π License
- π₯οΈ Dual Interface β Intuitive terminal CLI (
main.py) and feature-rich Streamlit web UI (streamlit_app.py) - π€ Smart Account Registration β Captures Aadhaar, personal details, and sets up secure PIN protection
- π Secure Authentication β 4-digit PINs hashed with PBKDF2-HMAC-SHA256 using unique salts
- π΅ Deposits & Withdrawals β Real-time balance updates with PIN verification and validation
- πΈ Fund Transfers β Secure transfers between accounts with atomic transactions and rollback on errors
- π Account Management β Close/deactivate accounts with PIN verification
- π Balance & Profile Views β Quick balance checks and comprehensive customer/account profiles
- π Transaction History β Passbook-style statement with running balances and timestamps
- β Robust Validation β Pydantic v2 validates all inputs at the trust boundary
- ποΈ Reliable Persistence β SQLite with WAL journaling, schema auto-creation, and migrations
- ποΈ Clean Design β Singleton connection manager, enum-based routing, and layered architecture
- π Transactional Integrity β Commits on success, automatic rollback on errors
pybank/
βββ main.py # πͺ CLI application entry point
βββ streamlit_app.py # π Streamlit web UI
βββ pyproject.toml # π¦ Project metadata & dependencies (uv)
βββ justfile # β‘ Task recipes
βββ README.md # π Project documentation
βββ LICENSE # βοΈ Apache-2.0 License
βββ db/ # πΎ SQLite database (auto-created)
βββ docs/ # π Documentation
β βββ architecture.md
β βββ components.md
β βββ presentation.md
β βββ user-guide.md
βββ src/
β βββ app.py # π CLI loop & BankAction router
β βββ const.py # π DB config & menu constants
β βββ enums.py # π’ BankAction enumeration
β βββ sqlite_db.py # ποΈ Singleton SQLite connection + schema
β βββ validators/
β β βββ models.py # π‘οΈ Pydantic models
β βββ handlers/
β β βββ pybank.py # πΌ Core banking operations
β βββ helpers/
β β βββ design.py # 𧬠SingletonMeta
β β βββ security.py # π PIN hashing
β βββ utils/
β βββ cli_utils.py # π¨ Colored output
βββ tests/ # π§ͺ Test suite
git clone https://github.com/anupmika/pybank.git
cd pybank
uv sync --no-cachepython main.py
# or
uv run main.py
# or
just runstreamlit run streamlit_app.py
# or
uv run streamlit run streamlit_app.py
# or
just dev-ui----------------------
| PyBank |
----------------------
| 1 | Open Account |
----------------------
| 2 | Deposite Money |
----------------------
| 3 | Withdraw Money |
----------------------
| 4 | View Balance |
----------------------
| 5 | View History |
----------------------
| 6 | Close Account |
----------------------
| 7 | View Account |
----------------------
| 8 | Transfer Money |
----------------------
| 9 | Close App |
----------------------
See User Guide for detailed walkthroughs.
| Column | Type | Constraints | Notes |
|---|---|---|---|
| id | INTEGER | PK (autoincrement) | Primary key |
| aadhar_num | TEXT | UNIQUE NOT NULL | 12-digit Aadhaar |
| name | TEXT | NOT NULL | Full name |
| TEXT | NULL | Optional | |
| phone | TEXT | NOT NULL | Phone number |
| age | INTEGER | NOT NULL | Age |
| father_name | TEXT | NOT NULL | Father's name |
| address | TEXT | NULL | Optional |
| city | TEXT | NOT NULL | City |
| initial_balance | REAL | NOT NULL | Initial deposit |
| created_at | TEXT | NOT NULL (ISO) | Created timestamp |
| Column | Type | Constraints | Notes |
|---|---|---|---|
| account_num | INTEGER | UNIQUE NOT NULL | 500000 + user_id |
| user_id | INTEGER | FK -> users(id) NOT NULL | User reference |
| account_type | TEXT | DEFAULT 'savings' | Account type |
| balance | REAL | DEFAULT 0 | Current balance |
| currency | TEXT | DEFAULT 'INR' | Currency |
| is_active | INTEGER | DEFAULT 1 | 1 active, 0 inactive |
| created_at | TEXT | NOT NULL (ISO) | Created timestamp |
| pin_hash | TEXT | NULL | PBKDF2-HMAC-SHA256 hash |
| Column | Type | Constraints | Notes |
|---|---|---|---|
| id | INTEGER | PK (autoincrement) | Primary key |
| account_num | INTEGER | FK -> accounts(account_num) | Account reference |
| transaction_type | TEXT | NOT NULL | deposit/withdraw/transfer_in/transfer_out |
| amount | REAL | NOT NULL | Amount |
| balance_after | REAL | NOT NULL | Balance after tx |
| timestamp | TEXT | NOT NULL (ISO) | Timestamp |
| Document | Description |
|---|---|
| Architecture Guide | Design patterns, layers, and flows |
| Component Reference | Module/class/function details |
| User Guide | Step-by-step usage for CLI and web |
| Presentation | Project presentation and diagrams |
just test # Run tests
just coverage # Run with coverage
just sync # Install deps
just run # CLI app
just dev-ui # Streamlit app
just clean # Clean artifactsLicensed under the Apache License 2.0. Made with β€οΈ and Python π°