Book a 30-min callBook a call

System design: an AI chat assistant for a website

A system design for a website AI assistant: ingestion on publish, hybrid retrieval, SSE streaming, caching layers, guardrails, evaluation and failure modes.

Two rows of boxes: a publish row from a page through chunk blocks to an index cylinder, and a question row through a gate, a search box and a model box to a chat bubble with link chips.
Written by
BYD Tech
Published
Topic
Deep dives
Reading time
14 min read

Questions people ask

Should a website assistant stream over SSE or WebSockets?

Server-sent events, in most cases. The answer flows one way, SSE is plain HTTP that proxies and CDNs understand, and the format has reconnection built in. Choose WebSockets when the server must also push unprompted or the client streams continuously, as in voice.

Do you need a vector database for a small website?

Often not a separate one. A few thousand pages fit comfortably in Postgres with a vector extension, or in a search engine that supports vectors, next to keyword search. A dedicated vector store makes sense when the corpus, the query rate or the filtering needs outgrow that.

How do you keep the assistant from answering off-topic questions?

Enforce scope in three places. A relevance threshold on retrieval refuses questions that match no page, without calling the model. The system instructions say to answer only from the passages given. An output check rejects answers that cite no passage.

What should the assistant do when the model provider is down?

Fail usefully. Retrieval does not need the model, so after a timeout, send a short apology with the best-matching pages as links. Cached answers keep working, and a second provider with its own tested prompt is an option if uptime matters enough.

Building something like this?