A comprehensive CLI-based banking application built with Rust, demonstrating advanced programming concepts and best practices.
- Customer Management: Register new customers with unique IDs
- Account Operations: Create accounts with initial deposits
- Transactions:
- Deposit money
- Withdraw money
- Transfer between accounts
- Transaction History: View detailed transaction logs with timestamps
- Data Persistence: Automatic saving/loading of bank data in JSON format
- Search & Statistics: Search customers and view comprehensive bank statistics
This project showcases a wide range of Rust concepts:
- Transfer of ownership in Customer/Account creation
- Immutable and mutable borrowing (
&self,&mut self) - Reference lifetimes in method signatures
- Documentation
Arc<T>: Thread-safe reference countingMutex<T>: Thread-safe interior mutability- Documentation
- Custom error types with enums
Result<T, E>for recoverable errorsOption<T>for optional values- Error propagation with
?operator - Documentation
- Custom trait definition (
Summarizable) - Trait implementation for multiple types
- Derived traits (
Debug,Clone,Serialize, etc.) - Documentation
- Iterator methods:
filter,map,sum,collect,any,enumerate - Closures with different capture modes
- Lazy evaluation
- Documentation
- Match expressions
if let/while let- Destructuring in patterns
- Documentation
Vec<T>: Dynamic arraysHashMap<K, V>: Key-value storage for O(1) lookups- String vs &str
- Documentation
- Serde for JSON serialization/deserialization
- Derive macros
- Documentation
- Type aliases (
BankResult<T>) - Generic types (
Vec<T>,HashMap<K,V>, etc.) - Documentation
pubkeyword for public APIs- Struct field visibility
- Documentation
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
chrono = { version = "0.4", features = ["serde"] }
uuid = { version = "1.0", features = ["v4", "serde"] }- Rust 1.70 or higher
- Cargo (comes with Rust)
# Clone or navigate to the project directory
cd rust-banking-system
# Build the project
cargo build --release
# Run the application
cargo run --releaseβββββββββββββββββββββββββββββββββββββββββββββ
β π¦ RUST BANKING SYSTEM CLI v1.0 π¦ β
βββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββ
MAIN MENU
βββββββββββββββββββββββββββββββββββββββββββ
1. π Register New Customer
2. π³ Create Account for Customer
3. π° Deposit Money
4. πΈ Withdraw Money
5. π Transfer Money
6. π View Account Details
7. π View Transaction History
8. π₯ List All Customers
9. π Search Customers
10. π View Bank Statistics
11. πΎ Save Data
0. πͺ Exit
βββββββββββββββββββββββββββββββββββββββββββ
-
Register a Customer
Enter your choice: 1 Enter customer name: John Doe Enter customer email: john@example.com -
Create an Account
Enter your choice: 2 Enter customer ID: [paste customer ID] Enter initial deposit amount: 1000 -
Make a Deposit
Enter your choice: 3 Enter customer ID: [paste customer ID] Enter amount to deposit: 500 -
Transfer Money
Enter your choice: 5 Enter sender customer ID: [sender ID] Enter recipient customer ID: [recipient ID] Enter amount to transfer: 200
The application automatically saves all data to bank_data.json in the project directory. This file is:
- Created automatically on first save
- Loaded automatically on application start
- Updated when you select "Save Data" or exit the application
βββ Error Handling (BankError enum)
βββ Transaction System
β βββ TransactionType enum
β βββ Transaction struct
βββ Core Banking
β βββ Account struct
β βββ Customer struct
β βββ Bank struct
βββ Traits (Summarizable)
βββ CLI Interface (BankCLI)
βββ Persistence Layer (JSON)
# Build and run
cargo run
# Build with optimizations
cargo build --release
# Check for issues
cargo check
# Format code
cargo fmt
# Run linter
cargo clippy- Customer IDs and Account IDs are generated using UUIDs (v4)
- All monetary amounts use
f64for simplicity (in production, use decimal types) - Data is stored in plaintext JSON (in production, consider encryption)
- Thread-Safe Design: Uses
Arc<Mutex<T>>for concurrent access - Functional Programming: Extensive use of iterators and closures
- Type Safety: Strong typing with custom error types
- Zero-Cost Abstractions: Efficient compiled code
- Memory Safety: No garbage collector, no null pointers
- Pattern Matching: Exhaustive matching for safety
- Multi-threaded transaction processing
- Database integration (SQLite/PostgreSQL)
- Web API interface (using Actix/Rocket)
- Authentication and authorization
- Interest calculation
- Loan management
- Transaction reversal/cancellation
- Audit logging
This project is created for educational purposes to demonstrate Rust programming concepts.
Feel free to fork, modify, and use this project for learning Rust!
Built with β€οΈ using Rust π¦