Skip to content
Aabha AI Academy

Stage 1 · L01

Why the Equipment Rental API exists

Core · original Session 1 plus essential local Git/Docker setup

Native checkpoint 01

Download starter

Use the starter for this stage's focused examples. The cumulative transfer and solution belong at the stage-end capstone. Baseline checks pass; transfer checks initially fail. Downloads contain the matching native starter and solution for this stage.

A rental desk needs to read its catalogue before it can reserve anything. Equipment is the resource: each item has an identifier, a name and a stock quantity. A client chooses an HTTP method and path; the application decides how to answer. GET /equipment/1 asks for one existing item and must leave all rental state unchanged. Later, a reservation will deliberately write a rental row and enforce capacity and actor permissions.

The first snapshot is deliberately small enough to follow end to end. equipment/api.py defines two synthetic catalogue records and a FastAPI application. Its GET handler returns the matching record as JSON. This is a real HTTP API, but the catalogue lives in Python process memory. Restarting the process reconstructs those two records. It is not persistent storage, a capacity calculation, or a booking system.

Run the stage-01 application and compare the response at / with /equipment/1. A browser, curl, and a test client can use the same contract. The browser UI is a client; the API is the agreed interaction boundary. The backend includes routing, decisions, storage access and integration work behind that boundary. These responsibilities may share one deployment; separate containers do not by themselves establish a microservice design.

The stage-end capstone adds a read-only availability resource. At this stage available equals the synthetic stock quantity because no rentals exist. Name that limitation in your explanation. Reuse get_equipment so a missing item remains 404 and a nonnumeric identifier remains 422. Do not silently add booking behavior to a read route. The transfer tests check the real endpoint, method and response fields.

Client: GET /equipment/1; Uvicorn: HTTP → ASGI; FastAPI: path → integer 1; Handler: find Tripod fixture; Response: 200 JSON; Stage 01 has no stored rentals.
Client: GET /equipment/1; Uvicorn: HTTP → ASGI; FastAPI: path → integer 1; Handler: find Tripod fixture; Response: 200 JSON; Stage 01 has no stored rentals.

Follow the running code

Focused lesson example; see the end-of-stage capstone for the cumulative app · stage 01

GET /equipment/1 → item 1
GET /equipment/999 → 404
A restart reconstructs the two synthetic catalogue entries.

Predict and observe this focused example using the concepts explained above. Its boundary is stated in the focused answer.

Guided lab

  1. Read the explanation and predict the focused example’s outcome.
  2. Read item 1 and a missing item. Explain whether either GET creates a reservation.
  3. Compare the observed outcome with the focused answer and state its boundary.

Expected: Item 1 returns Tripod and quantity 2; a missing item returns 404. Both are reads. Stock in this first snapshot is process memory, and no reservation exists.

  • Unknown equipment → 404; words in the integer path → 422; POST to the read route → 405.

Focused exercise and answer

Complete this focused exercise before reading its answer. The full native transfer is introduced only at the end of the stage.

Your transfer task: Read item 1 and a missing item. Explain whether either GET creates a reservation.

  1. Read item 1 and a missing item. Explain whether either GET creates a reservation.
Inspect the matching answer

This answer addresses the focused exercise above; the cumulative implementation is shown only after the stage prerequisites.

Item 1 returns Tripod and quantity 2; a missing item returns 404. Both are reads. Stock in this first snapshot is process memory, and no reservation exists.

Check your reasoning

What survives a stage-01 server restart?

Show the explanation

The code and its two declared fixture records. A change made only to process memory is reconstructed on restart; PostgreSQL persistence arrives in stage 02.

Reading progress

54 lessons remain open to guests. Marking a lesson read records reading only; it does not award assessment credit or a certificate.

Device reading marks require browser storage. Reading is always available.

Sign in or create an account to save separate account progress. Your current page is kept.