← Questions

Design an embeddable streaming chat interface

0
GoogleSystem designLast asked Apr 2026

An AI system design interview question asked in Google's system design round, last asked Apr 2026. It tests frontend, streaming and chat.

For a frontend role: design a chat widget for an AI agent that other products can embed in their pages. The agent's replies stream in as they are generated. Cover how the widget plugs into a host page, how streaming works, how a long conversation stays fast, how chat history is cached, and which product and reliability metrics you track.

Requirements

  • Functional: a host page adds the widget with a few lines and passes the user's identity; the user sends messages and sees the reply stream in token by token; they can stop a reply, retry a failed one, and scroll back through long histories; the conversation survives a page reload.
  • Non-functional: the widget must not break or be broken by the host page's styles and scripts; first paint fast on slow devices; smooth scrolling with thousands of messages; streams that recover from dropped connections; accessible by keyboard and screen readers.

Clarifying questions

  • Is the widget an iframe, a web component, or a library rendered into the host's DOM?
  • How does the host authenticate the user to our backend?
  • Must conversations sync across devices and tabs?
  • What ordering and resume guarantees does the streaming backend give?
  • Can the agent call tools that need the user's approval?

What a strong answer covers

  • The embedding boundary and its trade-offs: an iframe gives full isolation of styles and scripts but costs sizing and messaging work (postMessage); a web component with shadow DOM gives style isolation with tighter integration. A small public API (init, open, events) and a theme config.
  • Authentication: a short-lived token from the host's backend, never a long-lived secret in the page.
  • Message states made explicit: pending, streaming, complete, failed, retried, cancelled. Optimistic display of the user's message.
  • Streaming over server-sent events (or fetch streaming, gRPC-web, WebSocket) with message and chunk sequence numbers, resume from the last received chunk after a reconnect, and cancellation that tells the server to stop.
  • Long histories: list virtualisation, pagination backwards, and stable scroll position while new tokens arrive.
  • Caching: recent conversation in IndexedDB keyed by user and conversation, reconciled with the server on load.
  • Metrics: time to first token, stream completion and error rates, retries, cancellations, messages per session, and how often users edit or regenerate a reply.

Follow-ups

  • The agent asks to run a tool and the user must approve. How do you show this without the action running twice?
  • The user navigates away mid-stream. How do you avoid losing the partial reply?
  • The host page has a strict Content Security Policy.
  • How would you load the widget so it never slows down the host page?

Where it's asked

  • Google · System design · Last asked Apr 202645 min · Whiteboard for the diagram, a doc for requirements and capacity math

What it tests

frontend · streaming · chat

Your canvas
Draw your answer hereBoxes, arrows and notes, saved for you to come back to.Sign in to start drawing