AI-Assisted Coding · Module 02

From Idea to Backend Implementation with AI

The AI drafts the backend; you make it correct.

Six lessons that turn the Module 1 FastAPI skeleton into a working Task Tracker backend inside Cursor IDE: a strict Pydantic data model, five CRUD endpoints built one prompt at a time, status-transition business rules, and a pytest suite you prove with a Break Test.

  • Cursor IDE
  • Pydantic v2 model
  • CRUD endpoints
  • Status transitions
  • pytest
  • Break Test

Module introduction

One repo, five connected parts

In Module 1 you ended with a FastAPI skeleton and a single /health endpoint. Module 2 turns it into a real backend. The AI moves out of the browser and into the editor, where it can read your actual files. You then build in a fixed order: the data model every endpoint depends on, the five CRUD endpoints one at a time, the business rule that decides which status changes are allowed, and finally a test suite you trust only after you have broken the code and watched the right tests fail. Each part ends at a verification gate, and you don’t move on until it passes. The thread running through all of it is the same: strict prompt, review, verification, targeted correction. Cursor can draft code, but you own correctness.

The five parts and their verification gates · Lecture notes p. 2
  1. 2.0Define the toolCursor reads the repo; /health returns 200.
  2. 2.1Data modelmodels.py and storage.py; verify_a.py all PASS.
  3. 2.2CRUD endpointsFive routes; curl and /docs confirm codes.
  4. 2.3Business logicTransition matrix: 200, 200, 422, 200, 422, 200.
  5. 2.4API testspytest green, then the Break Test fails the right tests.

Your learning path

Six lessons, one continuous build

Open source guide
01Cursor IDEModule 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.12 min02Data modelEvery 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.15 min03CRUD endpointsThe 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.15 min04Status transitionsA 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.12 min05API testsCursor 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.15 min06DeliverablesModule 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.10 minWhat you keep from Module 2Module 2 turns a one-endpoint skeleton into a tested backend, one strict prompt and one verification gate at a time, and ends with proof that the tests protect what they claim to.SummaryPrompt library20 prompts, each as a weak and an improved version: From Idea to Backend Implementation with AIPrompts