### Design a system to manage wallets
1. Allow customer to see their balance
2. Allow customers to transfer funds to each other
3. Customer can see their tnx histories
Database:
1. Record the balance of each customer
2. Updating / increase or decrease of balance
3. Store transactions
4. Backups / replicas
Table for Balance
Primary key - customer_id (integer)
Balance - (integer with 2.d.p)
Table for Transactions
customer_id (integer)
Primary key - transaction_id (integer)
Table for Transaction Info
Primary key - transaction_id (int)
Customer_key (int) - unique
time_of_transaction_of_sender (datetime)
time_of_transaction_of_receipient (datetime)
amount (int 2.d.p)
Fee_amount (integer)
receipient (integer) foreign key reference Balance.customer_id
2. Allow customers to transfer funds to each other
- Sender has enough funds
- Receipient exists
- Sender cannot send to him/herself
- Sender after deducting funds has sufficient amount left for fee
- Check if there is a duplicate customer_key
- Database - checking if unique
- Inform the customer and check if the transaction is valid
- Parameters(sender, receipient, amount, fee)
- Update of table
- Decrease of sender balance + fee (Balance table)
- Returm sender_time_of_transaction
- Increase of receipient balance (Balance table)
- Returm receipt_time_of_transaction
- Create new transaction id (sneder_ / receipt_time_of_transaction, fee)
1. Allow customer to see their balance
2. Allow customers to transfer funds to each other
3. Customer can see their tnx
2. /send_funds
/send_funds/check_funds
// fee is checked
/send_funds
(receipient, amount, key)
PUT - Balance table
POST - Transactions / Transactions_info