Free preview

High-Level Design

Why this matters: the high-level flow is short enough to state in five steps, which makes it a good place to notice what is not in it.

The high-level design illustrates how the system handles real-time conversations.

StepWhat happens
1. User inputThe user submits a text prompt via the interface or API
2. Gateway processingThe API gateway authenticates the request, applies rate limiting, manages the session, and forwards the prompt to the model server
3. Model inferenceThe AI model processes the prompt using conversation history. Responses are cached for retrieval and logged in the database
4. Response deliveryThe generated response is returned to the user via the API gateway
5. Feedback loopUser feedback is collected to improve system performance and fine-tune future models

Where the model gets its context

Step 3 says the model "processes the prompt using conversation history." That phrase is doing an enormous amount of work.

Key takeaway

Five steps: prompt, gateway, inference, delivery, feedback. The gateway's rate limiting is cost control, and it should measure tokens rather than requests — the same unit as billing and capacity planning. Step 5 belongs to a different system running weeks behind the other four, which is why it is asynchronous. And the diagram elides the load balancer, moderation, retrieval, and — most importantly — streaming, since a 1,250-token response is not an atomic payload. The real step 3 is assembling the prompt from system instructions, profile, recent turns, and retrieved context, every token of which costs prefill time.

Next: why an ordinary cache fails here, and what replaces it.

Enjoying the preview?

Create a free account to unlock the rest of this course, the in-browser judge, and live AI mock interviews.

Sign up free to continue