Leanpub Header

Skip to main content

Production-Grade Python, LangChain & LangGraph

A deployment-first handbook for developers who know Python syntax but have not shipped Python

Production-Grade Python, LangChain & LangGraph
This book is 25% completeLast updated on 2026-09-15

AI engineering is becoming one of the most valuable and in-demand areas of software development, and Python, LangChain, and LangGraph are core skills for building the systems behind it. Learn how to turn basic Python knowledge into production-grade backend and agentic AI applications—and move toward an engineering niche centered on building and controlling AI rather than competing with it.

Minimum price

$4.99

$9.99

You pay

Author earns

$

Also available for 1 book credit with a Reader Membership

PDF
EPUB
WEB
APP
About

About

About the Book

Learn the engineering skills behind one of software’s most valuable emerging fields

AI engineering is rapidly becoming one of the most commercially valuable areas of software development.

Companies are moving beyond simple chatbot prototypes and looking for engineers who can build reliable AI-powered applications, agentic workflows, retrieval systems, model integrations, and production infrastructure. That creates strong demand for developers who understand both software engineering fundamentals and modern AI application frameworks.

Python sits at the center of this ecosystem. It is the dominant language across AI, machine learning, data engineering, model tooling, and an increasing share of agent development. LangChain and LangGraph add the abstractions needed to build applications around large language models, tools, retrieval, state, and increasingly autonomous workflows.

These skills also occupy an interesting position in the changing software market. AI can automate more routine implementation work, but organizations still need engineers who can design the systems around AI: integration, orchestration, reliability, evaluation, security, deployment, observability, and production control. Learning to build the systems that use AI is therefore a compelling way to move toward the part of software engineering that AI itself is helping to create.

Production-Grade Python, LangChain & LangGraph is designed to take you there.

The book assumes that you already know basic Python syntax. Instead of teaching loops, functions, and classes again, it focuses on the engineering knowledge required to turn Python code into real production software.

You will learn:

  • How Python actually executes code through CPython, bytecode, modules, and processes
  • Modern project structure with pyproject.toml
  • Virtual environments, dependency management, locking, packaging, wheels, and reproducible builds
  • FastAPI and production API design
  • Configuration and secrets management
  • Async programming and concurrency
  • Database access, transactions, migrations, and persistence
  • Caching and external service integration
  • Error handling, retries, timeouts, and idempotency
  • Structured logging, metrics, tracing, and health checks
  • Unit, integration, API, and system testing
  • Containers, CI/CD, and production deployment
  • Security practices for backend and AI applications

The second half applies those engineering foundations to modern AI engineering with LangChain and LangGraph.

You will learn how to build:

  • LLM-powered applications
  • Structured model interactions
  • Tool-using agents
  • Retrieval-Augmented Generation systems
  • Stateful workflows
  • Conditional and parallel execution
  • Persistent agent state
  • Durable workflows
  • Human-in-the-loop approval
  • Streaming applications
  • Long-running agent processes
  • Multi-step and multi-agent systems
  • Testable and observable AI workflows

The emphasis throughout is on production engineering, not demos.

Calling an LLM is easy. Building a system around it that remains secure, reliable, observable, recoverable, and maintainable is where much of the real engineering value lies.

A complete production-style support-agent application brings the concepts together using FastAPI, SQLAlchemy, LangChain, LangGraph, persistence, authentication, observability, human approval, and safe execution of irreversible actions.

The book also includes a companion code repository containing the complete application, runnable examples, tests, deployment configuration, and every code sample used throughout the manuscript.

If you already know basic Python and want to position yourself for the growing field of AI engineering, this book gives you the production foundations and agent-development skills needed to move beyond prototypes and build systems organizations can actually depend on.

Author

About the Author

Fiodar Sazanavets

Fiodar Sazanavets is a senior software engineer specializing in AI systems, distributed applications, and data-intensive software. A former Microsoft engineer and fourt-time Microsoft MVP, he has more than a decade of professional experience designing and building production systems across a wide range of industries.

His core areas of expertise include Python, .NET, cloud technologies, distributed systems, and modern AI engineering. Throughout his career, he has worked on systems ranging from railway passenger information platforms and distributed IoT clusters to e-commerce applications and financial transaction-processing systems. He has also led engineering teams, mentored developers, and helped organizations translate complex technical requirements into reliable software that solves real business problems.

Alongside his engineering work, Fiodar is passionate about technical education. He writes books, creates online courses, mentors developers, and regularly publishes practical software engineering content. His teaching focuses on the skills developers need to build real-world systems: architecture, reliability, cloud engineering, AI, and production software development.

He writes about software engineering and AI at fiodar.substack.com/.

Contents

Table of Contents

About This Handbook

What This Book Is About

How to Use This Handbook

  1. Part I - Runtime, packaging, and deployment

1. What “compiling and deploying Python” actually means

  1. 1.1 Source, bytecode, wheels, and executables are different things
  2. 1.2 What compileall is for - and what it is not for
  3. 1.3 The three main deployment units
  4. 1.5 Build once, deploy the same artifact

2. A production-ready Python project skeleton

  1. 2.1 pyproject.toml is the project control plane
  2. 2.2 Virtual environments are process isolation for dependencies
  3. 2.3 Lock application dependencies
  4. 2.4 Imports should reflect package boundaries

3. Building and installing release artifacts

  1. 3.1 Why a wheel is useful even when you deploy a container
  2. 3.2 Editable installs are for development, not production
  3. 3.3 Pin the runtime as well as Python packages
  4. 3.4 Do not build with production secrets

4. Configuration, settings, and secrets

  1. 4.1 Validate settings at process startup
  2. 4.2 Never log secrets
  3. 4.3 Prefer identity to long-lived secrets where possible

5. Processes, ASGI, and serving an HTTP application

  1. 5.1 Understand the process model
  2. 5.2 Containers often favor one server process per container
  3. 5.3 Use lifespan for startup and shutdown resources
  4. 5.4 Graceful shutdown is part of correctness

6. Health checks, readiness, and startup

  1. 6.1 Startup probes protect slow initialization
  2. 6.2 Do not run destructive migrations on every replica startup

7. Containers: the default service deployment pattern

  1. 7.1 A production Dockerfile should optimize reproducibility and attack surface
  2. 7.2 Build dependencies should not remain in the runtime image
  3. 7.3 Run as a non-root user
  4. 7.4 Treat the filesystem as ephemeral
  5. 7.5 Signals and PID 1 matter

8. Deployment choices: VM, containers, serverless, Kubernetes

  1. 8.1 Virtual machine deployment
  2. 8.2 Managed containers
  3. 8.3 Serverless functions
  4. 8.4 Kubernetes fundamentals for Python services

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.)

In fact, authors have earned over $15 million writing, publishing and selling 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