KatInterview

Design a Collaborative LLM Prompt Workbench with Live Streaming

System DesignModel answer
HardModel answerSystem Designsystem-designstreamingmulti-tenancy

Last updated

Design a multi-tenant web tool where teams author prompts, run them on external LLMs with streamed output, version and compare results, and track cost, latency, and safety.

You are asked to design an LLM prompt workbench: a web product where developers and prompt engineers compose prompts, pick model parameters, execute them against hosted language models, and watch the output arrive token by token. Teams save prompt revisions, put outputs side by side, share work with colleagues, and examine the cost, latency, and safety outcome of each execution.

This is an open-ended design discussion. Work through it as you would in a real session: clarify requirements, estimate scale, draw a high-level architecture, then dive into the hardest areas. Write down every assumption you make.

Scale assumptions

Use these figures unless you explicitly state others:

  • 100,000 monthly active users
  • 1 million prompt executions per day
  • A portion of executions stream tokens to the browser live
  • Users are grouped into workspaces or organizations (multi-tenant)
  • Prompts and outputs may contain sensitive data

Third-party model providers are a network dependency. Every call costs money per token, latency varies, requests may be throttled or fail temporarily, and the provider may decline to answer.

What to cover

  1. Requirements and user flows. Functional and non-functional requirements tied to this product, an explicit out-of-scope list, and the end-to-end journey: write, run, stream, save a version, compare, review history.
  2. APIs and data model. Core entities and an API surface. Make runs reproducible and decide where large or sensitive bodies are stored.
  3. High-level architecture. Components and the request path, with one clear structural decision at the center.
  4. Execution, streaming, retries, cancellation. The run lifecycle, how tokens reach the browser, which failures you retry, how you avoid double charges, and how a cancel actually stops spend.
  5. Versioning, collaboration, history. How edits become versions, how comments and sharing work, and how history is stored and queried at 1M runs/day.
  6. Security, privacy, abuse. Tenant isolation, encryption, secrets, rate limits versus spend quotas, retention and deletion, abuse detection.
  7. Observability, cost, tradeoffs. What you measure, how authoritative cost is computed and stored, and the main tradeoffs you are choosing.

Good clarifying questions to raise: read/write mix, average output length and streaming share, internal vs external models and fallbacks, time-to-first-token target, what happens to a run if the browser disconnects, strictness of isolation and retention, and whether live co-editing is in scope.

Hints

Hint 1

Convert the numbers first: 1M runs/day is about 12 runs/s on average, maybe 50 to 100/s at peak. With runs lasting 10 to 30 seconds, that implies thousands of concurrent streams. Use these figures to size the streaming tier and the provider rate budget.

Hint 2

Split the system into an authoring/collaboration plane (CRUD, versions, comments, history) and an execution plane (queue, workers, model gateway, streaming). Make the execution side survive a closed browser tab by writing tokens to a stream buffer that clients can reattach to.

Hint 3

For cost, think about three things together: an idempotency key on run creation, cancellation that aborts the upstream provider request, and token cost computed at run time with the price snapshot stored on the run record rather than recomputed from current prices later.