A hardened banking backend with strict role-based access, hashed PIN authentication, immutable-style ledgers, and atomic money operations. Built to simulate real financial constraints such as account locking, fraud detection and concurrency safety.
Modular separation across auth, money operations, RBAC and audit-event logging.
Separation of duties between Customer, Teller, and Admin.
ROLE MATRIX
Customer Teller Admin
------------------------------------------------
View Balance ✔️ ✔️ ✔️
Deposit/Withdraw ✔️ ✔️ ✔️
Transfer Money ✔️ ✔️ ✔️
Create Account ❌ ✔️ ✔️
Lock/Unlock Account ❌ ✔️ ✔️
View All Users ❌ ❌ ✔️
View Audit Logs ❌ ❌ ✔️Permission checks occur on both the route layer and inside SQL procedures to prevent privilege escalation.
Highly normalised schema with ledger-style history tables.
users (id, user_name, password, role) accounts (id, account_no, name, pin, balance, failed_attempts, is_locked, user_id) history (id, account_id, amount, type, timestamp) audit_logs (id, actor, action, details, ip, user_agent, timestamp)
PINs use bcrypt hashing and failed login attempts automatically lock the account. The history table works like a mini-ledger capturing all financial activity.
Organised by feature domain.
AUTH
POST /register_account
PUT /change_pin
POST /login
ACCOUNTS
GET /get_account_by_account_no
GET /get_accounts
GET /get_all_potential_accounts
MONEY OPS
POST /deposit
POST /withdraw
POST /transfer_to_another_account
HISTORY + AUDIT
GET /history/{account_no}
GET /get_all_audit_logs (admin only)
DELETE /delete_all_history (demo)
DELETE /delete_all_audit_logs (demo)Full validation pipeline.
BEGIN; SELECT * FROM accounts WHERE id='A' FOR UPDATE; SELECT * FROM accounts WHERE id='B' FOR UPDATE; UPDATE accounts ...; INSERT INTO history ...; COMMIT;
Forensics, fraud detection, and debugging.
Honest constraints compared to real banking infra.
• No multi-factor authentication for high-value actions.
• No distributed transactions or cross-ledger coordination.
• Audit logs not append-only (demo constraint).
• No AML/KYC integration or fraud-detection engine.
✅ ACID transactions for financial safety
✅ Secure auth flows: bcrypt + JWT
✅ How banks protect ledgers and audit trails
✅ Structuring modular APIs with FastAPI routers