A production-style banking backend with strict RBAC, hashed PIN authentication, account lock policies, immutable history logs, and fully ACID-safe money movement.
Modular structure for security, clarity and maintainability.
Responsibilities clearly separated across Customer, Teller and Admin.
| Capability | Customer | Teller | Admin |
|---|---|---|---|
| View Balance | ✔️ | ✔️ | ✔️ |
| Deposit / Withdraw | ✔️ (self) | ✔️ | ✔️ |
| Transfer Money | ✔️ (self) | ✔️ | ✔️ |
| Create Account | ❌ | ✔️ | ✔️ |
| Lock/Unlock Account | ❌ | ✔️ | ✔️ |
| View All Users | ❌ | ❌ | ✔️ |
| View Audit Logs | ❌ | ❌ | ✔️ |
Permission checks run at both API and SQL layers to block privilege escalation.
Ledger-style financial design.
users (id, user_name, password, role) accounts (id, account_no, name, pin_hash, 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 are hashed using bcrypt. The history table acts as an append-only mini ledger recording all movement.
BEGIN; SELECT * FROM accounts WHERE id='A' FOR UPDATE; SELECT * FROM accounts WHERE id='B' FOR UPDATE; UPDATE accounts ... INSERT INTO history ... COMMIT;
Row-level locks ensure that two withdrawals on the same account cannot run in parallel or corrupt balance.
Every action leaves a trace.
• Eliminating race conditions → row-level locks
• Brute-force PIN attempts → auto lockout
• Guaranteed traceability → strict audit logs
• No 2FA for high-risk ops
• Audit logs not append-only
• No AML/KYC pipeline
• Single database (non-distributed)
✓ ACID-safe financial transactions
✓ Secure auth (bcrypt + JWT)
✓ Ledger and audit design
✓ Modular FastAPI architecture