Skip to content
AI Full-Stack Wiki

Diagram library

AI engineering, drawn as systems

Every diagram in this wiki uses one visual language: the same shapes, colors, and line styles mean the same thing everywhere. Hover or tap any component for an explanation, highlight a flow, or open a diagram fullscreen to zoom in. Each one also has a full text description.

How to read the diagrams

Shapes

  • Rounded rectangle: Service or code you run
  • Cylinder: Database or storage
  • Hexagon: LLM or other model
  • Circle: User or actor
  • Page: File or document

Colors

  • AI / LLM
  • Backend
  • Frontend
  • Data / storage
  • Security / risk
  • External

Lines

  • Request or data
  • Async job or event
  • Streaming response
  • Trust boundary

The learning roadmap

Nine stages take you from web foundations to a job-ready portfolio. Each stage depends on the ones before it, which is why the wiki is ordered this way.

The AI full-stack engineer roadmap: 9 stages from foundations to career, about 26 weeks on the 6-month path. Select a stage to open it; stages light up as you complete their articles.
Show text description

The roadmap is an ordered path of 9 stages. Each stage builds on the ones before it. Durations follow the 6-month standard plan; the 3-month plan compresses them and the 12-month plan expands the foundations.

  1. Start Here (2 weeks, beginner): Understand the role and pick a study plan.
  2. Foundations (4 weeks, beginner): TypeScript, Node.js, React, databases, APIs, and DevOps.
  3. LLM Fundamentals (2 weeks, beginner): Tokens, context windows, choosing models, keys and billing.
  4. LLM App Engineering (5 weeks, intermediate): Streaming, structured outputs, tool use, RAG, and caching.
  5. Agents & Orchestration (5 weeks, advanced): Agent loops, multi-agent systems, MCP, durable execution.
  6. Production AI (2 weeks, advanced): Evals, tracing, reliability, security, and cost.
  7. AI-Assisted Development (1 week, intermediate): Build, review, test, and debug with coding agents.
  8. Projects (3 weeks, advanced): Six builds, ending with a production SaaS assistant.
  9. Career (2 weeks, intermediate): Portfolio, writing, and AI system design interviews.

Architecture of an AI application

A production AI feature is mostly ordinary full-stack engineering. The model is one component behind your API, surrounded by auth, storage, background jobs, and observability. Use the flow buttons to trace a chat request, document indexing, or telemetry.

Full-stack architecture of an AI applicationA React UI talks to a Node.js API layer that handles auth, caching, Postgres with pgvector, a job queue with workers, observability, and calls to third-party model APIs whose tokens stream back to the browser.usesHTTPS requestSSE streamverify sessioncacheenqueue jobjobstracesTHIRD-PARTY APISUserReact UINext.js clientAPI layerRoute handlers / ExpressAuthSessions, permissionsRedisCache, rate limitsPostgrespgvector embeddingsJob queueBackground workWorkersIndexing, long tasksObservabilityTraces, cost, evalsModel APIsLLM + embeddings

Hover or tap a component to see what it does.

Full-stack architecture of an AI application: a React frontend, a Node.js API layer that owns every model call, Postgres with pgvector for data and embeddings, Redis, a job queue with workers, observability, and third-party model APIs.
Show text description

The diagram shows a production AI web application as boxes inside two trust zones: your own infrastructure, and third-party model APIs. Solid arrows are requests, dashed arrows are asynchronous jobs and telemetry, and arrows with moving dots are streamed responses.

  • User: The person using your product in a browser or mobile app.
  • React UI: Renders the chat or feature UI, sends requests to your API, and renders streamed tokens as they arrive. Never holds model API keys.
  • API layer: The only place that talks to model providers. Validates input, checks auth and rate limits, assembles context, calls the model, and streams the answer back over Server-Sent Events.
  • Auth: Identifies the user and decides what data and tools they may access. Every model call and tool call inherits these permissions.
  • Redis: Fast key-value store for per-user rate limits, response caching, and short-lived session state.
  • Postgres: The system of record: users, conversations, and documents. The pgvector extension stores embeddings so the same database answers similarity searches for RAG.
  • Job queue: Holds slow work (document indexing, long agent runs, batch jobs) so API requests return quickly. Jobs survive restarts and can be retried.
  • Workers: Node.js processes that pull jobs from the queue: chunk documents, request embeddings, write vectors to Postgres, and run long tasks with retries.
  • Observability: Collects a trace for every request and job, with prompts, token counts, latency, and cost, so you can debug bad answers and run evals on real traffic.
  • Model APIs: Hosted models reached over HTTPS: an LLM for generation and tool use, and an embedding model for vector search. Stateless: every request must carry its full context.

Chat request. The UI posts the message to your API, which verifies the session, checks the rate limit in Redis, retrieves context from Postgres, calls the model, and streams tokens back to the browser over SSE.

Document indexing. An upload is acknowledged immediately and queued. A worker chunks the document, requests embeddings from the model API, and writes the vectors to pgvector.

Observability. The API and workers emit a trace for every request and job, with token counts, latency, and cost. Traces feed dashboards, alerts, and evals on real traffic.

The tool-use loop

Tool use (also called function calling) lets a model request actions, but your code always executes them. Step through one full loop, including the exact JSON that crosses each arrow.

The tool-use loopThe user asks your app a question; your app sends the conversation and tool definitions to the model; the model replies with a tool_use request; your code runs the tool against your data and sends a tool_result back; the model then writes the final answer, which your app streams to the user.questionmessages + toolscontent blocksrun toolresultanswerUserYour appNode.js serverLLMMessages APITool codegetOrderStatus()Orders DBYour data

Step 1 of 7

The user asks a question

The answer depends on live data the model has never seen, so a plain model call would guess. Your app receives the message like any other request.

User message

"Where is my order #4821?"
The tool-use (function calling) loop: the model requests a tool with a tool_use block, your Node.js code runs it and returns a tool_result, and the model uses the result to answer. Press Play or step through it.
Show text description

The diagram shows five parts: the user, your app (a Node.js server), the LLM behind the Messages API, your tool code, and your database. The model never executes tools itself; your app runs the loop.

  1. The user asks a question. The answer depends on live data the model has never seen, so a plain model call would guess. Your app receives the message like any other request.
  2. Your app calls the model with tool definitions. Alongside the conversation, you describe each tool: a name, a description the model reads to decide when to use it, and a JSON Schema for its input.
  3. The model asks you to run a tool. The model cannot execute code. It stops with stop_reason "tool_use" and returns a tool_use block naming the tool and the arguments it chose.
  4. Your code executes the tool. Validate the input, check that this user may see this order, then run the function. Your data never leaves your control unless you return it.
  5. Send the tool result back. The API is stateless: append the assistant turn exactly as received, then a user turn containing a tool_result that references the tool_use id, and call the model again.
  6. The model writes the final answer. With the result in context, the model answers and stops with stop_reason "end_turn". If it needs more data, it returns tool_use again and the loop repeats from step 3.
  7. Stream the answer to the user. Show the final text in the UI. In production, cap the loop (for example at 10 iterations), log every tool call, and treat tool results as untrusted input.

Retrieval-augmented generation (RAG)

RAG grounds answers in your own documents. The work splits into an offline indexing path and an online query path that meet at the vector database.

Retrieval-augmented generation (RAG) pipelineIndexing path: documents are split into chunks, embedded, and stored in a vector database. Query path: the question is embedded, similar chunks are retrieved and reranked, and the LLM answers from those chunks with citations.vectors + textnearest neighborstop 20INDEXING · OFFLINEQUERY · EVERY REQUESTDocumentsPDF, HTMLChunksplit + metadataEmbeddingmodelVector DBPostgres + pgvectorQuestionEmbeddingmodelVector searchtop-k similarRerankerre-scores pairsLLMcited answerAnswerwith citations

Hover or tap a component to see what it does.

RAG pipeline: the indexing path chunks and embeds documents into a vector database ahead of time; the query path embeds the question, retrieves and reranks similar chunks, and the LLM answers with citations.
Show text description

Retrieval-augmented generation has two paths that meet at the vector database.

Indexing path. Runs offline whenever documents change: load each document, split it into chunks, embed every chunk, and store the vectors with their text and metadata.

Query path. Runs on every request: embed the question, retrieve the nearest chunks, rerank them, and give the best few to the LLM, which answers with citations.

  • Documents: Your source of truth: help-center articles, internal docs, tickets, PDFs. Keep each document's URL and title for citations.
  • Chunk: Split documents into passages of a few hundred tokens, ideally on headings or paragraphs, with a small overlap. Attach the source, title, and section to each chunk.
  • Embedding model: Turns each chunk into a vector: a list of numbers where similar meanings end up close together. Use the same embedding model for indexing and querying.
  • Vector DB: Stores each chunk's text, metadata, and vector, with an index (such as HNSW) for fast nearest-neighbor search.
  • Question: The user's question, for example: "How do I rotate an API key?"
  • Embedding model: Embeds the question with the same model used for the documents, so the question and the chunks live in the same vector space.
  • Vector search: Finds the chunks whose vectors are closest to the question's vector, usually 20 to 50 candidates. Combine with keyword search for exact terms (hybrid search).
  • Reranker: A model that reads the question and each candidate together and scores relevance more precisely than vector similarity. Keep only the best few chunks.
  • LLM: Receives the question plus the selected chunks, with instructions to answer only from them and cite the sources it used.
  • Answer: The response shown to the user, with links to the source documents so they can verify it.

The numbers on the arrows are typical starting points, not rules: retrieve around 20 candidates, then keep the best 5 after reranking. Tune both with evals.

Agent design patterns

Most useful "agents" are simpler workflows. These six patterns go from the most predictable to the most autonomous; start at the top and move down only when the task demands it.

Prompt chaining

Prompt chaining patternInput flows through LLM call 1, a code gate that can exit early, LLM call 2, and LLM call 3 to the output.passfailInputLLM call 1outlineGatecode checkExitfails checkLLM call 2draftLLM call 3polishOutput

Tap a step for details.

Prompt chaining. A fixed sequence of LLM calls where each step works on the previous step's output, with programmatic checks in between.
Show text description

Input flows through LLM call 1, a code gate that can exit early, LLM call 2, and LLM call 3 to the output.

Use it when: The task splits cleanly into ordered subtasks and you want each call to be simpler and more accurate.

Example: Write an outline, check it covers required points, draft the article, then polish the tone.

Routing

Routing patternA router LLM classifies the input and sends it to one of three specialized handlers, whose result becomes the output.InputRouterclassifies inputBillingprompt ATechnicalprompt BGeneralsmaller modelOutput

Tap a step for details.

Routing. A first LLM call classifies the input and sends it to the specialized prompt, tool set, or model best suited to it.
Show text description

A router LLM classifies the input and sends it to one of three specialized handlers, whose result becomes the output.

Use it when: Inputs fall into distinct categories that are better handled separately, including routing easy requests to a smaller, cheaper model.

Example: Send billing questions, technical issues, and general questions to different prompts and models.

Parallelization

Parallelization patternThe input fans out to three concurrent LLM calls checking accuracy, tone, and safety; code aggregates the results into the output.InputLLM callaccuracyLLM calltoneLLM callsafetyAggregatein codeOutput

Tap a step for details.

Parallelization. Several LLM calls run at the same time on independent parts of a task, and code aggregates their outputs.
Show text description

The input fans out to three concurrent LLM calls checking accuracy, tone, and safety; code aggregates the results into the output.

Use it when: Subtasks are independent and can run concurrently for speed, or you want several independent checks or votes for confidence.

Example: Run accuracy, tone, and safety checks on a draft in parallel, then combine the verdicts.

Orchestrator-workers

Orchestrator-workers patternAn orchestrator LLM plans subtasks and dispatches them to worker LLM calls; a synthesizer LLM combines their results into the output.InputOrchestratorplans subtasksWorkersubtask 1Workersubtask 2Workersubtask nSynthesizercombines resultsOutput

Tap a step for details.

Orchestrator-workers. An orchestrator LLM breaks the task into subtasks at runtime, delegates them to worker LLM calls, and a synthesizer combines the results.
Show text description

An orchestrator LLM plans subtasks and dispatches them to worker LLM calls; a synthesizer LLM combines their results into the output.

Use it when: You cannot predict the subtasks in advance, for example how many files a code change touches or which sources a question needs.

Example: Plan which files to edit for a feature, have a worker propose each file's change, then merge them into one patch.

Evaluator-optimizer

Evaluator-optimizer patternA generator LLM writes a draft; an evaluator LLM scores it and either sends feedback back to the generator or accepts it as the output.draftfeedbackacceptedInputGeneratorwrites a draftEvaluatorscores vs criteriaOutput

Tap a step for details.

Evaluator-optimizer. One LLM call generates a result while another evaluates it against clear criteria and sends feedback, looping until it passes.
Show text description

A generator LLM writes a draft; an evaluator LLM scores it and either sends feedback back to the generator or accepts it as the output.

Use it when: You have clear evaluation criteria and iterative refinement measurably improves the result.

Example: Translate a document, have an evaluator flag mistranslated terms, and revise until no issues remain or a round limit is hit.

Autonomous agent

Autonomous agent patternA human gives the LLM agent a task; the agent repeatedly takes actions in its environment and reads the feedback, checks in with the human when needed, and stops when done.taskcheck-insactionfeedbackHumanLLM agentdecides next stepEnvironmenttools, APIs, filesStop

Tap a step for details.

Autonomous agent. An LLM decides its own next step in a loop: it calls tools, observes the results, and continues until the goal is met or a limit is reached.
Show text description

A human gives the LLM agent a task; the agent repeatedly takes actions in its environment and reads the feedback, checks in with the human when needed, and stops when done.

Use it when: The task is open-ended, the number of steps cannot be predicted, and you can afford the cost and verify the outcome.

Example: Fix a failing test: read the code, run the tests, edit files, re-run, and stop when the suite passes.