Untitled Document
Untitled Document
● A bucket is filled with tokens at a fixed rate (e.g., 5 tokens per second).
● Each request consumes one token; if no tokens are available, the request is denied or
delayed until more tokens are added.
📌 Steps:
1. A bucket with a capacity (C) holds tokens (e.g., C = 5 for 5 requests per second).
2. Tokens are added at a fixed rate (1 per 200ms to maintain 5 per second).
3. If a request arrives when the bucket has tokens, a token is consumed, and the
request is processed.
4. If the bucket is empty, the request is rejected or queued until tokens are refilled.
● Maintains a moving window of time (e.g., 1 second) and tracks request counts within
that window.
● If requests exceed the limit (e.g., 5 per second), new requests are rejected.
📌 Steps:
Conclusion
● Sliding Window Counter is chosen as it strictly enforces 5 transactions per second,
making it ideal for fraud prevention in banking transactions at Zeta.
● The Token Bucket approach could be explored for more flexibility if occasional burst
handling is needed.
2. Database Schema
For a real-world scenario, we'd use a relational database like PostgreSQL:
sql
CopyEdit
CREATE TABLE accounts (
account_id VARCHAR PRIMARY KEY,
balance DECIMAL NOT NULL CHECK (balance >= 0)
);
This ensures data integrity, foreign key relationships, and balance constraints.
4. Performance Optimizations
○ Dashboard –
✅ View account balance.
✅ Apply for a loan (form-based input).
✅ Check dispute history.
● Income
● Credit Score
● Existing Loans
● Debt-to-Income Ratio
3. Approach Explanation
(a) Building the MVP in 24 Hours with AI-Assisted Tools
If I had to build this fast, I’d use:
● Zapier/n8n: For automating API calls (e.g., fetch balance, check loan status).
● Google Sheets/Airtable: For storing user data without setting up a full DB.
○ Fraudulent Transaction
○ Duplicate Charge
○ Unauthorized Access
○ Past fraud activity (e.g., if the customer has disputed many transactions
before).
3. Approach Explanation
(a) Using AI-Assisted & Low-Code Tools
If I had to implement this with minimal custom code: