Module 1: Architecture and State Contracts

LangGraph Architecture Overview

Learning objectives

  • Explain the core mental model behind LangGraph Architecture Overview
  • Apply LangGraph Architecture Overview within Architecture and State Contracts
  • Identify important boundaries, trade-offs, and failure modes
  • Produce concrete evidence from the practice exercise

Production checkpoint construction

from langgraph.checkpoint.postgres import PostgresSaver

DB_URI = "postgresql://..."
with PostgresSaver.from_conn_string(DB_URI) as checkpointer:
    checkpointer.setup()
    graph = builder.compile(checkpointer=checkpointer)

Initialize the database-backed saver explicitly and scope its connection lifecycle. Every invocation that participates in persistence must use a stable thread identifier.

Related: LangGraph Core Concepts | LangGraph State Graph | LangGraph Persistence and Checkpoints | LangGraph Index

This note is the block diagram. Every other note in the vault is a zoom-in on one of the boxes here.


The Big Picture

                    ┌────────────────────────────┐
                    │      Caller / UI / API     │
                    └────────────┬───────────────┘
                                 │ input (initial state)
                                 ▼
┌──────────────────────────────────────────────────────────────────┐
│                        GRAPH RUNTIME                             │
│  ─ orchestrates node execution, manages state, handles interrupts│
│                                                                  │
│   ┌──────────────────────────────────────────────────────────┐   │
│   │                     COMPILED GRAPH                       │   │
│   │                                                          │   │
│   │   ┌─────────────┐    ┌─────────────┐    ┌────────────┐  │   │
│   │   │    Node A   │───▶│    Node B   │───▶│   Node C   │  │   │
│   │   │  (agent)    │    │  (tool)     │    │  (review)  │  │   │
│   │   └─────────────┘    └─────────────┘    └────────────┘  │   │
│   │          ▲                                    │          │   │
│   │          │                                    │          │   │
│   │   ┌─────────────┐                      ┌────────────┐   │   │
│   │   │ Conditional │◀─────────────────────│    END     │   │   │
│   │   │    Edge     │                      │            │   │   │
│   │   └─────────────┘                      └────────────┘   │   │
│   └──────────────────────────────────────────────────────────┘   │
│                                                                  │
│   ┌──────────────────────────────────────────────────────────┐   │
│   │                      STATE STORE                         │   │
│   │         TypedDict shared across all nodes                │   │
│   └──────────────────────────────────────────────────────────┘   │
│                                                                  │
│   ┌──────────────────────────────────────────────────────────┐   │
│   │                   CHECKPOINTER                           │   │
│   │         SQLite / Postgres / Redis persistence            │   │
│   └──────────────────────────────────────────────────────────┘   │
│                                                                  │
│   ┌──────────────────────────────────────────────────────────┐   │
│   │                    INTERRUPT HANDLER                     │   │
│   │         Pause, human input, resume, time travel          │   │
│   └──────────────────────────────────────────────────────────┘   │
└──────────────────────────────────────────────────────────────────┘

Read the diagram top-to-bottom. The caller passes initial state to the graph runtime. The runtime executes nodes in order, routing via edges. State is updated after each node. The checkpointer saves snapshots. The interrupt handler pauses execution when needed.


The Four Layers

1. Graph Definition Layer

Where you define nodes, edges, and state schema.

Responsibilities:

  • Declare the State TypedDict
  • Add nodes (Python functions)
  • Add edges (normal and conditional)
  • Set entry and exit points

Engineering analogy: defining a graph is like writing a Makefile or a Terraform config. You declare what should happen, not how to execute it.

See LangGraph State Graph and LangGraph Nodes and Edges.


2. Runtime Layer

The execution engine. Activated when you call graph.invoke() or graph.stream().

Responsibilities:

  • Traverse the graph according to edges
  • Call nodes with current state
  • Merge node outputs into state using reducers
  • Enforce max iterations and timeouts
  • Stream events to callbacks

Engineering analogy: the Python interpreter executing bytecode. The graph is the bytecode; the runtime is the VM.


3. Persistence Layer

Checkpoints and state storage.

Responsibilities:

  • Save state after each node (checkpoint)
  • Load state on resume
  • Support multiple threads (conversations)
  • Enable time travel (rewind to prior checkpoint)

Backends:

  • InMemorySaver — in-memory, for dev
  • SqliteSaver — local SQLite
  • PostgresSaver — production database
  • RedisSaver — fast, ephemeral

See LangGraph Persistence and Checkpoints.


4. Interrupt Layer

Human-in-the-loop and external interaction.

Responsibilities:

  • Pause graph execution at a node
  • Serialize state for external review
  • Resume with new input or edited state
  • Support approval workflows

See LangGraph Human in the Loop.


Data Flow on a Single Invocation

  1. Caller invokes graph.invoke({"question": "What is RAG?"})
  2. Runtime loads the compiled graph and initializes state
  3. Entry point routes to the first node
  4. Node receives state, does work, returns updates
  5. Runtime merges updates into state via reducers
  6. Checkpointer saves a snapshot
  7. Edge router decides the next node (or END)
  8. Repeat 4–7 until END or interrupt
  9. Runtime returns final state to caller

Why This Decomposition

LayerChanges when...Fails because...
Graph definitionYou add a new step or branchWrong state schema, missing edge
RuntimeYou need streaming or asyncEvent loop blocked, callback leak
PersistenceYou migrate databasesConnection failure, schema mismatch
InterruptYou add an approval stepState not serializable, resume logic bug

Engineering analogy: this is the separation of concerns from compiler design. Frontend (graph definition) → middle-end (runtime) → backend (persistence).


What LangGraph Doesn't Have

To set expectations:

  • No built-in model hosting. You still call external APIs or local inference servers via LangChain.
  • No distributed execution. Graphs run in a single Python process. For distributed work, orchestrate multiple graphs via a message queue.
  • No visual editor. Graphs are defined in code, not drag-and-drop.
  • No automatic scaling. You bring your own infrastructure (Kubernetes, Lambda, etc.).

Related

  • LangGraph Core Concepts — vocabulary used in the diagram
  • LangGraph State Graph — defining the graph
  • LangGraph Persistence and Checkpoints — the persistence layer
  • LangGraph Human in the Loop — the interrupt layer
  • LangGraph Index — full topic map

Practice lab

Implement the smallest runnable agent workflow that demonstrates LangGraph Architecture Overview. Trace inputs, state, model and tool calls, outputs, and cost; inject one failure and add a regression test that prevents it from returning. Add an operational constraint such as concurrency, recovery, security, latency, or cost, and defend the resulting design trade-off.

Review questions

  1. What problem does LangGraph Architecture Overview solve, and what assumptions does it rely on?
  2. Which boundary or failure case is easiest to miss, and how would you expose it?
  3. What alternative design would you consider, and what trade-off would change the decision?
  4. What artifact, trace, test, or metric proves that your implementation is correct?

Completion evidence

  • A working artifact, annotated trace, or reproducible experiment
  • At least one normal case and one deliberately failing or boundary case
  • A concise explanation of the design choice and its trade-offs
  • Saved output showing how correctness was evaluated