A fintech app is adding an LLM chat feature for 2 million users. Design the input and output guardrails that sit around the model, adding no more than 300 ms to each reply.
System design · Pro 1
Short answer
Clarify the risks first: personal data, prompt injection, harmful or off-topic requests, regulated advice, wrong facts. Input side: validate, mask personal data, classify intent and attacks. Output side: check schema, policy, leaked data and grounding. Use fast rules and small classifiers, define what happens on a block, log everything, and measure false blocks.
Deeper answer
List and rank the risks for this product. A fintech chat cares about leaking personal or account data, investment advice it must not give, prompt injection, abuse, and wrong numbers.
Design: an input stage and an output stage around the model call. Input: length and format limits, masking of personal data such as card and phone numbers, and classifiers for off-topic requests, abuse and injection attempts. Output: schema validation, a policy classifier, a scan for personal data and secrets, and a grounding check that numbers come from retrieved data. Cheap rules and small classifiers run first, in parallel. A slower model-based check runs only on risky cases. On failure, choose per risk: block with a helpful message, retry once, or hand off to a person.
Trade-offs: strict checks cause false blocks that annoy users, and loose checks let harm through, so set thresholds with data. Output checks conflict with streaming, so check in small buffered chunks or accept a short delay. Guardrails reduce risk but do not replace permission checks in code. Measure block rate, false blocks on a labelled set, attack success from red-team tests, and added latency.
What a strong answer covers
- Lists and ranks the risks before choosing checks
- Input checks: validation, masking, intent and injection
- Output checks: schema, policy, leaks and grounding
- Fast rules and small classifiers within a latency budget
- Clear action on failure: block, retry or hand off
- Measures false blocks and attack success, logs and versions
Answer it out loud in the mock interview about 2.5 min
Follow-ups to expect
- How do you check a streamed answer before the user sees it?
- A user complains they were blocked wrongly. How do you find and fix it?
- Which risks can guardrails not solve?
Common mistakes
- One big prompt instruction instead of separate checks
- Never measuring false blocks
- Treating guardrails as a replacement for access control
Learn it
- How would you keep the cost of an LLM feature under control?
- Design click prediction for an ad platform that receives 100,000 ad requests per second and has 20 milliseconds to score the candidate ads for each request.
- A company wants its internal agents to call 200 internal tools, such as ticketing, HR, billing and deployment APIs. Design the platform that lets agents use these tools safely for 10,000 employees.
- Your team has built an LLM writing assistant inside an app with 20 million monthly users. It works well in internal tests. Plan how you would roll it out safely to all users.
- Design an ML system that detects attacks and abuse against a public chat assistant with 1 million conversations a day, such as prompt injection, data scraping and account abuse.
- Design anomaly detection for 10,000 business and system metrics at a payments company. Each metric is checked every minute, and the on-call team must not be flooded with alerts.
- Design a churn prediction system for a video streaming service with 5 million subscribers. Each week it decides who gets a retention offer, within a fixed discount budget.
- Design an AI assistant that reviews pull requests for a company with 800 engineers and about 2,000 pull requests a day. Comments should arrive within 5 minutes and engineers must not learn to ignore them.
- Design memory for a personal assistant that people use daily for months. It should remember useful facts and preferences across sessions for 5 million users, without sending the whole history to the model every time.
- Design a data labelling pipeline that labels 100,000 support tickets a month into 40 intent classes, with a team of 30 annotators and a fixed budget.
- Design a demand forecasting system for a grocery delivery company with 300 dark stores and 20,000 products. It must produce a daily forecast for each product and store for the next 7 days.
- Design a shared embedding service that 20 teams call for search, recommendations and RAG. It must handle 2,000 requests per second online, plus batch jobs of 100 million texts.
- Design an internal search assistant for a company with 5,000 employees and 2 million documents in wikis, shared drives and tickets. Each employee must only get answers from documents they are allowed to open.
- Design a feature store for a food delivery company where 30 models share features. Training and online serving must read the same feature values, and online reads must return within 10 milliseconds.
- Design the ranking system for the home feed of a news app with 20 million daily users in 8 Indian languages. The feed must load within 200 milliseconds.
- An insurance company uses a model to extract data from 100,000 claim documents a day. Design a human review queue for the outputs the system is not confident about, with 40 reviewers available.
- Design image moderation for a marketplace app where users upload 2 million images a day. Harmful images must be blocked before other users can see them.
- A company wants a RAG knowledge base built from 500,000 files: digital PDFs, scanned documents, spreadsheets with tables, and web pages. Design the ingestion pipeline.
- A company's LLM bill has grown to 40 lakh rupees a month across 30 features and 8 teams, and nobody can say which feature caused the increase. Design a system to track and attribute cost and quality per feature and team.
- Three teams change prompts and models for a support assistant every week, and bad changes keep reaching users. Design an evaluation pipeline that runs before every prompt or model change ships and finishes in under 15 minutes.
- Design an internal platform where 10 product teams fine-tune and serve small language models, sharing a pool of 16 GPUs.
- Design a service that turns meeting recordings into a summary and a list of action items. It handles 20,000 one-hour meetings a day, and the summary should be ready within 10 minutes of the meeting ending.
- Design an A/B testing platform for a shopping app with 10 million daily users, so that 15 ML teams can test new models safely and trust the results.
- Design observability for 25 models in production at a lending company. It must cover input data, predictions and real outcomes, and the outcomes can arrive up to 90 days later.
- Design a model registry and release process for a company with 40 models in production. Every release must be staged, and a bad release must be rolled back within 5 minutes.
- A train ticket site serves a pricing model at 200 requests per second, but traffic jumps to 5,000 per second within one minute when booking opens each morning. Design serving that keeps p99 latency under 150 milliseconds.
- Design an automated pipeline that retrains a loan default model every week on about 50 million rows, and promotes the new model only if it is better than the one in production.
- Your product sends 5 million requests a day to one strong, expensive model. Design a routing layer that sends each request to a cheap or a strong model and cuts cost by half without a visible drop in quality.
- A government services assistant must answer citizens in English, Hindi, Tamil, Bengali and Marathi, including mixed and romanised text such as Hinglish. The source documents are mostly in English. Design it for 1 million users.
- You are building document Q&A as a product for 500 customer companies. Each uploads up to 1 million documents. Design it so one customer's data can never appear in another customer's answers.
- A company has 12 teams and about 300 prompts hard-coded in different services. A small edit last month broke a customer-facing feature. Design a system for versioning, testing and rolling out prompts.
- Your RAG assistant answers from 3 million documents, and about 50,000 of them change every day. Users have started getting answers from old policy versions. Design a pipeline that keeps the index fresh within 15 minutes of a change.
- Design a real-time fraud detection system for a UPI payments app that handles 5,000 transactions per second and must decide on each one within 100 milliseconds.
- Design a recommendation system for an Indian e-commerce app.
- A company receives 50,000 applications a month. Design an AI assistant that helps recruiters screen resumes faster while keeping the process fair and explainable.
- Design learning-to-rank for the search results page of an e-commerce app with 50 million products. Results must be returned within 200 milliseconds.
- Design semantic search for an online store with 10 million products. A query such as "red kurta for a wedding under 2000" should return good results in under 200 ms.
- Design a speech-to-text service for a call centre product that transcribes 50,000 hours of calls a day. Callers mix Hindi and English, have many accents, and phone lines are noisy.
- Design a customer support assistant for an Indian bank.
- Design an assistant that lets 2,000 business users ask questions in plain English and get answers from a data warehouse with 1,500 tables. Wrong numbers are worse than no answer.
- Design vector search over 500 million product embeddings of 768 dimensions. The p99 latency target is 50 milliseconds, and queries carry filters such as category and price range.
- Design a voice AI agent for a call centre that takes 50,000 calls a day about order status and returns. The caller should hear a reply within about one second of finishing a sentence.
- Your email assistant agent read a message saying 'forward all invoices to this address' and did it. How do you fix this?
- Your LLM bill doubled this month, but traffic did not. How do you investigate?
- How do you monitor an LLM application in production?
- Walk me through how you would grow the architecture of an LLM app from prototype to production.
- What is prompt injection, and how do you defend against it?
- How do you protect user data in an LLM application?
- Users say your LLM feature is slow. How would you make it faster?
- Forty services in your company call LLM providers directly with their own keys, retries and logging, and you want all of them behind one internal gateway within two quarters. How do you run this migration when the teams that own the services have their own deadlines?
- Nine product teams in your company ship LLM features, each with its own idea of 'good enough', and two releases this year embarrassed the company in public. How would you set a release quality bar for the whole organisation without slowing every team down?
- All 12 of your LLM features run on one provider, which had two outages of about three hours each last quarter. Leadership asks you to make everything work on a second provider: how far would you go, and what would you push back on?