By Kevin McAleer, 5 Minutes
Page last updated November 24, 2026

By the end of this lesson you will be able to describe how every part of the Robot Telemetry API fits together, and choose what to build or learn next.
Well done makers, you now have a real, protected web API. Here is the whole project, file by file:
| File | Job | Lesson |
|---|---|---|
main.py |
Creates the app, lifespan, CORS and plugs in the routers | 2, 5, 8 |
models.py |
Pydantic v2 models for readings, users, tokens and LED commands | 3, 5 |
db.py |
SQLite tables and the get_db dependency |
5 |
security.py |
Password hashing and signed tokens | 4, 6 |
deps.py |
CurrentUser and AdminUser dependencies |
6 |
auth.py |
/register and /token |
6 |
readings.py, leds.py, users.py |
The robot’s data, the robot’s LEDs and user management | 3, 7 |
settings.py |
Secrets and options from the environment | 9 |
dashboard.html |
A static page that talks to the API | 8 |
flowchart TD
subgraph Browser
D[dashboard.html on Jekyll]
end
subgraph Robot
P[Pico W or fake_robot.py]
end
subgraph API[FastAPI app]
M[main.py and CORS] --> AU[auth.py]
M --> RD[readings.py]
M --> LD[leds.py]
M --> US[users.py]
AU --> SE[security.py]
RD --> DP[deps.py]
LD --> DP
US --> DP
DP --> SE
end
D --> M
P --> M
API --> DB[(SQLite)]
ST[settings.py] --> API
Annotated rules stop bad data before your code sees it.CurrentUser and AdminUser keep routes short, and make forgetting a check hard.Teachers: This summary works well as a short review session of 30 to 45 minutes. Ask groups to explain one request, such as “a learner switches on the red LED”, by tracing it through the files in the table above. Marking is easier if you ask for a diagram, not code.
The official FastAPI documentation has excellent guides on background tasks, WebSockets and testing, all of which suit robot projects.
PUT /leds/red request passes through, in order, from the browser to the response.GET /readings/summary route returning the minimum, maximum and average value per sensor.TestClient from fastapi.testclient to write a test that checks POST /readings with no token returns 401./docs, where you see the exact request and response.Why: The last lines of a traceback name the real error, and /docs shows what the server received.
requirements.txt (as in lesson 9) and upgrade one package at a time.Quick quiz 1 of 3
Which file turns a token into the logged-in user?
get_current_user in deps.py decodes the token and looks the user up. security.py only checks the token itself.Quick quiz 2 of 3
Which is the safest place for the secret key?
Quick quiz 3 of 3
A robot sends a valid token for a user who has since been deleted. What happens?
Comments