Skip to main content

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

Answer it out loud in the mock interview about 2.5 min

Follow-ups to expect

Common mistakes

Learn it

Guardrails

Practice System design questions

More on this topic

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.