← Study Index  ·  AI & Retrieval / Atlas — Build

Hands-on companion · Chapters 04–14

Atlas — build the notes as you read them

One small project, grown one lesson at a time, in nothing but the Python standard library. Each note ends with a Build it section; this is where the checkpoints live. By Chapter 14 the pieces are a working knowledge-graph agent.

Why it's one project, not ten snippets

Isolated snippets don't show how things fit. So every chapter adds one small module to the same codebase and answers the same question flat search can't — "Who leads the company that competes with the startup Microsoft acquired?" — from a new angle. No API keys, no database, no installs: the LLM is a deterministic stub you can later swap for a real client without changing anything around it.

Get set up

Clone the notes repo (you already have it), then:

# from the repo root
cd Projects/atlas-build
python3 run_all.py          # every chapter, end to end
python3 -m atlas.graph      # or one lesson at a time

Each module has an if __name__ == "__main__" demo, so running it prints exactly the output shown in that note's Build it section. Type the code from the note yourself; run the checkpoint here when you want to compare.

The checkpoints

Each row links back to its lesson. Read the note, build the module, then move on — the flow doesn't break.

CH 04

Knowledge Graphs & Graph RAG

atlas/graph.py

A tiny property graph — nodes are nouns, edges are verbs — with ego-graph traversal and a first Graph-RAG retrieval that returns topology, not text.

Open lesson → Build it ↗
CH 05

KG Primitives & Neo4j

atlas/queries.py

A Cypher-style match and one-hop walk, plus community detection as connected components — the query layer over the graph.

Open lesson → Build it ↗
CH 06

Text → Graph Extraction

atlas/extract.py

Turn raw sentences into clean triples and merge aliases (MSFT → Microsoft) with entity resolution. The graph stops being hand-typed.

Open lesson → Build it ↗
CH 07

Graph RAG in Production

atlas/retrieve.py

Put a vector on every node, jump to an entry node by cosine, walk the ego graph, and prune super-nodes — the three-phase engine.

Open lesson → Build it ↗
CH 08

DSPy — Declarative Optimization

atlas/dspy_lite.py

A 60-line DSPy: a signature is a typed contract, a module renders + parses, and compile bootstraps few-shot demos. The prompt becomes a build artifact.

Open lesson → Build it ↗
CH 09

LangGraph — Agentic Workflows

atlas/engine.py

The engine underneath LangGraph: StateGraph with nodes, edges, and an invoke that merges each node's update into shared state.

Open lesson → Build it ↗
CH 10

State Machines & Execution Graphs

atlas/engine.py

Conditional edges make it an agent, not a pipeline — a router picks the next node, cycles become possible, and a recursion limit becomes mandatory.

Open lesson → Build it ↗
CH 11

Assemble the Execution Graph

atlas/agent.py

Every piece so far becomes a node: retrieve → synthesize, wired with a conditional edge. The whole QA agent, expressed as State + Nodes + Edges.

Open lesson → Build it ↗
CH 12

The ReAct Architecture

atlas/react.py

Thought → Action → Observation, looping over graph tools until it can Finish — with the hard step limit every production loop needs. Answers Elena leads Nimbus.

Open lesson → Build it ↗
CH 13

Persistence & Threading

atlas/checkpoint.py

A checkpointer snapshots state after every step, keyed by thread_id. State survives a process restart; two threads stay fully isolated.

Open lesson → Build it ↗
CH 14

Context Management & Summarization

atlas/context.py

Unbounded memory is its own bug. A custom reducer appends turns; a maintenance node keeps recent verbatim, compresses the rest into a running summary, discards the raw.

Open lesson → Build it ↗