Module 13A: Projects

Ship & get hired3 projects0 of 3 complete

Starter projects are guided step by step and suit freshers. Stretch projects are open-ended, add production concerns, and suit experienced readers.

Three projects: one starter, one stretch and one optional dossier. Every one runs keylessly. The module's code is pure Python: the ai_product files of lessons 13A.1 to 13A.7, the scripted models (CannedModel), fixture corpora and in-memory stores all run on your machine with no provider keys, no services and no network. Hosted providers are the optional stretch for each project, and the ports and fakes are exactly where the real implementation plugs in. The capstone builds live in Module 13B.

The building blocks. Each project assembles files the lessons ship, plus the running packages from earlier modules:

  • From 13A.1: ai_product/feature_brief.py, the AI feature brief model, issues() validator and score_use_case() decision-table scorer
  • From 13A.2: events.py (typed event contract + SSEEncoder), smoother.py (ChunkSmoother, replay, metrics), progress.py (ProgressTracker), plus the demo_app.py/demo_client.py pair
  • From 13A.3: approval.py (ApprovalGate), review_queue.py (ReviewQueue with AUTO/REVIEW/AUDIT routing), feedback.py (FeedbackEvent, FeedbackStore, feedback_to_evalkit)
  • From 13A.4: failure_ui.py (from_outcome/from_transport/from_policy to typed UserMessage), copy_catalog.py (resolve, catalogue_keys), markdown_safety.py (clean_markdown), a11y_lint.py (lint_spec)
  • From 13A.5: ports.py (ModelPort, RetrieverPort, ToolsPort, StorePort, canonical Message/Completion/RetrievedChunk/ToolResult), jobs.py (JobRunner, InProcessJobStore, idempotency keys), app.py (FastAPI app factory with fakes and build_demo_app())
  • From 13A.6: metrics.py (event aggregator: acceptance, edit distance, escalation, p50/p95), experiment.py (two_proportion_z_test, bootstrap_diff_ci, bootstrap_prop_ci, sample_size_per_arm, mde_for_sample), unit_economics.py (ModelPrice, TaskProfile, cost_per_success, sensitivity_table, CostModel, support_copilot)
  • From 13A.7: case_card.py (CaseCard, Source, Outcome, Shape, check(), render())

From earlier modules: evalkit (evalkit.core.Example/FunctionScorer/Score/run_eval, evalkit.dataset.load_dataset/to_core_examples) from 10A.10, and the support copilot from Module 13B (or your own build) as the product the experiment study instruments. Where a package is not yet assembled, each project's steps say exactly which minimal file to create instead.

The honesty rule for this module. CannedModel replays scripts; fixture corpora are fictional; in-memory stores stand in for databases. They prove your plumbing, such as the event contract, the approval gate, the job state machine and the eval gate, and never a real model's judgement. Expected outputs that depend on model behaviour are labelled illustrative; deterministic runs are labelled Output:. Where a step only becomes meaningful with a real model, the project says so and shows the one-line switch.


Starter

Starter: AI UX audit and redesign#

Goal: Pick any public AI chat or assistant feature you use, audit it against the pattern catalogues the module built — streaming and latency (13A.2), trust and control (13A.3), failure states and accessibility (13A.4) — write the audit report, redesign three screens as wireframes, and write the copy deck for every state you find. Fully keyless: this is a design-and-analysis project, not a build.

The audit is the deliverable. The ai_product modules are your checklist made executable: failure_ui.py's taxonomy, a11y_lint.py's rules, copy_catalog.py's i18n discipline, events.py's contract vocabulary, smoother.py/progress.py's render-side behaviours, and approval.py/review_queue.py/feedback.py's control surfaces.

What you'll practise:

  • Latency and streaming UX: the three clocks, the 0.1/1/10 s thresholds, when streaming hurts, smoothing, scroll behaviour, the control set, the event contract (lesson 13A.2, especially 1.2, 2.1, 2.2, Part 6)
  • Trust, disclosure and control: calibrated trust, the autonomy dial, HITL patterns, evidence display, uncertainty and abstention, feedback design, dark patterns (lesson 13A.3, especially 4.1, 8.1, 7.3)
  • Failure states and inclusive design: the failure taxonomy, copy craft, recovery paths, degradation, clarifying questions, safe rendering, WCAG 2.2, i18n, real devices (lesson 13A.4, especially Part 2, 3.2, Part 8)
  • The audit method itself: think-aloud sessions, log review, red-team-style usability probes, and what to measure (13A.4, Part 11)

Setup:

bash
uv init ux-audit --bare --python 3.13 && cd ux-audit
uv add pydantic
mkdir -p ai_product audit

Copy the ai_product files this audit uses from the lessons: events.py, smoother.py, progress.py (13A.2), approval.py, review_queue.py, feedback.py (13A.3), failure_ui.py, copy_catalog.py, markdown_safety.py, a11y_lint.py (13A.4). No .env, no keys, no services.

Steps:

  1. Pick the target and write the scope. Choose one public AI feature — a chat assistant, a support widget, a document tool, a voice line's web chat. Write audit/scope.md: what the feature does, who uses it, which surfaces you're auditing (main chat, streaming states, errors, settings), and what you will not judge (model quality — that's evals, not UX). Be honest about access: if you can't use the product yourself, say so and audit a competitor's product or a mock instead.
  2. Capture the evidence. For each audited surface, record: what the user sees while waiting, what events the UI must be receiving (map what you observe to events.py's vocabulary — meta, status, token, reasoning, tool_start, tool_end, citation, suggestion, warning, error, usage, reset, heartbeat, done), what happens on each failure you can provoke (rate limit by rapid-fire requests if allowed, ambiguous input, off-topic, empty retrieval), and what controls exist (stop, regenerate, edit, feedback, memory, approvals).
  3. Score against the catalogues. Work through the three lessons' checklists as a rubric: 13A.2's failure gallery and event-contract rules, 13A.3's pattern catalogue and trust checklist, 13A.4's failure taxonomy, copy table, WCAG table and degradation ladder. For every finding record: surface, what you observed, the catalogue item it violates, severity (blocks use / erodes trust / polish), and evidence (screenshot description, transcript, curl output).
  4. Run the executable checks. Write audit/spec.json describing the audited UI's components (streamed text region, approval dialog, feedback buttons, error banner) in the shape a11y_lint.lint_spec expects, and run it — every LIVE-02-style failure is a finding. Run failure_ui.signal_key/from_outcome mentally against each error you triggered: does the product's actual message match what the mapper would produce, and is the copy in copy_catalog.py's spirit (honest, specific, blameless)?
  5. Write the audit report. audit/report.md: scope, method, findings table ordered by severity, the three worst problems in depth, what the product does well (name it — audits that only find faults are useless), and a prioritised fix list.
  6. Redesign three screens. Pick the three highest-severity surfaces and produce wireframes — ASCII or Mermaid, labelled "wireframe, not a design system" — applying the lessons' patterns: the event contract for streaming, ApprovalGate-style controls for risky actions, UserMessage-driven failure states, aria-live strategy for streamed text, copy_catalog keys for every message. For each wireframe, list which ai_product module enforces the behaviour.
  7. Write the copy deck. For every state in your three redesigned screens, write the actual user-facing copy: loading, streaming, citations, warnings, each failure state (timeout, rate limit, refusal, empty result, truncation), approvals, feedback prompts, degraded mode. Follow 13A.4's anatomy (what happened / why / what you can do / what we preserved / where to get help) and give each string an i18n key in copy_catalog.py's style.
  8. Measure what you can. If you ran the product, record perceived latency honestly (your own stopwatch on TTFT vs total — label it n=1 anecdote, not a benchmark). Note which metrics from 13A.6's tree the product should be tracking and whether it visibly does.

Verify it, and what you should see:

bash
uv run python -c "from ai_product.a11y_lint import lint_spec; import json; print(json.dumps(lint_spec(json.load(open('audit/spec.json'))), indent=1))"
uv run python -c "from ai_product.copy_catalog import catalogue_keys, resolve; print(len(catalogue_keys())); print(resolve('en','error.timeout'))"  # a key missing from the catalogue comes back as the key itself, which is the gap

audit/report.md, three wireframes and copy_deck.md are the deliverables. A good audit names at least one thing the product does well, cites a catalogue item for every finding, and its redesigns map each decision to a specific ai_product file.

Done when:

  • audit/scope.md, audit/report.md, three wireframes and copy_deck.md exist and are internally consistent (every wireframe state has copy; every copy key exists in the catalogue style).
  • Every finding cites a catalogue item from 13A.2, 13A.3 or 13A.4 — no vague "bad UX".
  • a11y_lint.lint_spec ran on your spec and its failures appear as findings.
  • The copy deck covers at least: streaming start, mid-stream warning, citation display, timeout, rate limit, refusal, empty result, truncation, approval request, degraded mode.
  • Your report states plainly what you could not verify (you can't see their logs, evals or backend) and separates observed behaviour from inference.

Stretch ideas: Audit the same feature on two devices/network conditions (13A.4, Part 10). Add an implicit-signal analysis: which user behaviours (edit rate, abandonment, regenerate) would you instrument to test your trust hypotheses (13A.3, 5.3; 13A.6, Part 2). Turn your worst finding into a capstone.yaml-style requirement with an eval-case acceptance criterion (13B.1, 3.2). Optional live check, no keys needed for most of it: repeat the audit against a second product and diff the two reports.

Common problems:

  • Auditing vibes instead of catalogues — every finding must name the lesson section it violates; "feels off" is not a finding.
  • Confusing model quality with UX — a wrong answer is an eval problem; a wrong answer presented confidently with no evidence, no recovery and no way to report it is a UX problem. Say which.
  • Wireframes that redesign the brand, not the behaviour — the lesson's patterns are about states, contracts and controls, not visual design.
  • Copy that apologises without informing — 13A.4's anatomy requires what happened, why, what you can do, what we preserved, where to get help; "Something went wrong, sorry!" fails four of five.
  • Forgetting the already-built controls — check whether the product has stop/regenerate/edit/feedback/memory before redesigning them; the finding may be "exists but undiscoverable", which is a different fix.

Stretch

Stretch: Experiment and economics study#

Goal: Instrument the support copilot (from the Support copilot starter, or your own build) as a product, simulate an A/B test between two prompts or model configurations using evalkit and the experiment helpers, and write the decision memo with unit economics under three price scenarios. Keyless: the "experiment" runs on scripted data and the statistics run on the counts — the method is what transfers to real traffic.

This is lesson 13A.6 as a project: metrics that join product events to traces and evals, honest experiment arithmetic, the data flywheel, and cost-per-successful-task economics.

What you'll practise:

  • The metric tree: business outcome → usage → quality → experience → safety → cost, north-star and guardrail selection, vanity metrics and Goodhart's law (13A.6, Part 1 and Part 3)
  • Instrumentation: the product event schema, joining product events to traces and evals, privacy-aware analytics, the offline/online split (13A.6, Part 2)
  • Experimentation for LLM features: randomisation units, sample size by hand, the AI-specific traps, interleaving, shadow traffic, holdouts, model-upgrade experiments, reading results honestly, the decision memo (13A.6, Part 4)
  • The data flywheel: production traffic → labelled cases → eval sets → better prompts, and its biases (13A.6, Part 5)
  • Unit economics: cost per successful task, gross margin, pricing models, cost caps as product features, lever trade-offs (13A.6, Part 6)
  • Rollout strategy and roadmapping under uncertainty (13A.6, Parts 7–8)

Setup:

bash
uv init metrics-lab --bare --python 3.13 && cd metrics-lab
mkdir -p ai_product

metrics.py, experiment.py and unit_economics.py are pure standard library — copy them from 13A.6 and run python3 metrics.py events_sample.jsonl, python3 experiment.py demo, python3 unit_economics.py demo. Save the jsonl block in 13A.6, 2.4 as events_sample.jsonl. If you built the Support copilot starter, reuse its support_copilot stack and evals/; otherwise generate events from a fixture task set you write.

Steps:

  1. Write the metric spec. For your product, write the one-page spec from 13A.6, 3.7: a north-star tested against the four criteria in 1.3, three guardrails with thresholds and breach actions, five diagnostic metrics. Justify each — this document is the project's spine.
  2. Instrument the event stream. Define your product event schema per 13A.6, 2.2 — the JSONL fields metrics.py reads (feature, variant, event, outcome, session_id, user_hash, tenant_hash, latency_ms, edit_distance, cost_usd, judge_score, day). Emit events from your build's orchestrator (or generate a realistic synthetic stream with a script for the study). Join product events to trace IDs and eval case IDs so offline and online numbers reconcile.
  3. Run the aggregator. Feed your events through python3 metrics.py events.jsonl and --by day; compute acceptance rate, edit distance, escalation rate and p50/p95 latency per feature+variant. Add a third variant and re-run — does the treatment effect survive?
  4. Design the experiment. Write the design section of the decision memo per 13A.6, 4.1–4.4: what you randomise (user, session or conversation — justify), the AI-specific traps you're controlling (shared caches, novelty effects, silent model updates, interference), duration, guardrails, and the peeking policy. Compute the required sample with sample_size_per_arm for your baseline rate and MDE; if your traffic can't reach it, say so and design the interleaving or holdout alternative.
  5. Simulate the result. Generate a synthetic A/B result (binomial draws around your assumed rates, fixed seed) sized to your computed n, run two_proportion_z_test and bootstrap_prop_ci/bootstrap_diff_ci, and report the estimate with its interval — labelled as simulated, not measured. Also run mde_for_sample on your actual expected traffic to show what effect you could realistically detect.
  6. Slice honestly. Break the simulated result into slices (language, ticket type, tenant tier) and apply a multiple-comparisons correction; report underpowered slices as underpowered, not as wins or losses (13A.6, 4.7).
  7. Build the unit-economics sheet. Use unit_economics.py's TaskProfile/ModelPrice/cost_per_success/sensitivity_table/CostModel for your product under three price scenarios (the lesson's Exercise 7 works the support copilot at $0.75/$1.50/$2.50 per resolved ticket and a document profile at $4.00/document — adapt the numbers to your product). Vary success rate, attempts per task, cache hit rate and review sampling; find where gross margin goes negative and which single lever moves it most.
  8. Write the decision memo. Fill the template from 13A.6, 4.9: Question, Design, Results, Decision — with the caveats (simulated data, what real traffic would change, what you'd monitor post-ship).
  9. Plan the rollout. Write the stage-gate table (dogfood → private beta → staged rollout) with entry/success/exit criteria per 13A.6, Part 7, the most likely failure at each stage, and the rollback/freeze/hotfix plan for quality regression.
  10. Map the flywheel. Trace one feedback event from your product through feedback_to_evalkit into an eval case, through a prompt change, back to a metric — the loop that makes the product improve (13A.6, Part 5). Name the biases that could corrupt it (survivorship, position bias, feedback-loop bias).

Verify it, and what you should see:

bash
python3 metrics.py events.jsonl            # per-feature+variant table with p50/p95
python3 experiment.py demo                # z-test, bootstrap CI, sample-size examples
python3 unit_economics.py demo            # cost-per-success + sensitivity table
python3 your_study.py                     # your simulated A/B + economics sheet

Expected shapes (deterministic): metrics.py prints acceptance/edit-distance/escalation/latency rows per bucket; experiment.py prints z-statistic, p-value and CIs; unit_economics.py prints cost per started/successful task, gross margin and the sensitivity grid. Your simulated A/B should report an estimate with its interval and an explicit "underpowered" or "significant" call — never a bare percentage.

Done when:

  • The metric spec exists with a justified north-star, three guardrails and diagnostics.
  • events.jsonl (real or synthetic) runs through metrics.py and the numbers reconcile with your instrumentation claims.
  • The experiment design names the randomisation unit, controls the AI-specific traps, computes sample size, and states its peeking policy.
  • The simulated result reports estimate + interval + slice analysis with underpowered slices marked.
  • The unit-economics sheet covers three price scenarios, finds the negative-margin region, and names the most powerful lever.
  • The decision memo follows the template and says what the simulation cannot tell you.

Stretch ideas: Run the experiment for real on your own product's dogfood traffic if you have users — same code, real counts. Add interleaving for prompt comparison (13A.6, 4.5). Instrument a second product shape (document pipeline or voice) and compare metric trees. Hosted, needs keys: swap CannedModel for a real provider on a small golden set and compare eval scores as the "quality" arm of the economics.

Common problems:

  • Thumbs-up as the north-star — Goodhart's law applies doubly to AI metrics; a metric that can be gamed by agreeing more will be (13A.6, 1.6).
  • Peeking — checking the experiment daily and stopping when it "looks significant" inflates false positives; pre-register the sample size and the decision rule.
  • Cost per call instead of cost per successful task — retries, failures and human review are the real cost; cost_per_success exists precisely for this.
  • Ignoring shared caches in A/B — a treatment that changes the prompt invalidates cached prefixes differently per arm; the experiment design must account for it (13A.6, 4.4).
  • Simulated data presented as measurement — label it; the method transfers, the numbers don't.

Optional

Optional: Case-study dossier#

Goal: Build a reusable dossier of five well-sourced AI-product case cards plus a pattern matrix mapping them to the module's patterns — the 13A.7 method applied to products of your choosing. Fully keyless: reading, analysis and pure-local Python.

This is lesson 13A.7 as a project. The lesson covers twelve cases; your dossier covers five you choose — which is the real exercise, because it forces source discovery, not summarising.

What you'll practise:

  • Critical reading: source-quality ladders, dissecting a claim (who measured, denominator, baseline, date, beneficiary), survivorship bias, "what is public vs claimed vs unknown" (13A.7, Part 1)
  • The case study card: problem, users, public system description, UX decisions, reported metrics, what went wrong, what transfers, dated sources (13A.7, 1.5)
  • ai_product/case_card.py: CaseCard, Source, Outcome, Shape, check() (warns about missing metrics, suspiciously clean success cards, failure cards that do not say what went wrong, and single-source cards; the model itself rejects a claim with no source URL and date) and render() (13A.7, 6.1)
  • Cross-case analysis: the pattern matrix mapping cases to 13A.2–13A.6's patterns, and failure→control mapping (13A.7, Part 5)
  • The pre-mortem: apply the failure analysis to your own capstone (13A.7, Exercise 7)

Setup:

bash
uv init case-dossier --bare --python 3.13 && cd case-dossier
uv add pydantic
mkdir -p ai_product cards

Copy case_card.py from 13A.7, 6.1. No keys, no services — you will do real web research; every source must be one you open yourself.

Steps:

  1. Choose five cases. Pick products not covered in the lesson's twelve — or re-card two of them from scratch as a calibration exercise. Balance across shapes (copilot, assistant, agent, voice, document, internal tool) and outcomes (success, mixed, failure). The AI Incident Database (incidentdatabase.ai) is the graveyard for failures.
  2. Research each case. For each, find the primary sources: engineering blogs, official announcements, court/regulator documents, reputable reporting. Open and read them — a source you haven't opened doesn't count. Record URL, publication date, access date, and the exact claim as reported for every metric.
  3. Write the cards. Fill the template from 13A.7, 1.5 for each case as cards/<slug>.json, using the CaseCard fields from 13A.7, 6.1: problem, system as publicly described (mark "not public" where the record is silent — never extrapolate architecture), metrics as reported (with denominators and baselines), what went wrong, lessons that transfer, and the sources with URL and date. A claim without a source URL and date is rejected when you build the card. Load each file into CaseCard, run check() and fix every warning, then write card.render() to cards/<slug>.md for reading.
  4. Build the pattern matrix. Map each case to the module's patterns: which 13A.2 streaming/latency choices, 13A.3 trust/control patterns, 13A.4 failure states, 13A.5 architecture patterns and 13A.6 metrics/economics does the public record show? A blank cell is an answer too — it means the record doesn't say.
  5. Draw the cross-cutting lessons. What do the successes share? What do the failures share? For each failure, name the control that would have prevented or limited it (the 13A.7, 5.4 table is the checklist; links go to 08A.14, 12.x, 13.x).
  6. Pre-mortem your capstone. Assume your own product failed publicly in six months. Write the blameless postmortem and map each imagined failure to a control — if your list only says "we'll prompt it better", you haven't found anything yet.
  7. Write the dossier index. cards/README.md: the five cards, the pattern matrix, the lessons, and — honestly — which claims rest on a single source and which products you could not verify well enough to card.

Verify it, and what you should see:

bash
uv run python -c "
from ai_product.case_card import CaseCard
import json, glob
for f in sorted(glob.glob('cards/*.json')):
    card = CaseCard.model_validate(json.load(open(f)))
    print(card.title, '|', card.outcome.value, '|', card.shape.value, '| warnings:', card.check())
"

Each card renders to Markdown via card.render(); check() returns warnings for missing metrics, suspiciously clean success cards, failure cards that do not say what went wrong, and single-source cards — a clean dossier has zero warnings or only argued ones.

Done when:

  • Five cards exist, each with sourced, dated claims and explicit "not public"/"unknown" markers.
  • CaseCard.check() passes (or every warning is justified in the card).
  • The pattern matrix maps cases to specific 13A.2–13A.6 patterns, not vague themes.
  • Every failure case names the control that would have caught it.
  • The pre-mortem for your own product produces at least three non-prompt controls.
  • The index states which claims are single-sourced and which products you rejected for weak sourcing.

Stretch ideas: Card a product in a domain you care about deeply (health-adjacent, finance, education) and compare its controls to a general assistant. Add a sixth card from the AI Incident Database and do the failure→control mapping in depth. Write a "how I verified this" appendix per card — the source-discovery trail is the reusable skill.

Common problems:

  • Citing a source you didn't open — the lesson's hard rule; if you can't fetch it, it doesn't count. Use the wayback machine or find the primary.
  • Presenting company claims as measurements — "Klarna's AI does the work of 700 agents" is a claim with a date and an incentive, not a benchmark; the card format forces you to label it.
  • Survivorship bias — only reading successes teaches nothing; at least two of your five should be mixed or failure cases.
  • Extrapolating architecture — "they must use RAG because..." is invention; write "not public".
  • Letting check() warnings slide — a single-source card presented as settled, or a success story with no failure modes, undermines a portfolio dossier; the validator exists for a reason.

Esc
02.2Tokens and TokenizationHow LLMs Work · 21k wordsLesson
02.3EmbeddingsHow LLMs Work · 18k wordsLesson
07Retrieval-Augmented Generation (RAG)11 lessons · Everyone who will build LLM features that must answer from knowledge the model doesn't have in its weights: internal handbooks and help centres, contracts, ticket histories, product docs, or any corpus that changes faster than a training run. The module covers the full RAG stack — architecture, retrieval strategy, query understanding, grounded generation, citations, conversation, managed services, advanced patterns, evaluation, debugging and production operation — and shows where each major provider's managed retrieval and citation features fit (OpenAI, Anthropic, Google Gemini and OpenRouter). All code is Python.Overview
08E.1The Model Context Protocol (MCP)Protocols and Extensibility · 12k wordsLesson
↑ ↓ navigate↵ openesc close