Week 1

Stage 4 · Weeks 25–29 · software

Web + HTTP + APIs

Build, containerize and deploy an API

Locked

Scored stage progress

0%

Practice and implementation

0/15

Exercises + milestone requirements owned by this stage

Evidence and gate

0 · 0/12

Artifacts · checked requirements

Why it matters

Purpose of this stage

Build, containerize and deploy an API

Subjects

8 subjects · 57 canonical topics

Each subject states what you should be able to do, an order to work through it in, what to watch for, and the questions a reviewer should be able to ask you at the end. None of it is tracked or scored.

How to work through this subject

An order that works, not a checklist. Nothing here is tracked — the steps sequence this subject’s own topics and add none.

  1. Take one URL apart into scheme, hostname, port and path, and say what each part decides.
  2. Send the same request with a tool that shows you headers and body, and read the raw response.
  3. Try each HTTP method against something safe and note which ones are meant to change state.
  4. Read a handful of status codes and sort them into 'caller was wrong' and 'we were wrong'.
  5. Send JSON as a request body and read JSON back, noticing that both are just text with a content type.
  6. Finish by drawing the full path of one request — client, DNS, port, route, application logic, database, response — and narrating it end to end.

What to watch for

  • Status codes are a contract. 4xx means the caller was wrong; 5xx means you were.
  • Statelessness is why authentication has to be re-established on every request.
  • Headers carry metadata about the message; the body carries the message. Putting one in the other is a common design mistake.
  • REST conventions are conventions, not rules enforced by anything. Their value is that callers can guess correctly.
  • JSON is text. Nothing about it is typed until your code decides what the text means.
  • DNS turns a name into an address before any request is sent. When something is unreachable, that is the first hop to check.

Curriculum topics

client/server
The two roles in a network exchange: one asks, the other answers.
hostname
The name of the machine you are connecting to, resolved to an address before the connection.
port
A number identifying which program on a machine a connection is for, so one machine can run many servers.
DNS intuition
The system that turns a domain name into an IP address.
HTTP methods
The verb of a request — GET, POST, PUT, DELETE — declaring what kind of action is intended.
URL
The full address of a resource, including scheme, host, path and query string.
headers
Metadata sent alongside a request or response — content type, authentication, caching.
body
The payload of a request or response, as opposed to its metadata.
JSON
A text format for nested data that preserves types and structure, unlike CSV.
request
What the client sends: a method, a URL, headers and optionally a body.
response
What the server sends back: a status code, headers and optionally a body.
status code
The three-digit result of a request. 2xx succeeded, 4xx means the caller was wrong, 5xx means the server was.
statelessness
HTTP remembers nothing between requests, so identity must be re-established on every one.
REST conventions
A common style for API design: resources as URLs, HTTP methods as the actions on them.

Resources for this subject

  • REFERENCEHTTP MDN Web Docs
    The practical reference for methods, status codes and headers. The source's framework rule is to learn HTTP before framework magic — this is that material.
    Open
Need another explanation?1 more reference
  • OPTIONALRFC 9110 — HTTP Semantics IETF
    The specification itself. Consult for a precise answer on method semantics or idempotency; do not read end to end.
    Open

A reviewer should be able to answer these

Answer from memory, out loud, before moving on. These are not tracked and do not affect the gate — they tell you whether you actually understand this subject.

  1. What does 'HTTP is stateless' mean for how you authenticate a user?
  2. What is the difference between a 400 and a 500, and who is responsible for each?
  3. When would you use PUT instead of POST?
  4. What is the difference between a header and the body, and what belongs in each?
  5. What does the client actually send when it requests a URL?
  6. What do the parts of a URL each determine about where the request goes?
  7. What does DNS resolve, and what happens if it resolves to the wrong address?
  8. Which HTTP methods are expected to be safe to repeat, and why does that expectation matter?

Exercises

Demonstrated practice · 35% base weight
This stage defines implementation through its owned project milestone rather than a separate exercise list.

Stage project

Only milestones owned by Stage 4 count here

P2 · Multi-stage project

Expense Backend

Project detail

P2.M3 · REST API

Resources

0% progress weight

Resource status is a convenience marker only. It cannot change competencies, gates, or stage completion — in any tier below.

Start here

PRIMARY

FastAPI Tutorial

FastAPI

The framework tutorial, in order, from first app to dependencies and testing. Build it against the database you designed in Stage 3 rather than the tutorial's toy data.

Need another explanation?8 supplementary resources · not part of the canonical library

Use these for a demonstrated gap, not as a parallel course. They are authored additions and can never be the primary resource for a subject.

  • REFERENCELogging HOWTO Python Software FoundationHow to replace prints with real logging: levels, formatting, and where output goes. The cookbook covers attaching request context, which is what makes a deployed failure findable.Open Open
  • REFERENCEHTTP MDN Web DocsThe practical reference for methods, status codes and headers. The source's framework rule is to learn HTTP before framework magic — this is that material.Open
  • REFERENCEPydantic documentation PydanticFastAPI's validation layer, and the thing doing the work when a request is rejected. Also reappears for structured LLM output in Stage 11.Open
  • OPTIONALRFC 9110 — HTTP Semantics IETFThe specification itself. Consult for a precise answer on method semantics or idempotency; do not read end to end.Open
  • REFERENCEOpenAPI Specification OpenAPI InitiativeWhat FastAPI generates on your behalf. Reading it turns the generated docs from output into a design surface.Open
  • REFERENCEDocker — Get started DockerContainers from zero, plus FastAPI's own deployment guide for the exact service you are packaging.Bound to Stage 4, where containers are first taught, and reused in Stage 12 for ML packaging.Open Open
  • REFERENCEThe Twelve-Factor App 12factor.netWhere the rule that configuration comes from the environment originates. Short, and it settles most config-versus-secret arguments. Its logs, disposability and dev/prod-parity factors are the deployment half of this stage.Open
  • REFERENCEGitHub Actions documentation GitHubThe CI system this roadmap uses. Stage 4 needs only install, lint and test; Stage 12 adds data and model checks.Open

Stage gate

Readiness assessment

Not ready

Stage-specific requirements

Answer each prompt without notes. Expand a question only when you are ready to check your answer.
0/4
  • Explain the full flow: client → HTTP request → route → application logic → database → response
    Answer

    The client resolves the hostname to an address and opens a connection to a port, then sends an HTTP request with a method, path, headers and possibly a body. The server matches the path to a route, the handler validates the input, application logic runs and queries the database, and the result is serialized into a response with a status code and body. The connection carries no memory of previous requests, so anything the server needs to know arrives with each one.

  • Debug 4xx vs 5xx errors
    Answer

    A 4xx status says the request was wrong: bad input, missing authentication, insufficient permission, or a resource that does not exist, and the fix belongs with the caller. A 5xx says the server failed while handling a request it accepted, and the fix belongs with you. Diagnose 4xx from the request itself, and 5xx from your own logs and stack traces for that request.

  • Build and run the service in a container
    Answer

    Write a Dockerfile that installs dependencies and states the command to run, build it into an image, then run the image as a container with the port mapped and the configuration supplied as environment variables. The image is the artifact and the container is the running instance. Nothing secret goes into the image, and anything written inside the container is gone when it is replaced.

  • Explain what differs between your local and deployed environments
    Answer

    The deployed environment differs in configuration, filesystem, network and often resources. Environment variables that exist on your machine may be absent there, paths and ports differ, outbound and inbound access is restricted, and the deployed instance is reachable by anyone. Most first-deploy failures are a missing environment variable or a port the platform did not expect, which is why the logs are the first place to look.

Universal requirements

The eight conditions 01_LEARNING_RULES.md applies to every stage. Expand one to see what it actually asks for.
0/8
  • Core concepts can be explained from memory.
    What this asks for

    Every subject in this stage has review questions. The condition is met when you can answer them out loud, without notes and without looking anything up, in your own words rather than a recited definition. An explanation you can only give with the material open is recognition, not recall.

  • Required exercises are complete.
    What this asks for

    Complete means each exercise satisfies its stated requirements and its done-when criteria, not that you attempted it. Where an exercise says you should be able to explain or defend something, that explanation is part of completing it. A stage whose source lists no exercises meets this through its owned project milestone instead.

  • Stage project works.
    What this asks for

    Works means it runs end to end from a clean checkout, on the inputs it was built for, with the failure cases it claims to handle actually handled. It is not a notebook that produced a result once. Someone else following your README should be able to run it without asking you a question.

  • Tests or verification exist.
    What this asks for

    There is something that would fail if the behaviour regressed, and you have watched it fail. That can be automated tests or a written verification procedure with recorded results, depending on what the stage produces. A test that has only ever passed is evidence of nothing.

  • README explains decisions.
    What this asks for

    The README says what the project is, how to install, run and test it, and why it is built the way it is: the choices you made, the alternatives you rejected, and what you deliberately left out. A list of commands with no reasoning does not meet this condition.

  • You can reproduce the core implementation without copying.
    What this asks for

    Delete the central piece and write it again from an empty file, without your previous version, a tutorial, or generated code in front of you. It does not have to be identical, it has to work and you have to be able to explain every line. This is the condition that separates having finished from being able.

  • You pass the stage self-assessment at >= 80%.
    What this asks for

    Record a gate exam and score yourself honestly against the dimensions the roadmap defines: recall, implementation, debugging, testing and design judgment. Elapsed time, hours watched and completed resources count for nothing here. Checking the boxes without a recorded exam does not open the gate.

  • Claude/ChatGPT reviewer finds no foundational blocker.
    What this asks for

    Ask an AI reviewer to examine the work against this stage's concepts and report foundational misunderstandings, not style. A foundational blocker is a misconception that later stages would build on, such as leakage, a broken abstraction, or an explanation that is confidently wrong. Nothing in that class may remain open when you pass.

Recorded exam

No exam recorded. Checking every requirement is not sufficient.

Evidence

Artifacts linked to this stage

Add evidence
No stage evidence yet.