Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →

Q48HardSystem design

Design a RAG system over real-time data, e.g. a news or market-intelligence assistant that must reflect events from the last few minutes.

30-second answerSay your answer out loud first, then reveal.
Real-time RAG: feeds flow through a stream queue, stream processors and GPU embedding workers into a hot real-time index that rolls over into a historical index; a query's time intent is parsed, both indexes are searched by relevance times recency, duplicate stories are clustered keeping the latest, and the LLM answers with timestamps and sources.

Key design points

  1. Freshness SLA: e.g. an event becomes searchable within 60 seconds. Monitor lag from publish time to indexed time per source.
  2. Dedup and story clustering: the same news appears from 50 outlets. Use near-duplicate detection (MinHash, or embedding similarity) and cluster stories so the answer isn't 10 copies of one fact.
  3. Recency-aware ranking: score = relevance × time decay; parse temporal intent ("latest", "yesterday", "in 2024").
  4. Hot / cold tiers: a small hot index with real-time inserts (fast HNSW updates) and a large historical index; query both and merge.
  5. Entity tagging: companies, tickers and people as metadata for precise filtering.
  6. Generation: include the current date and each source's timestamp in the prompt; distinguish confirmed facts from developing reports; avoid presenting stale information as current.
  7. Source reliability scores, to limit misinformation amplification.

Trade-offs: embedding cost at high ingest volume (use smaller embedders and batching); index write amplification; consistency between the hot and cold tiers.

Slow is fine. Stopping is the only problem.