Study interactive :: Progress tools open in the Study Hub reader.

Phase E: Advanced Backend Engineering (In-Repo Lessons)

Maps to: Blueprint Phase E

Goal: Handle money, files, background work, and failure modes without turning your codebase into copy-pasted routes.


Table of Contents


Lesson 1: Layering routes, controllers, services

Route: HTTP parsing, status mapping
Controller: request/response shaping, authz checks
Service: business rules and DB transactions

This separation makes testing easier: services should not depend on Express-specific objects.


Lesson 2: Idempotency and webhooks

Payment providers retry webhooks. Your handler must be safe to run twice.

Patterns:


Lesson 3: File uploads and async processing

Validate MIME type, size limits, and filename hygiene. Prefer scanning and virus scanning policies for real products.

Offload heavy transforms to a worker queue when response latency matters.


Lesson 4: Query patterns at scale

Avoid unbounded OFFSET for huge tables when you can use keyset pagination.

Add indexes that match real WHERE + ORDER BY clauses; verify with EXPLAIN.


Lesson 5: Observability for backends

Minimum viable production awareness:


Exercises

  1. Implement a webhook endpoint with an idempotency table.
  2. Add a background job that runs every N minutes and cleans stale rows.
  3. Pick one slow query and document an index plan.

Next step

Phase F: Advanced frontend