One-time password service inspired by login codes from banks and apps: codes expire quickly, wrong guesses are limited, and delivery by SMS or email happens in the background.
See why generating, sending and checking codes in one place does not scale.
What was missing: Sending a code should not block the request, and a code must expire and work only once.
Why that's risky: A slow SMS provider makes every request wait, and nothing stops unlimited guesses at a six-digit code.
What gets added: One server that generates a code, sends the SMS itself and checks codes against the database.
Trade-offs: Simple, but delivery speed limits throughput.
Split issuing from verifying and enforce expiry and single use in the database.
What was missing: Requesting and verifying a code share one path and nothing enforces expiry or single use.
Why that's risky: Verification also writes (attempt count and used flag), so it is more write-heavy than it looks.
What gets added: A request service that saves a code with a five-minute expiry and zero attempts, and a verify service that rejects expired or used codes, counts each attempt and marks a correct code used.
Trade-offs: Enforcing single use in the database is slower than in memory but correct under retries.
Deliver codes through a queue and keep hot codes in memory.
What was missing: Delivery blocks requests and every verify reads the database.
Why that's risky: If delivery lags the user waits for a code that has already started expiring.
What gets added: A cache of live codes with a five-minute TTL, and a delivery queue with workers that send the SMS or email and retry on failure.
Trade-offs: Delivery is asynchronous, so the code arrives seconds later rather than inside the request.
Stop code guessing and watch delivery.
What was missing: Scripts can brute-force codes and drain the SMS budget.
Why that's risky: A six-digit code has only a million possibilities, so without attempt limits it can be guessed.
What gets added: A rate limiter on code requests and verification attempts per phone, account and IP, and monitoring of delivery delay and failed deliveries.
Trade-offs: Strict limits may block a real user who mistypes, so a lockout is temporary.
You're in the middle of an interview session. Leaving now will end your current attempt.
Explore concept overviews, real-system examples, key tradeoffs, and interview talking points for each roadmap section.
You've conquered this phase. These are the skills you now own: