Week 4 Master Guide
Week 4: HTTP/REST APIs, LLM Tokenizers, Prompt Engineering & Month 1 Capstone
Week 4 Daily Breakdown (5 Days)
Day 1
Week 4 — Day 1: How the Internet, HTTP & REST APIs Work (From Zero to LLM Wire Protocol)
1 code file(s) • 2 Q&ADay 2
Week 4 — Day 2: How LLMs Actually Process Text — BPE Tokenization, Softmax Temperature & `top_p` Math
1 code file(s) • 2 Q&ADay 3
Week 4 — Day 3: Prompt Engineering Mastery, Chain-of-Thought & Defending Against Prompt Injection
1 code file(s) • 2 Q&ADay 4
Week 4 — Day 4: Production API Resilience — Exponential Backoff, Full Jitter & Circuit Breakers
1 code file(s) • 2 Q&ADay 5
Week 4 — Days 5 to 7: Month 1 Capstone Project — SRE Runbook Copilot CLI
1 code file(s) • 0 Q&AWeek 4: HTTP/REST APIs, LLM Tokenizers, Prompt Engineering & Month 1 Capstone (week4.md)
Mentor's Note (10+ YOE Staff AI Engineer POV): Welcome to Week 4—the final week of Month 1 where everything you mastered in Weeks 1–3 (Terminal, Git, Core Python, Generators, Decorators, Pydantic v2,
asyncio, and SQL/Databases) connects directly to Large Language Models and culminates in Capstone Project 1: SRE Runbook Copilot CLI!What separates a beginner calling
client.chat.completions.create()from a Senior AI Engineer?
- Understanding HTTP & Wire Protocols (Day 1): Knowing exact HTTP status codes (
400vs401vs422vs429vs503),Authorization: Bearerheaders, andRetry-Afterheaders.- Understanding BPE Tokenization & Sampling Math (Day 2): How Byte-Pair Encoding (BPE) merges subword tokens, how the Softmax Temperature equation () controls determinism, and how
top_p(nucleus sampling) andlogprobsmeasure model confidence.- Advanced Prompt Engineering & Grounding (Day 3): Zero-shot vs Few-shot vs Chain-of-Thought (CoT), XML/Markdown delimiters to defeat Indirect Prompt Injection, and forcing
response_format={"type": "json_object"}.- Production API Resilience (Day 4): Exponential Backoff with Full Jitter () and Circuit Breakers.
- Month 1 Capstone Project (Days 5–7): Building, testing, and defending the complete SRE Runbook Copilot CLI (
capstones/month01_sre_runbook_copilot_cli/)!
Week 4 Architecture & Daily Folder Map
text
week04_apis_http_llms_and_capstone_1/
├── week4.md # Master Week 4 Syllabus & Architecture
├── day01_http_rest_apis_headers_status_codes/ # Day 1: HTTP/REST Internals, Headers & Status Codes
│ ├── README.md
│ ├── src/http_protocol_inspector.py
│ ├── tests/test_http_protocol_inspector.py
│ └── interview_questions.md
├── day02_bpe_tokenization_sampling_temperature_math/ # Day 2: BPE Tokenizer From Scratch & Softmax Math
│ ├── README.md
│ ├── src/bpe_and_sampling_math.py
│ ├── tests/test_bpe_and_sampling_math.py
│ └── interview_questions.md
├── day03_prompt_engineering_cot_delimiters_json_mode/ # Day 3: Prompt Engineering, CoT & Injection Defense
│ ├── README.md
│ ├── src/prompt_architect.py
│ ├── tests/test_prompt_architect.py
│ └── interview_questions.md
├── day04_api_resilience_backoff_jitter_circuit_breaker/ # Day 4: Exponential Backoff + Jitter & Circuit Breakers
│ ├── README.md
│ ├── src/resilience_engine.py
│ ├── tests/test_resilience_engine.py
│ └── interview_questions.md
└── day05_to_07_month1_capstone_sre_runbook_copilot/ # Days 5-7: Guide & Bridge to Capstone 1
└── README.md
capstones/month01_sre_runbook_copilot_cli/ # MONTH 1 CAPSTONE PROJECT REPOSITORY
├── README.md # Complete Capstone Documentation & Architecture
├── main.py # Parallel CLI Entry Point + SQL Audit + Cost Report
├── runbooks/
│ ├── payments_service.md
│ └── database_failover.md
├── src/
│ ├── __init__.py
│ ├── schemas.py # Pydantic v2 `RunbookResponse` & `CostRecord`
│ ├── cost_calculator.py # Exact Token & USD Cost Auditor
│ ├── copilot.py # Async OpenAI/Gemini/Deterministic Engine
│ └── audit_db.py # SQLite Persistent Cost & Telemetry Ledger
└── tests/
└── test_capstone_month01.py # Comprehensive Capstone Verification Test Suite
Daily Schedule & Core Deliverables
| Day | Topic | Deep Theory & Math Covered | Production Deliverable |
|---|---|---|---|
| Day 1 | HTTP, REST APIs, Headers & Status Codes | TCP/TLS handshake, Request/Response anatomy, GET vs POST idempotency, Status Codes (200, 400, 401, 403, 422, 429, 500, 502, 503), Retry-After | http_protocol_inspector.py — Builds OpenAI/Gemini-compatible HTTP payloads and classifies retryable vs fatal HTTP status codes |
| Day 2 | BPE Tokenization, Softmax Temperature & top_p Math | Byte-Pair Encoding (BPE) merge algorithm; Softmax with Temperature: ; Nucleus Sampling (top_p); converting logprobs to linear probability () | bpe_and_sampling_math.py — Trains a miniature BPE tokenizer from scratch + implements Softmax Temperature & top_p nucleus filtering |
| Day 3 | Prompt Engineering, CoT & Injection Delimiters | System/User/Assistant message hierarchy, Few-Shot exemplars, Chain-of-Thought (CoT), XML tag sandboxing (<runbook_context>), and negative constraints | prompt_architect.py — Prompt template compiler with XML context sandboxing and prompt injection detector |
| Day 4 | API Resilience: Exponential Backoff, Jitter & Circuit Breakers | Why naive retries cause "Thundering Herd" outages; Full Jitter math: ; 3-state Circuit Breaker (CLOSED OPEN HALF_OPEN) | resilience_engine.py — Production Exponential Backoff + Full Jitter calculator & stateful Circuit Breaker |
| Days 5–7 | Month 1 Capstone: SRE Runbook Copilot CLI | Combining Pydantic v2 + AsyncOpenAI / Universal .env + Cost Auditor + SQLite Audit Ledger + Parallel Execution | Full Month 1 Capstone in capstones/month01_sre_runbook_copilot_cli/ + Capstone Defense Interview! |