How the AI Engineering from Scratch Curriculum Is Organized: Phases and Lessons Structure
The AI Engineering from Scratch curriculum organizes 20 sequential learning phases (numbered 00–19) under a root phases/ directory, with each phase containing standardized lesson folders that include code/, docs/, and outputs/ subdirectories.
The rohitg00/ai-engineering-from-scratch repository implements a rigid filesystem-based curriculum architecture designed for both human navigation and programmatic ingestion. This structure breaks down complex AI engineering concepts into 20 logical phases, ranging from initial setup to advanced capstone projects, with each phase containing multiple hands-on lessons following a consistent three-part layout.
Phase-Lesson Hierarchy
The curriculum root contains a phases/ directory that houses exactly 20 phases, numbered from 00 to 19. Each phase represents a distinct AI sub-domain, such as "Math Foundations," "Deep Learning Core," or "LLM Engineering."
Inside the phases/ directory, folders follow the naming convention:
phases/<NN>-<phase-slug>/
Where <NN> is a two-digit zero-padded index (00, 01, 02, …, 19) that enforces chronological order.
Within each phase directory, individual lesson folders follow a similar pattern:
phases/<NN>-<phase-slug>/<NN>-<lesson-slug>/
For example, Phase 1 "Math Foundations" contains lessons like phases/01-math-foundations/01-linear-algebra-intuition/, while Phase 3 "Deep Learning Core" includes phases/03-deep-learning-core/03-backpropagation/.
Phase Overview Examples
| Phase | Name | Lesson Count | Example Lesson |
|---|---|---|---|
| 00 | Setup & Tooling | 12 | Dev Environment |
| 01 | Math Foundations | 22 | Linear Algebra Intuition |
| 02 | ML Fundamentals | 18 | Linear Regression from Scratch |
| 03 | Deep Learning Core | 13 | Backpropagation from Scratch |
| 04 | Computer Vision | 28 | Convolutions from Scratch |
| 19 | Capstone Projects | – | Advanced Integration Projects |
The complete phase and lesson table is documented in the repository's README.md under the Contents section, with each lesson title linking directly to its folder path.
Standardized Lesson Structure
Every lesson folder in the AI Engineering from Scratch curriculum contains three mandatory subdirectories:
code/– Runnable implementations in Python, TypeScript, Rust, or Juliadocs/– Narrative markdown documentation (typicallyen.md) explaining concepts and objectivesoutputs/– Generated artifacts including prompts, skills, agents, or MCP servers produced by the lesson
This uniformity allows the curriculum to categorize lessons by type (Learn, Build, or Reference) and primary programming language. For instance, Phase 0 contains 12 lessons covering development environment setup, while Phase 1 contains 22 lessons on mathematical foundations, each following this exact three-folder structure.
Navigating the Curriculum Programmatically
The consistent filesystem layout enables automated discovery and loading of lesson content. Because every lesson follows the phases/<phase>/<lesson>/ pattern with standardized subfolders, you can programmatically traverse the curriculum.
Listing All Lessons in a Phase
The following Python function scans a phase directory and identifies the primary implementation file in each lesson's code/ folder:
import pathlib
import fnmatch
def list_lessons(phase_dir: str):
phase_path = pathlib.Path(phase_dir)
for lesson in sorted(phase_path.iterdir()):
if lesson.is_dir():
code_dir = lesson / "code"
py_files = fnmatch.filter(
[p.name for p in code_dir.iterdir()], "*.py"
)
main_py = py_files[0] if py_files else "none"
print(f"{lesson.name}: {main_py}")
# Example: list lessons in Phase 1 – Math Foundations
list_lessons("phases/01-math-foundations")
This outputs entries such as:
01-linear-algebra-intuition: vectors.py
02-vectors-matrices-operations: matrix_ops.py
...
Loading Lesson Implementations Dynamically
You can import lesson code directly without manual path manipulation:
from importlib.util import spec_from_file_location, module_from_spec
import pathlib
def load_lesson(phase: str, lesson: str):
code_path = pathlib.Path("phases") / phase / lesson / "code"
main_file = next(code_path.glob("*.py"))
spec = spec_from_file_location("lesson_mod", main_file)
mod = module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
# Load the "Backpropagation from Scratch" lesson (Phase 3, Lesson 3)
backprop = load_lesson("03-deep-learning-core", "03-backpropagation")
backprop.run_demo() # assumes the lesson defines a run_demo entry-point
Accessing Documentation and Outputs
Retrieve lesson narratives and enumerate generated artifacts using standard path operations:
def get_doc(phase: str, lesson: str) -> str:
doc_path = pathlib.Path("phases") / phase / lesson / "docs" / "en.md"
return doc_path.read_text(encoding="utf-8")
def list_outputs(phase: str, lesson: str):
out_dir = pathlib.Path("phases") / phase / lesson / "outputs"
for item in out_dir.iterdir():
print(f"{item.name} → {item.suffix}")
# Usage examples
doc_text = get_doc("01-math-foundations", "01-linear-algebra-intuition")
list_outputs("14-agent-engineering", "01-the-agent-loop")
Key Files and Directories
| File/Directory | Purpose | Path Pattern |
|---|---|---|
README.md |
Central overview with phase/lesson tables and navigation guide | /README.md |
AGENTS.md |
Contribution policies and lesson contract specifications | /AGENTS.md |
phases/ |
Root container for all 20 phases and their lessons | /phases/ |
| Phase directory | Individual phase container (e.g., Math Foundations) | /phases/01-math-foundations/ |
Lesson code/ |
Runnable source implementations | /phases/<phase>/<lesson>/code/ |
Lesson docs/en.md |
Human-readable lesson narrative | /phases/<phase>/<lesson>/docs/en.md |
Lesson outputs/ |
Generated prompts, agents, and MCP servers | /phases/<phase>/<lesson>/outputs/ |
Summary
- The AI Engineering from Scratch curriculum organizes content into 20 sequential phases (00–19) stored in the root
phases/directory. - Each phase contains numbered lesson folders following the pattern
phases/<NN>-<phase-slug>/<NN>-<lesson-slug>/. - Every lesson includes three standardized subdirectories:
code/for implementations,docs/for narrative explanations, andoutputs/for generated artifacts. - The rigid structure supports programmatic navigation, allowing automated loading of lesson code, documentation, and outputs across all 20 phases.
- Phase examples range from Setup & Tooling (Phase 00) and Math Foundations (Phase 01) to Capstone Projects (Phase 19).
Frequently Asked Questions
How many phases are in the AI Engineering from Scratch curriculum?
The curriculum contains 20 phases, numbered from 00 to 19. Phase 00 covers "Setup & Tooling" with 12 lessons, while Phase 19 focuses on "Capstone Projects." Each phase represents a logical progression in AI engineering competency, from mathematical foundations through deep learning, computer vision, and agent engineering.
What is the folder structure inside a lesson directory?
Every lesson folder contains exactly three subdirectories: code/ for runnable implementations (Python, TypeScript, Rust, or Julia), docs/ containing the narrative explanation in en.md, and outputs/ for generated artifacts like prompts or MCP servers. This standardized layout appears in all lessons across all 20 phases, enabling consistent navigation both manually and programmatically.
How are lessons categorized within the curriculum?
Lessons are classified by type and programming language. The three lesson types are Learn (conceptual understanding), Build (hands-on implementation), and Reference (lookup materials). The primary languages used vary by lesson but typically include Python for machine learning fundamentals, with TypeScript, Rust, or Julia appearing in specialized phases.
Can I programmatically access lesson content without manually browsing folders?
Yes. Because the curriculum follows a strict phases/<phase>/<lesson>/ convention with consistent subfolder names, you can use standard filesystem operations or the provided Python utilities to list lessons, load code modules dynamically via importlib, read documentation files, and enumerate output artifacts. This design supports automated curriculum browsers and custom learning agents.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →