AI Engineering from Scratch / Stage 1. The task, the workspace and the process
The card logic moves from `index.html` into a Python service you start with one command, read line by line and roll back to a working version through Git.
Outcome: a service + tests + 3 cases
For this lesson you need: the starter with the lesson-02 branch where uv run pytest is green (pytest is a program that runs your tests with one command, more on it below); the card prototype and the 3 checks in KB.md from lesson 1; the "check before commit" skill from lesson 2. At the start of the lesson, in the starter folder:
If the second command says error: pathspec ... did not match, you don't have cases of your own yet, and that's fine. If it says fatal: invalid reference: lesson-02, you don't have a lesson-02 branch because lesson 2 went differently for you. Then skip the second command. If git switch refuses because of uncommitted changes, commit them first in the lesson 2 branch: git add -A, then git commit -m "кінець уроку 2". A commit is a snapshot of the project saved in Git, more on it in the "Git" step below.
This command creates your copy of the project for lesson 3. You don't need to understand tags and branches for this lesson.
The new branch starts from the finished example: the web/index.html page from the l01 tag and the same 3 checks in KB.md that are written in the contract. Your version of the page from lesson 1 hasn't gone anywhere, it's in the lesson-01 branch. Working on your own idea in my-first-product? Today you do the move on the card, and you move your own prototype after the lesson, see the "In your project" block at the end.
What changed in the contract. Card v1 is now computed by Python: make_card_rules(ticket) returns a CardResult with the fields status, ticket_id, order_id and missing, and normalize_order_id turns the number into the DEMO-1042 form. The page sends text to POST /api/card (that's the service's address, we'll go through it in the step about the move) and only displays the response. The service doesn't accept a customer_id field in the request; it takes the customer from the session, meaning whoever is currently logged in as the operator. Until there's a login, customer_id is the constant c-17. New in this lesson: evals/cases.jsonl with cases c001, c002, c003, and the add-case command for your own cases in evals/own.jsonl.
Remember lesson 1. What counted as proof that the prototype works?
The lesson 1 prototype keeps its logic in the browser. Anyone who presses F12 can see the model key there, and someone could pay for their own requests with your key. And you can't run a function in the browser with a command, so after every agent edit the checks are manual, until the day you skip them. That's why the logic has to move into a Python service. A service is a program that runs on your computer (later on a server), takes a request from the page and returns a card. Next to it live tests that run the checks in a second, and Git, which brings back a working version when the agent breaks something.