09 / 16

AI Architecture

Reference architectures and the cross-cutting decisions that make AI systems hold up in production.

0/9 studied
01Reference architecture of an LLM application

A production LLM app is layers around the model: client → API & auth → orchestration → context (retrieval, memory, tools) → model gateway → models, wrapped in guardrails, evals, observability and cost control.

Core◇ Diagram</> Code
02Quality, latency, cost: the AI trade-off triangle

Every AI design choice trades quality, latency and cost, plus risk. Set a bar for each, know which lever moves which corner, and pick from the measured Pareto frontier instead of arguing.

Core◇ Diagram</> Code
03Resilience: multi-provider failover & degradation

LLM providers fail loudly (outages, 429/529) and quietly (latency spikes, quality regressions). Time out fast, retry with backoff, trip circuit breakers, fail over to an evaluated backup, then degrade gracefully.

Advanced◇ Diagram</> Code
04Identity & authorization for agents

An agent acts for a user: give it short-lived, narrowly scoped, delegated tokens capped by the user's rights; authorize every tool call in code, confirm risky ones, and audit each action to the human.

Staff+◇ Diagram</> Code
05Caching layers in an AI system

One AI request can pass eight caches, from the CDN down to the GPU's KV cache. Each saves different latency or dollars; key every one by tenant, permissions and model, prompt and index version.

Advanced◇ Diagram</> Code
06Model upgrades & deprecations

Hosted models retire on published schedules, so every model you ship is a future migration: pin versions, hide providers behind one interface, and move only through an eval-gated path of shadow, canary and rollback.

Advanced◇ Diagram</> Code
07The data flywheel

Turn usage into improvement: log traces and feedback, select and label the informative cases, use them for evals first and training second, ship, and let more usage feed the next turn.

Advanced◇ Diagram</> Code
08Vector search at billion scale

At a billion vectors, memory is the design constraint: compress the vectors, move the index to SSD or object storage, shard and replicate, and rescore a small candidate set at full precision.

Staff+◇ Diagram</> Code
09On-device & edge inference

Run the model on the device instead of the cloud: you win latency, privacy, offline use and near-zero cost per query, and pay with small models, tight memory and a fleet to update.

Advanced◇ Diagram</> Code