AI Application Integration · 3 to 4 hours
Design a resilient streaming chat
Design a streaming interview-practice chat that keeps one answer correct across reconnects, several open tabs, and cancellation races, checks citations against current access, and never repeats its booking tool during recovery.
4 h
Used in interview rounds:
AI System Design (Hard)Overview
Design a chat experience that keeps one answer correct across disconnects, reconnects, several tabs, cancellation, and changing source access. The goal is an explicit contract connecting durable server state, client rendering, replay, citations, accessibility, and authorized side effects, backed by fault-injection tests.
Study time: 3 to 4 hours
Interview format: System design discussion with a fault-injection plan
By the end you can
- Separate runs from connections, and give conversations, messages, attempts, runs, and tool operations their own durable identities
- Make submission idempotent and bind each run to the conversation revision it accepted
- Replay persisted events after a client cursor, and hand off from a snapshot to live events without a gap or a duplicate
- Resolve cancellation races with one authoritative terminal state while keeping completed tool effects recorded
- Keep citations, authorization, and accessible fallbacks correct across reconnects and access changes
- Plan fault-injection tests that check each recovery invariant beyond reducer unit tests
Prerequisites
Helpful background: Familiarity with HTTP streaming, client state reducers, database transactions, and access control helps.
This topic covers client and server streaming state, cancellation, reconnects, citations, and accessible UI. Model Serving & Inference covers runtime scheduling, memory, and hardware.
In this guide
- Separate execution from connection
- Idempotent submission
- Event persistence and replay
- Snapshot plus replay consistency
- Worked replay timeline
- Cancellation and competing terminal states
- Multi-tab and concurrent conversation edits
- Citation lifecycle
- Accessible recovery and fallback
- Security, privacy, and local persistence
- Performance and observability
- Scenario: an interview-practice chat
- Fault-injection plan
Hard questions are part of Premium: the study guide, reference answer, rubric, and exercises unlock with Premium.
Related on CodeSnatch
Lessons, problems, and articles that build the skills this question uses.
System Design
Revision numbers, an operation log with periodic snapshots, and offline replay in a multi-client editor.
System Design
Snapshots plus replay of later events, and optimistic concurrency on an expected version, for a run log.
Community article
A practitioner's account of how idempotency keys go wrong in payment APIs, and the habits that prevent it.
System Design
Client message IDs, at-least-once delivery with dedupe, and catch-up after reconnects in a chat design.
AI Engineering
Covers access checks at time of use, revocation during in-flight work, and private data kept in caches and memory.
Practice the interview question
Answer it in your own words before you look at the reference answer.
