You already know: embeddings and approximate nearest-neighbour (ANN) search, the enterprise RAG case, and the guardrail gateway. This case designs the vector database itself at a billion vectors with continuous writes. ANN indexes (graph-based ones are the common choice) find close vectors quickly by searching only a small part of the data, trading a little recall (the share of true nearest neighbours found) for speed. The design questions: how to fit a billion vectors in memory, how to make writes visible within seconds when indexes are slow to build, how to filter without losing recall, how to keep fan-out from ruining tail latency, and how to guarantee deletes.
How to read this lesson. No code, on purpose. Numbers marked assumed are assumptions you state out loud.
1. The prompt, and the questions that change the design
A mid-level answer: "use an HNSW index, shard it, and put a cache in front". A staff candidate notes that graph indexes are expensive to build and awkward to update, so real-time writes need a log-structured design (a fresh, small, brute-force-searchable segment plus sealed, indexed segments). They notice that filters are where recall quietly collapses, that fan-out across shards turns rare slow shards into common slow queries, and that deletes are a guarantee, not a best effort.
Assumptions you state: