Leanpub Header

Skip to main content

AI Engineering Visualized: Volumes 1–4

Build one AI support assistant across four hand-drawn books: prompts and evals, an agent harness, RAG with sources, then production. Python, no API key. Save up to $39.

Bought separately

$119.96

Minimum price

$59.99

$79.99

You pay

Author earns

$

Also available for 3 book credits with a Reader Membership

These books have a total suggested price of $119.96. Get them now for only $59.99!
About

About

About the Bundle

One prompt. One assistant. Four books. Never restart.

AI Engineering Visualized: Volumes 1–4 follows one project from the first prompt to a system running for real users: a support assistant for Northwind Goods, a fictional online store. Volume 1 builds it. Volume 2 wraps it in an agent harness with checked plans, approvals and receipts. Volume 3 gives it real knowledge and makes every answer traceable to a source. Volume 4 takes it to production. No new example, codebase or set of terms between books.

Volume 1: Foundations

24 chapters, 232 hand-drawn doodles and almost 3 hours of explainer videos, one per chapter

A single prompt answering "Can I get a refund for order #1234?" grows into a working system: refund rules in code the model can't argue away, tool calls, cited answers, an honest "I don't know", evals before every change, and an agent loop with step limits, permissions and human approval.

Volume 2: Agents

17 chapters, 118 hand-drawn doodles and almost 2 hours of explainer videos, one per chapter

The same assistant gets an agent harness: the loop, tool registry, checks, state store, approvals, memory and limits. Each approval is bound to the exact action. The model is a part you can swap. The harness is what you test, version and ship.

Volume 3: RAG & Knowledge Systems

16 chapters plus a capstone appendix, 113 hand-drawn doodles

The best match was true once. Now it's wrong. Volume 3 builds the code that decides which sources may answer: ingestion with provenance, permissions checked at every step, hybrid search and reranking, a rule for when sources disagree, safe SQL, knowledge graphs and a regression gate. The capstone sends one ticket through every stage.

Volume 4: Production AI

16 chapters plus a capstone appendix, 115 hand-drawn doodles

The worker calls the payment provider and dies before it writes anything down. Was the refund paid? Volume 4 runs the assistant for real users: an API, a queue and leased workers, SLOs and error budgets, traces you can trust, shadow scoring and drift, releases you can roll back, latency and cost engineering, model routing with fallbacks, threat modelling, privacy, and incident response.

How the books teach

  • Visual first. Every idea is a named mental model with its own hand-drawn doodle, such as The Context Suitcase, The Agent Harness, The Evidence Pack or The SLO Card, with a plain definition, a failure you can trigger and the fix.
  • Real code, no API key. Short Python examples from the free companion repository (MIT licence) run on a stand-in model, so they cost nothing to try. Volumes 2–4 also report real runs on a local model (llama3.2 through Ollama).

Who it's for

Backend and full-stack developers, data engineers asked to "add AI", and technical founders who read Python. You don't need a machine learning background.

Why the bundle

  • One project, start to finish. Each volume picks up where the last one ended.
  • 578 hand-drawn doodles and over 4.5 hours of explainer videos across the set.
  • Save $19.97 at the minimum price, or $39.97 at the suggested price. All four books for $59.99 instead of $79.96, or $79.99 instead of $119.96.
  • Free updates to all four books. Buy once and get every future revision free.

Books

About the Books

AI Engineering Visualized, Volume 1: Foundations

AI Engineering Visualized, Volume 1: Foundations

A Visual Guide to Building LLM Apps, RAG and Agents

You got the demo working. Now it has to work on Monday. AI Engineering Visualized is for developers who have to ship features that call a language model. A model is one box; a product is the whole diagram around it. This book draws that diagram, box by box, as hand-drawn doodles you can remember and reuse when you design or debug. Every idea is a named mental model, such as The Context Suitcase, The Citation Gate, The Golden Set or The Trojan Ticket, with a picture, a plain definition, a failure you can trigger and the fix. One assistant, built chapter by chapter. You build a support assistant for Northwind Goods, a fictional online store. It starts as one prompt answering "Can I get a refund for order #1234?" and grows into a system that:

  • decides refunds with rules in code the model cannot argue away
  • counts its tokens and checks its own output against a contract
  • calls tools, then searches a handbook and answers with citations
  • says "I don't know" when the pages don't cover the question
  • measures itself with evals before every change
  • runs an agent loop with step limits, permissions and human approval
  • retries failed calls, masks personal data and logs every request for replay

Real code, no API key. Every chapter has short Python examples from the free companion repository (MIT licence, Python standard library only) and an exercise with a tested solution. The examples run on a scripted stand-in model, so they cost nothing; swap in your provider with one function when you are ready. Who it's for: backend and full-stack developers, data engineers asked to "add AI", and technical founders. You need to read Python. You do not need a machine learning background. Who it's not for: readers who want to train models from scratch, or a catalogue of today's model prices and rankings. Prices and model names change too fast; the book shows you how to measure instead. Complete edition: all 24 chapters. All 24 chapters of Volume 1 are in this edition, fully illustrated.

Part of the AI Engineering Visualized series: Volume 1: Foundations, Volume 2: Agents, Volume 3: RAG & Knowledge Systems and Volume 4: Production AI. Get all four in the Volumes 1–4 bundle.

AI Engineering Visualized, Volume 2: Agents

AI Engineering Visualized, Volume 2: Agents

A Visual Guide to Designing Agents That Plan, Act and Recover

Your agent worked in the demo. Then it refunded the wrong order, waited forever on a courier, or told a customer "your refund has been processed" when no payment ever went through.

AI Engineering Visualized, Volume 2: Agents is about everything around the model that turns its proposals into safe, finished work. The book calls that the agent harness: the loop, the tool registry, the checks, the state store, the approvals, the memory and the limits. The model is a part you can swap. The harness is what you test, version and ship.

One assistant, carried forward. Volume 1 ended with a support assistant for Northwind Goods, a fictional online store. Volume 2 picks it up and makes it an agent you could trust with real tickets: refunds, damaged items, late deliveries, address changes. Each chapter builds one part of the harness, shows a failure you can trigger, and fixes it.

Visual first. Every idea is a named mental model, such as The Agent Harness, The Identity Chain, Blast Radius, One Operation, One Receipt, The Waiting Ticket or Every Stop Has a Reason, drawn as a doodle with a plain definition next to it.

Real code. Each chapter has short Python examples ("Hands on Keys") and runs on a scripted stand-in model by default, so it costs nothing. Chapters also report what happened when the same code ran against a real local model (llama3.2 through Ollama), including the bugs those runs exposed and how the harness was changed to catch them.

Chapters 1-3 are in the free sample.

Who it's for

Developers who have a working LLM feature or a basic agent loop and now need it to behave on real tasks: backend and full-stack engineers, data engineers, and technical founders. You need to read Python. It helps to have read Volume 1 (especially its agent chapters), but the ideas it relies on are recapped where they are used.

Complete

All 17 chapters are written, and each chapter's explainer video is live. Buy once and get every future revision free.

Part of the AI Engineering Visualized series: Volume 1: Foundations, Volume 2: Agents, Volume 3: RAG & Knowledge Systems and Volume 4: Production AI. Get all four in the Volumes 1–4 bundle.

AI Engineering Visualized, Volume 3: RAG & Knowledge Systems

AI Engineering Visualized, Volume 3: RAG & Knowledge Systems

A Visual Guide to RAG and Knowledge Systems

The best match was true once. Now it's wrong.

Asha asks whether order #2001 can still be refunded. The best match in the assistant's new search index is an old ticket saying the parcel is still on its way. That ticket was true when it closed. Now it's stale: the order record says #2001 was delivered. A better search would still find that ticket. The code around the search decides which sources may answer, and this book builds that code.

For a retrieval feature whose answers you now have to trust. The sources are manuals with tables, an order database, past tickets and rules that change by region. Volume 1 built the Northwind Goods support assistant with a small hybrid search over one policy page and nine handbook passages. Volume 2 put a harness around it so it could act. Volume 3 gives it real knowledge and makes every answer traceable to a source.

One assistant, carried forward. Chapter by chapter you build the knowledge system behind the model:

  • a contract and an access path for every source, and an ingestion pipeline with stable ids, provenance and safe reruns
  • documents with tables and scans, cut into chunks that know where they apply
  • permissions from the session, checked at search and at every later step, with poisoned pages treated as a signal and never as the boundary
  • embeddings and vector indexes, hybrid search with an exact-match lane, reranking, and queries that are rewritten, routed and decomposed
  • a clear rule for which source wins when two disagree, when to abstain, and an evidence pack the model can cite
  • safe, scoped SQL over records, and multi-hop retrieval over a knowledge graph
  • index updates, deletes and rebuilds, retrieval metrics and faithfulness judges, and test sets with a regression gate

A capstone appendix then sends one ticket through every stage on one corpus.

Visual first. Every idea is one of 35 named mental models, such as The Ingestion Conveyor, Small to Find, Big to Read, The Two-Stage Funnel, The Evidence Pack, The Stale Index or The Regression Gate. Each one has a hand-drawn doodle, a plain definition, a failure you can trigger and the fix.

Real code, no API key. The examples are short Python excerpts from the free companion repository (MIT licence), built from plain stages on the Python standard library with no framework. By default they run on a stubbed model, with no API key, no network and no cost. You can point a chapter at a real local model with Ollama if you like. Each Model experiment reports one real llama3.2 run with its settings and log, not a rate; runs not made yet are marked [TO MEASURE].

Chapters 3, 7 and 10 are in the free sample.

What you'll learn

  • Give every source a contract, and decide when to retrieve a document and when to look up a record
  • Ingest documents with stable ids and provenance, so reruns don't duplicate or orphan chunks
  • Keep table rows as records, spot-check parsers and send a page image when the layout carries the meaning
  • Cut chunks at headings and rows, search small chunks and hand the model the parent section
  • Enforce who may see what, from the session, at search, expansion, rerank, cache and citation
  • Choose an embedding model on your own golden set, and fuse keyword and vector search
  • Rerank a wide net down to five, and size the net from a recall curve
  • Rewrite and route queries without losing products, negations, dates or limits
  • Settle conflicts between sources by applicability and authority, and abstain when no source should answer
  • Pack evidence within a budget and validate every citation
  • Turn questions into allow-listed, parameterized SQL, and walk a knowledge graph where an unknown edge escalates
  • Update, delete and rebuild an index safely, and catch a stale one
  • Measure every RAG stage, judge faithfulness and block regressions with a gate

Who it's for

Developers who have built a retrieval feature and now have to trust its answers. You should be comfortable reading Python. Volume 1, or the same ground (tokens, embeddings, search, chunking, a RAG pipeline, grounded answers, evals), comes first. Volume 2 helps lightly: the code starts from its final code, and each piece it reuses is recapped in one line. You don't need a machine learning background. You need Python 3.10 or newer and git.

Who it's not for

If you want a tour of RAG frameworks or vector databases, this isn't that book. It builds plain stages so that every guarantee is code you can read and test. Further Reading points to the real tools.

Free sample

Front matter plus Chapters 3, 7 and 10.

Complete

All 16 chapters and the capstone appendix are written and illustrated in this edition (281 pages in the screen PDF). Buy once and get every future revision free.

Table of contents

Sources and ingestion

  • 1. The Knowledge Map: Source Contracts and Access Paths
  • 2. Ingestion Pipelines: Stable IDs, Provenance and Re-Runs
  • 3. Documents With Layout: Tables, Scans and Images
  • 4. Structure-Aware Chunking and Applicability Metadata

Who may see what

  • 5. Knowledge Access: Permissions, Tenants and Poisoned Documents

Finding the right passage

  • 6. Embedding Models and Vector Indexes
  • 7. Hybrid Search: Keywords Plus Meaning
  • 8. Reranking: The Second Opinion
  • 9. Query Understanding: Rewrite, Route and Decompose

Deciding and packing

  • 10. When Sources Disagree: Authority, Applicability and Abstain
  • 11. Context Assembly: Packing Evidence for the Model

Records and links

  • 12. Structured Knowledge: Query Specs, Scope and Safe SQL
  • 13. Knowledge Graphs and Multi-Hop Retrieval

Keeping it right

  • 14. Index Lifecycle: Updates, Deletes, Rebuilds and Drift
  • 15. Evaluating RAG: Retrieval Metrics and Faithfulness Judges
  • 16. RAG Test Sets and Regression Gates

Appendix: Capstone, One Ticket Through Every Stage

Plus: Further Reading, Transfer Exercises, a Decision Guide, an Experiment Ledger, Quick Reference, a Solutions Index, Quiz Answers, a Glossary and a Mental-Model Index.

Part of the AI Engineering Visualized series: Volume 1: Foundations, Volume 2: Agents, Volume 3: RAG & Knowledge Systems and Volume 4: Production AI. Get all four in the Volumes 1–4 bundle.

AI Engineering Visualized, Volume 4: Production AI

AI Engineering Visualized, Volume 4: Production AI

A Visual Guide to Shipping, Scaling and Securing AI Apps

Asha's mug set arrived chipped, and she wants a refund. The worker calls the payment provider, and the process dies before it writes anything down. Was she paid?

That is the question Chapter 1 answers. Through three volumes the Northwind Goods assistant learned to answer, to act safely and to answer from real knowledge. It did all of that in one process on one laptop, for one customer at a time. This book runs it for real users: many tickets at once, on machines that fail, with releases that can go wrong and costs that add up.

For people who have a working assistant or agent and now have to operate it. Volume 1 built the Northwind Goods support assistant. Volume 2 put a harness around it so it could act. Volume 3 gave it real knowledge. This volume takes it to production.

One assistant, carried forward. The same support assistant for Northwind Goods, the fictional online store, now run as a service. Chapter by chapter you build what surrounds the model in production, and every chapter adds one part to it:

  • Boundaries and targets (Chapters 1-3): an API, a queue and leased workers with identity, secrets and state at named boundaries; SLOs counted as events, with error budgets and a written policy; traces, metrics you can trust and logs with nothing private in them.
  • Knowing whether it works (Chapters 4-6): live traffic scored in the shadow and watched for drift, feedback and experiments, and releases you can version, test and roll back.
  • Fast and affordable (Chapters 7-12): the critical path, streaming and backpressure, tokens and caching, model routing and fallbacks, serving choices, and when to fine-tune, distil or change models.
  • Safe and recoverable (Chapters 13-16): threat modelling and red-teaming, privacy and the data lifecycle, incident response, and a capstone that operates the complete system.

Visual first. This edition has 36 named mental models, such as Request Path, Job Path, The SLO Card, Canary and Rollback, The Critical Path Waterfall, The Attack Surface Map or The Weekly Improvement Loop. A mental model here is a named picture you can reuse when you design or debug. Each one has a hand-drawn doodle, a plain definition, a walkthrough, and why it matters; most also break the running example and fix it.

Real code, no API key. The examples are short Python excerpts from the free companion repository (MIT licence), in its vol4/ folder at tag vol4-ed1. The book builds plain parts with the Python standard library so that every step is code you can read. Further Reading points to the real tools and standards. By default the code calls a stubbed model, with no API key, no network and no cost. Traffic, durations and failures come from a seeded simulator, and the book labels them simulated. You can point later chapters at a real local model with Ollama if you like. A small evidence pack of local-model runs, with model digest, settings, hardware and sample size, is in the Experiment Ledger appendix. Everything else is labelled simulated or unmeasured.

Chapters 1, 6 and 15 are in the free sample.

What you'll learn

  • Put the assistant behind an API and a queue of leased workers, with identity, secrets and state at named boundaries
  • Write SLOs counted as events, with error budgets and a written policy
  • Trace every request, trust metrics only when the spans are complete, and log nothing private
  • Score live traffic in the shadow, off the reply path, and watch for drift
  • Turn feedback into tests and experiments, and ship a change only when the difference is real
  • Version every change in a release you can test and roll back
  • Shorten the critical path, stream under a contract, and apply backpressure
  • Price cost per resolved ticket, and cache with a stable prompt prefix
  • Route each ticket type to a model with tested fallbacks
  • Choose managed or self-hosted serving, and decide when to fine-tune, distil or change models
  • Threat-model the attack surface, check trust boundaries in code, and red-team the system
  • Map personal data through its lifecycle, and keep an audit trail
  • Contain, recover and verify after an incident
  • Operate the complete system for a week and report it honestly

Who it's for

People who have a working assistant or agent and now have to operate it. You should be comfortable reading Python. You do not need a machine learning or operations background. Volume 1, or the same ground (the whole-system diagram, tokens, evals, guardrails and privacy, and the timeouts, retries and latency budget of its last chapter), comes first. Volumes 2 and 3 help lightly: the code starts from Volume 3's final code, which contains Volume 2's agent harness, and each piece it reuses is recapped in one line. You need Python 3.10 or newer and git.

Who it's not for

If you want a tour of production platforms, this isn't that book. It will not hide the system in a platform. It builds plain parts with the Python standard library so that every step is code you can read. Further Reading points to the real tools and standards.

Free sample

Front matter plus Chapters 1, 6 and 15.

Complete

All 16 chapters and the appendices are written and illustrated in this edition (292 pages in the screen PDF). Buy once and get every future revision free.

Table of contents

Boundaries and targets

1. Production Architecture: APIs, Workers, State and Boundaries

2. SLOs and Error Budgets

3. Observability: Traces, Metrics and Logs

Knowing whether it works

4. Online Evaluation: Shadow Scoring and Drift

5. Feedback and Experiments

6. Release Engineering: Versioning, CI and Rollbacks

Fast and affordable

7. Latency Engineering: The Critical Path

8. Streaming, Cancellation and Backpressure

9. Cost Engineering: Tokens and Caching

10. Model Routing, Fallbacks and Provider Resilience

11. Inference and Serving: Managed vs Self-Hosted

12. When to Fine-Tune, Distill or Change Models

Safe and recoverable

13. Security Engineering: Threat Modeling and Red-Teaming

14. Privacy, Governance and Data Lifecycle

15. Incident Response: Contain, Recover, Verify

16. Capstone: Operating the Complete System

Appendix: Capstone, One Week Through Every Box

Plus: Further Reading, a Joined Drill, Transfer Exercises, a Decision Guide, an Experiment Ledger, Audit Log Integrity, Quick Reference, a Solutions Index, Quiz Answers, a Glossary and a Mental-Model Index.

Part of the AI Engineering Visualized series: Volume 1: Foundations, Volume 2: Agents, Volume 3: RAG & Knowledge Systems and Volume 4: Production AI. Get all four in the Volumes 1–4 bundle.

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub