Production REST API capstone
Production REST API capstone
“Production-oriented” is not a universal guarantee. Requirements depend on traffic, data sensitivity, regulations, infrastructure, and failure budget. This capstone makes those decisions explicit and testable.
What you will learn
- define service boundaries and threat assumptions;
- design database and HTTP contracts together;
- add authentication without storing raw credentials or tokens;
- connect logs, metrics, traces, and health signals;
- plan migrations, shutdown, rollback, and release evidence.
Scope and architecture
Build a multi-user task API. Users register and sign in; authenticated users manage only their tasks; list endpoints paginate and filter; PostgreSQL stores data; and the process exposes health and telemetry. Leave email, OAuth, teams, and a browser UI out of version one.
client -> HTTP router and middleware -> task/auth services
-> repository interfaces -> PostgreSQL
configuration -> application wiring
requests -> logs + metrics + traces
signals -> readiness + graceful shutdown
Dependencies point inward. Transactions live in the layer that understands the complete business operation.
Threat model and milestones
Document assets, actors, trust boundaries, risks, controls, and remaining risk. Include injection, broken object-level authorization, credential guessing, token theft, denial of service, and secret leakage. Security is ongoing: maintain dependencies and define a patch process.
Build in reviewable milestones: migrations; repository integration tests; authentication and ownership; task handlers and pagination; observability and health; then shutdown and a release runbook.
Practice
How should PATCH /tasks/{id} prevent one user from changing another user's task?
WHERE id = $1 AND owner_id = $2. Put the rule in the service/repository operation and query, not only middleware, so every caller gets the protection.Summary
- Define scope, boundaries, and operational expectations before coding.
- Authorisation belongs beside the protected operation.
- Transactions, telemetry, migrations, and shutdown are design concerns.
- Production readiness is evidence against requirements, not a label.
Ready to wrap up?
Mark this complete when you can explain the main idea and finish the practice task.