Preface
Technology Stack
The Nature of AI Agents
- Part I: Core Python Concepts
Chapter 1: Type Annotations
- Labels
- Living Documents
- Limitations
- Looking Ahead
Chapter 2: Enumerations
- The Traffic Light Analogy
- The
enumModule - Creating an Enumeration
- String Enums
- Modeling Querybase Intents
Chapter 3: Dataclasses, Immutability, and Memory
- Dataclasses
- Boilerplate for Free
- Defaults and Mutable Fields
- Immutability
Chapter 4: Runtime Validation
- Introducing Pydantic
- Dataclasses vs. Pydantic
- Part II: Software Architecture Principles
Chapter 5: Separation of Concerns
- The Python Hierarchy of Separation
- Mapping SoC to the Querybase Files
Chapter 6: Encapsulation and Abstraction
- Encapsulation
- Abstraction
- Public vs. Private Interfaces
- Designing Maintainable Modules
Chapter 7: Layering
- Querybase Layers
- API Layer
- Pipeline Layer
- Infrastructure Layer
Chapter 8: Pipelines and Flow Contracts
- Stages as a chain
- Immutable state & flow contracts
- Swapping Stages
- Part III: Designing Querybase
BEFORE THE BUILD
Chapter 9: Task Decomposition & Workflows
- One-Shot Prompt
- Decomposing the Querybase Workflow
- The Tactical Assignment Matrix
- Assigning Responsibilities to Implementations
Chapter 10: Understanding the Question
- Structured Understanding
- Defining the Classification Contract
- Establishing a Shared Vocabulary
RETRIEVAL AND CONTEXT CONSTRUCTION
Chapter 11: Retrieval
- What Is Retrieval?
- Finding Information
- Embedding-Based Retrieval (EBR)
- Measuring Similarity
- The Three-Step Lifecycle
DESIGN DECISIONS
Chapter 12: Choosing a Retrieval Architecture
- The Decision
- Crossing the Boundary
MAPPING THE ARCHITECTURE
Chapter 13: Mapping the Retrieval Layer
- Part IV: Building Querybase
Chapter 14: Initializing the Project
- Development Tools
- Creating the Repository
- Separating Concerns
- Creating our Backend
- Initializing the Development Environment
- Creating a
.gitignorefile - Creating an Environment Template
- Installing Dependencies
- Creating the Project Structure
Chapter 15: Building the Contracts
- A Shared Language
- Request Contracts
- Response Contracts
- Structural Contracts
- Boundary Validation
Chapter 16: Building the Classifier
Chapter 17: Building the Router
Chapter 18: Building the Search Layer
Chapter 19: Building the Extractor
Chapter 20: Building the Answerer
Chapter 21: Response Generation and Pipeline Orchestration
- Building the Pipeline
- Routing Requests
- Request Handoff
- Pipeline Orchestration
- Error Handling
- Designing Deterministic AI Pipelines
Chapter 22: Testing the Pipeline
- Unit-testing each stage in isolation
- Mocking the LLM and embedding calls (the dev_smoke_test.py pattern)
- End-to-end wiring tests with no live API calls
Decision Register
- Comparison Matrix: Retrieval Architectures