Original source guide

Module 2 · From Idea to Backend Implementation with AI

Where each lesson comes from, what was not supplied, and the places where the material needs a careful reading.

The sources

This module is built from two supplied PDFs: the Module 2 lecture notes (11 pages), which cover the purpose and outcomes, the Cursor IDE setup and the four build parts (data model, CRUD endpoints, status transitions, API tests) with their deliverables; and the Module 2 prompt library (23 pages), which holds 20 prompt cards from T0.1 to O2 with weak and improved versions. No reading list was supplied for Module 2, so this module has no reading page. The Module 2 videos and the hands-on guide the notes say they accompany were not supplied, and neither were the verify_a.py script or the transition-matrix script the notes describe. A few cautions also draw on the author’s own Module 2 work in the course repository, and say so where they do.

Listening

Every page in this course is read aloud by your device’s own voice. No recorded narration was generated for it. Back to the lessons

Where each lesson comes from
LessonLecture notesPrompt library
1 · The editor as the AI workspacepp. 1-3pp. 1-3 (intro, T0.1, T0.2)
2 · The data model is the contractpp. 3-5pp. 3-7 (A1–A3)
3 · One endpoint per promptpp. 5-7pp. 7-14 (B1–B3)
4 · Status transitions are a business rulepp. 7-8pp. 14-16 (C1, C2)
5 · Tests that can failpp. 8-10pp. 16-20 (D1–D3)
6 · Deliverables, logs and the bridgepp. 10-11pp. 20-23 (E1, E2, O1, O2)

Lesson 01

The editor as the AI workspace

Module 2 moves the assistant into the editor, because the work now happens inside real project files. Before any code is generated, you prove the assistant can read app/main.py and explain the /health endpoint correctly.

Open the lesson
Module purpose and learning outcomes

From skeleton to backend; the eight outcomes; pause after each demo until verification passes.

Lecture notes p. 1
Module at a glance

The five-part table and the thread: strict prompt, review, verification, targeted correction.

Lecture notes p. 2
Part 1 — Define the tool: Cursor IDE

Why the AI moves into the editor, the setup checklist and the first verified interaction.

Lecture notes pp. 2-3
How to use the library and core principles

Ask, inspect, run, test, refine; the conventions table; the five principles.

Prompt library pp. 1-2
T0.1 and T0.2

Explain /health; confirm project context before a code-generation prompt.

Prompt library pp. 2-3

Lesson 02

The data model is the contract

Every endpoint is built on the data model, so it comes first and it is strict: Pydantic v2 models, enums for status and priority, a validated title, no extra fields, and server-managed fields kept out of client input. An eight-check script proves it before you move on.

Open the lesson
Part 2.1 — Goal and core model expectations

Why the model is the contract; the four goals; the elements table.

Lecture notes pp. 3-4
Prompt A1 review and import check

Five checks before applying; the one-line import command.

Lecture notes p. 4
Verification A

The eight checks verify_a.py should print as PASS.

Lecture notes p. 4
Common AI mistakes and what you leave with

Six model-layer mistakes; the Part 2.1 outputs.

Lecture notes p. 5
A1, A2 and A3

Generate models and storage; fix model validation; fix storage or import failures.

Prompt library pp. 3-7

Lesson 03

One endpoint per prompt

The API comes alive one route at a time: POST, GET list, GET by id, PATCH, DELETE, each from its own strict prompt and each verified with curl or Swagger before the next. A vague-versus-strict experiment on POST shows why.

Open the lesson
Part 2.2 — One endpoint per prompt

The teaching rule and the vague-versus-strict experiment.

Lecture notes p. 5
Endpoint build order and review checklist

The five routes with expected behavior and verification focus; six review points.

Lecture notes p. 6
Common AI mistakes and what you leave with

Six endpoint mistakes; the Part 2.2 outputs.

Lecture notes pp. 6-7
B1 and B2.1 to B2.4

The POST experiment and one strict prompt per remaining route.

Prompt library pp. 7-13
B3

Fix endpoint verification failures with expected-versus-actual evidence.

Prompt library pp. 13-14

Lesson 04

Status transitions are a business rule

A PATCH route that sets a field is not a business rule. The backend decides whether a status change is allowed from the pair of current and new status, using a small set of allowed transitions, and returns 422 for anything else.

Open the lesson
Part 2.3 — Why this belongs in the backend

Field setter versus business rule; the backend as enforcement point.

Lecture notes p. 7
Transition rules and Prompt C1

The six-row table and what C1 must create and review.

Lecture notes pp. 7-8
Verification C and common mistakes

The six-test matrix and five business-rule mistakes.

Lecture notes p. 8
C1 and C2

Add status-transition validation; fix transition matrix failures.

Prompt library pp. 14-16

Lesson 05

Tests that can fail: pytest and the Break Test

Cursor can generate tests with good names and plausible assertions, but a green suite proves nothing on its own. You review the generated tests, run them, then deliberately break production code and confirm the right tests fail.

Open the lesson
Part 2.4 — Core testing principle and Prompt D1

A test that passes when the code is broken is lying; fixtures and 16 or more named tests.

Lecture notes pp. 8-9
Review before running and expected coverage

Six review points; the coverage table; the pytest commands.

Lecture notes p. 9
The Break Test

Five steps, what to do if it doesn’t fail, and six test-generation mistakes.

Lecture notes p. 10
D1, D2 and D3

Generate the suite; fix failures with test-versus-production reasoning; diagnose Break Test results.

Prompt library pp. 16-20

Lesson 06

Deliverables, logs and the bridge to Module 3

Module 2 ends with three kinds of evidence: code, verification results, and three short logs that record what you prompted, what you corrected and what you learned. Then the same loop carries into the frontend.

Open the lesson
Module 2 deliverables

Code, verification and documentation deliverables.

Lecture notes pp. 10-11
Closing and bridge to Module 3

From skeleton to backend; the AI drafted it, you made it correct.

Lecture notes p. 11
E1 and E2

Prompt comparison log and reflection log.

Prompt library pp. 20-22
O1 and O2

Optional: explain warnings; produce an API summary checklist.

Prompt library pp. 22-23

Source appendix

Where the material needs a careful reading

Read with care

Videos and hands-on guide not supplied

The notes are written to be used while watching the Module 2 videos and completing a hands-on guide (p. 1). Neither was supplied, so nothing here is attributed to them.

Prompt labels differ between the documents

The notes mention a label “B1b” (p. 1); the prompt library has no B1b, and B1 holds both the weak and strict POST prompts. The notes also say the exact prompt text should be kept in the library “when that resource is updated”, so the two documents were written at different moments.

Scripts described, not printed

tests/verify_a.py (eight checks, p. 4) and the six-check transition sequence (p. 8) are described but not printed. You write or obtain them yourself.

How many tests

The notes ask for “16 or more” tests (p. 9); D1 names 17 (pp. 17-18). The author’s own suite reached 19. Treat 16 as the floor, not a target.

A transition the table doesn’t list

The notes’ transition table (p. 7) doesn’t mention InProgress -> ToDo. C1’s set of allowed pairs leaves it out, so the rule rejects it; the lessons follow C1.

Python version and union syntax

B2.1 writes query parameters as “TaskStatus | None = None” (p. 9), which needs Python 3.10 or later. The author’s Module 2 log records a startup crash on a Python 3.9 environment from exactly this. That is an observation from the author’s work, not from the PDFs.

How many tests the Break Test fails

The notes say the invalid-transition test should fail when the validator is removed (p. 10) and, in the deliverables, “at least” that test (p. 11). With D1’s suite the same-status test also depends on the validator, so two failures are expected; the author observed exactly two.

Tool descriptions are dated

Cursor’s file chips, @ references and Apply in Editor, and Copilot Chat’s # references, are described as the documents saw them in the recorded demo. The author worked through the module with a different editor assistant, adapting the library’s prompts. Check your own tool’s current behavior.

Framework names as printed

Status-code constants such as status.HTTP_422_UNPROCESSABLE_ENTITY and package pins such as pytest>=8 and httpx>=0.27 are reproduced as the documents print them, at their date.

Checked against the supplied documents cited in each note.

What not to take away

The lessons actively work against these misreadings:

  • If the code runs, it is correct.
  • Asking for all the endpoints at once saves time.
  • A browser chat assistant knows your project structure.
  • Plain strings are fine for status and priority.
  • Clients may send their own id and timestamps if they want to.
  • Checking that the new status is a valid enum value is enough.
  • Hiding invalid buttons in the UI enforces the rule.
  • An empty filter result should return 404.
  • A green test suite proves the code works.
  • When a test fails, change the assertion until it passes.
  • If the Break Test doesn’t fail, the production code needs fixing.

Study-guide synthesis; each item is addressed in the lessons.