Design a Coupon and Promo Code Service - System Design

“Design a coupon service” sounds like a CRUD table with a discount_percent column until you write down what actually breaks it. Marketing wants to print 10 million unique codes for a Diwali campaign, mail them out, and have each one usable exactly once. The rules are not simple: this code is 20% off, that one is flat 500 off orders over 2000, this batch is one-per-customer across the customer’s lifetime, that batch stacks with free shipping but not with other percentage coupons. And the whole thing has to answer POST /checkout in a few milliseconds during a flash sale when 200,000 people hit “apply code” in the same minute, because the coupon check sits directly on the critical path to revenue. ...

27 min

Design an API Gateway - System Design

Everyone draws the API gateway as a single box labelled “gateway” between the client and the microservices and moves on. Then the interviewer starts pulling threads: this one box is on the hot path of every request in the entire company, so what happens to latency when it does auth, rate limiting, routing, and circuit breaking on each of millions of requests per second? Where does the per-client rate-limit count live when you have 200 stateless gateway nodes behind a load balancer and the same customer’s requests are sprayed across all of them? What does the gateway do when one downstream service starts timing out - does it drag every caller down with it? Now it is a real problem. ...

30 min

Design an IoT Device Management Platform - System Design

A device management platform sounds like a CRUD app over a fleet table until you say the numbers out loud. One billion devices. Each one holds a live connection and pushes a telemetry reading every 30 seconds. Each one must be reachable, right now, to receive a command or a firmware update that you decide to send from the cloud. The interviewer lets “it’s just MQTT” sit for a beat and then asks the questions that break it: where does a billion live TCP connections terminate, how do you find the one server holding the socket for device d-8831xy when you need to push it a command, what happens to the 33 million telemetry messages per second, how do you roll firmware to 50 million devices without melting your own download tier or bricking the fleet, and what happens when a device that was online three seconds ago vanishes mid-update. ...

31 min

Leaving Your Job Before 60 - The NPS Exit Rules Nobody Explains Clearly

Here is the sentence that catches people off guard: if you close your NPS account before 60, you do not get to keep most of your money. The scheme was built around a single exit door at age 60, and the designers made the early exit deliberately painful. At 60 you take 60% as a tax-free lumpsum and annuitise 40%. Leave before 60 and those numbers invert - you keep 20% and 80% is conscripted into an annuity you cannot touch. ...

13 min

Design a Full-Text Search Engine (like Elasticsearch) - System Design

Everyone builds search the same way the first time: put the documents in a database, and run SELECT * FROM docs WHERE body LIKE '%term%'. It works on a thousand rows. Then the interviewer makes it the real problem: billions of documents, a query that matches a few keywords has to come back ranked by relevance in under 50ms, documents must be searchable within a second of being written, and the whole thing has to survive machines dying without losing data or going dark. ...

32 min

Design a Package Tracking System - System Design

You type a tracking number into an app and a timeline appears: “Picked up in Pune”, “Departed Mumbai hub”, “Arrived at Delhi facility”, “Out for delivery”, “Delivered”. Underneath that tidy list is a parcel that got scanned by a dozen different devices across a week - a pickup scanner in a van, a conveyor belt sorter, a handheld at a hub, a doorstep delivery app - each of them firing an event into the system from a different city, sometimes out of order, sometimes twice, sometimes hours late because the scanner was offline in a warehouse basement. The product looks like a list. The system is a distributed event pipeline feeding a state machine, and the interviewer will spend the whole hour on the gap between those two things. ...

27 min

Design a Video Transcoding Pipeline - System Design

Someone uploads a 4GB 4K master. Before anyone can watch it, that one file has to become roughly a dozen different versions - 360p, 480p, 720p, 1080p, 1440p, 4K, each in two or three codecs - and every version has to be cut into short segments and wrapped in a manifest so an adaptive player can stream it. That is tens of minutes to several hours of CPU work per upload. The naive mental model is “call ffmpeg on the file and wait.” That model dies the instant you have more than one user, because encoding a 2-hour movie serially takes as long as the movie, times the number of renditions, on one machine that might crash 90% of the way through and lose everything. ...

35 min

F&O Losses Can Offset Your Salary: The ITR-3 Move Most Salaried Traders Miss

Every broker blog tells the salaried trader the same thing: “Your F&O loss can be set off against your salary, so file it and cut your tax.” Half of that sentence is a gift the income tax department actually hands you. The other half is wrong, and filing on the wrong half is how you turn a legitimate Rs 62,400 saving into a defective-return notice. Here is the precise version. A loss from trading futures and options is a non-speculative business loss. That classification is worth real money. But Section 71(2A) specifically bars a business loss from being set off against income taxed under the head “Salaries.” What it can do - and what almost no salaried trader using ITR-1 or ITR-2 ever claims - is wipe out tax on every other rupee of income you earned that year, and then carry the leftover forward for eight years. For most salaried traders that is rent, FD and savings interest, dividends, and capital gains, all of it taxable at the same slab. The saving is identical in size to the one the broker blog promised. You just reach it through the right door, and that door is ITR-3. ...

12 min

Speculative Decoding Is the Inference Trick That Cuts LLM Latency Without Changing the Model

Most self-hosted LLM teams respond to slow generation the same way: buy a bigger GPU. Latency is high, tokens per second is low, so the fix must be more VRAM and more FLOPs. I have watched teams move from an A100 to an H100 to an H200, double their monthly bill, and get a 15 percent improvement in wall-clock latency for a chat endpoint. The uncomfortable truth is that token generation on a transformer is not compute-bound. It is memory-bound. You are not waiting on the GPU to multiply matrices. You are waiting on the GPU to read the model weights out of HBM, over and over, once per token. Speculative decoding attacks exactly that bottleneck, and it does it without touching your model weights, your fine-tune, or your output distribution. Done right it cuts first-token-adjacent latency and end-to-end generation time by 40 to 60 percent on the workloads where it fits. ...

12 min

Design a Distributed Counter at Scale - System Design

“Design a distributed counter” sounds like homework until you write down what it actually is: a single number that millions of people want to add to at the same time. A TikTok video goes viral and its view count has to climb past a billion. An e-commerce flash drop decrements the same SKU’s stock from 10,000 to 0 while 2 million people hammer “buy.” A tweet’s like count, an ad’s impression count, a rate limiter’s request count - all the same shape. One logical integer, astronomically many writes converging on it, and a read path that wants the current value cheaply and often. The interviewer is not testing whether you can run count = count + 1. They are testing whether you understand that a single mutable number is the single worst thing to put under a write stampede, and whether you can pick the right consistency model for the specific counter in front of you. ...

28 min

Design a Feature Flag Service - System Design

A feature flag service sounds like a key-value store with a boolean in it. “Is new-checkout on? Return true or false.” That framing survives exactly until you ask the three questions that actually define the system. First: who is the flag on for - because “on” is rarely global; it is “on for 1% of users, ramping to 100%”, or “on for internal staff and users in Canada”, or “on for everyone except this one enterprise account that is paying us to be careful.” Second: how fast does a change take effect - because the entire reason flags exist is to turn a bad feature off now, and “now” means the kill switch has to reach every running instance of your app in well under a second, not on the next poll, not after a cache expires. Third: how much load does that put on your servers - because if you have 10 million SDK instances embedded in your customers’ backends and mobile apps, and each one asks a central server “what is the current flag config?” every time it evaluates a flag, you have built a self-inflicted DDoS. The real problem is this: evaluate flags locally inside millions of SDK instances with zero network latency on the evaluation path, support rich targeting and percentage-based gradual rollout that stays sticky per user, and propagate any flag change to every one of those millions of instances in under 100ms - without the central flag server collapsing under the fan-out. ...

38 min

Design TikTok / Instagram Reels (Short-Video Feed) - System Design

People see the swipe and think the hard part is video. It is not. Serving a 15-second clip is a CDN problem that YouTube solved a decade ago. The hard part of Reels is that every single swipe is a fresh ranking decision, the feed has no end, nobody chose what comes next, and the system has roughly 400 milliseconds to pick the next video out of billions while you are still watching the current one. That is the whole game. ...

30 min

PPF After 15 Years: Extend With Contributions, Extend Without, or Close - Which Beats a Debt Fund

The standard advice when your PPF matures is “extend it with contributions, you keep the 80C deduction and the tax-free interest.” For a large number of people that advice is quietly wrong, because the 80C half of it is worth exactly nothing to them. If your EPF already fills the ₹1.5 lakh 80C limit on its own, every rupee of the “80C benefit” you are being sold on the extend-with-contributions path has already been claimed. You are paying attention to a benefit you cannot collect. ...

12 min

Pydantic AI Makes LLM Output Validation a First-Class Engineering Problem

If you still have a re.search(r'\{.*\}', response) somewhere in your codebase to pull JSON out of an LLM reply, that line is a liability. Everyone knows this by now. The interesting question in 2026 is not “regex versus a parser.” It is “once the raw provider APIs give you JSON mode and schema enforcement, who owns validation, retries, and the fact that you want the same code to run against Claude, GPT-4o, and Gemini?” ...

9 min

Design Discord (Voice Chat with Low Latency) - System Design

People hear “build Discord voice” and reach for the same WebRTC tutorial they would use for a video call: two peers, an SDP exchange, media flows, done. Discord voice is a different animal from Zoom, and the differences are what make the design interesting. There is no “meeting” you schedule and join. There is a persistent voice channel sitting inside a server, always there, and users drop in and out of it the way you walk into a room. The latency budget is tighter - voice-only, interactive, gaming-adjacent, so the target is sub-100ms mouth-to-ear, not Zoom’s 200ms. And the pathological case is not a 1000-person webinar with one speaker; it is a hot channel with 10,000+ people who can all unmute and talk, a community stage or a raid, where the fan-out is genuinely many-to-many. ...

29 min

Design Insurance Claims Processing - System Design

“Design insurance claims” sounds like a form with a Submit button. A customer uploads a photo of their dented car, someone looks at it, money gets paid. The interviewer lets that stand until they ask the question that breaks it: this is not a request-response system, it is a long-running, human-in-the-loop workflow that must be fully auditable years later. A single claim lives for days or weeks. It is touched by a customer, an ML model, a fraud engine, one or more human adjusters, maybe a surveyor and a hospital, and finally a payment system. Any of them can send it backward - ask for more documents, flag fraud, dispute the estimate. And every single one of those touches is a regulated record: when a claim is denied, the regulator (and possibly a court) can demand the exact inputs, model version, and human decision that produced that outcome, reproducible on demand. ...

33 min

Design Loan Disbursal Platform (FinTech) - System Design

A loan disbursal platform looks like a form plus a yes/no, and interviewers love it because it is not. The “form” fans out to a half-dozen external systems you do not control - credit bureaus, KYC/identity providers, bank account verification, a fraud graph, an ML risk model - some of which are slow, some flaky, some rate-limited, all of which cost money per call. The “yes/no” is a regulated underwriting decision that must be explainable, reproducible years later, and never made twice on the same application. And the payoff at the end is disbursal: real money leaving your account to a customer’s bank, over a rail you cannot roll back. A duplicate disbursal is money gone. ...

33 min

Design Aadhaar / National Identity Database - System Design

“Store identity for everyone and let them prove who they are” sounds like a users table with a photo column. Then you look at the numbers and the physics of biometrics, and it stops being CRUD. You are holding fingerprints, irises, and demographics for 1.4 billion people. Every single new enrollment has to be checked against the entire existing population to guarantee that this human does not already hold an identity under another name - a 1:N biometric match against 1.4 billion records, not a key lookup. And once enrolled, a person must be able to prove their identity at a ration shop, a bank, or a SIM counter in under two seconds, 50 million times a day, while a regulator watches every byte of how you store and move the most sensitive data a state can hold about a person. ...

34 min

Design Twitch (Live Streaming Platform) - System Design

Twitch is not a video problem with a chat bolted on. It is a real-time interaction problem that happens to carry video. That is the thing that trips people in the interview: they reach for the YouTube answer (transcode once, serve immutable bytes from the edge forever) or the live-sports answer (one pro feed, fan it to millions through a CDN) and both are wrong in the way that matters. Twitch has two features neither of those has. First, the content comes from millions of amateur streamers at once, each a separate live ingest with its own transcode, most of them watched by twelve people and a handful watched by a million - a brutal long tail with no pre-encode and no warning about which stream goes viral. Second, the whole point is the loop: a viewer types in chat, the streamer reads it on screen two seconds later and reacts, and the viewer sees that reaction. If the video is 30 seconds behind, that loop is dead and you have built YouTube. So the latency target is not “feels live,” it is sub-5-second glass-to-glass, tight enough that chat and video stay in sync. ...

25 min

Design WhatsApp Status (24-hour Stories) - System Design

WhatsApp Status looks like Instagram Stories with a different logo, and if you design it like Stories you will get most of it right and miss the one thing that makes it hard. Stories is a public-ish follow graph where the server can read everything. Status is end-to-end encrypted over a bidirectional phone-contacts graph with per-contact privacy rules, and the server is never allowed to see the pixels. Those two facts - the server cannot read the media, and “who can see this” is a function of two address books agreeing - reshape the entire fan-out, and that is where the interview lives. ...

30 min