All questions
Hard2026-09-20

Design a Chat Application like ChatGPT

Company
Uber
Role

SDE-2 (Backend)

Round

Onsite (HLD)

System DesignStreamingDatabase DesignLLM

Problem Statement

Design a chat application similar to ChatGPT. Users should be able to start new conversations, continue previous conversations, and receive streamed AI responses.

Requirements

Functional:

  • Start a new chat conversation
  • Continue a previous conversation (with full context)
  • Stream AI responses token-by-token as they're generated
  • List and retrieve past conversations
  • Handle very long conversations (context window limits)

Non-Functional:

  • Low latency to first token
  • Scale to millions of concurrent users
  • Reliable message persistence
  • Handle long-running LLM inference requests

What the Interviewer Expects

  1. Core entities & data model:
    • User, Conversation, Message (role: user/assistant, content, timestamp)
    • Conversations store an ordered list of messages
  2. Streaming responses — Server-Sent Events (SSE) or WebSockets to stream tokens as the LLM generates them. Discuss why SSE fits one-directional streaming well.
  3. Context management — sending prior messages to the LLM for continuity. Handling context window limits (truncation, summarization of old messages).
  4. Architecture — client → API gateway → chat service → LLM inference service (queued, possibly GPU-backed) → stream back.
  5. Persistence — store messages in a DB (Postgres/Cassandra). Cache active conversations in Redis.
  6. Scaling LLM inference — request queue, batching, autoscaling GPU workers, handling long inference times without blocking.

Follow-ups

  1. How do you handle a user who refreshes mid-stream? (resumable streams, storing partial responses)
  2. How do you manage the context window when a conversation exceeds the LLM's token limit?
  3. How do you rate-limit expensive LLM calls per user/tier?
  4. How would you support conversation branching (edit a message and regenerate)?
  5. How do you ensure message ordering and consistency in a distributed setup?
🧠

No solution provided

Think through it. That's how you build real interview muscle.

Share: