Week 4 — Platform, craft & capstone
Judge when to use Redis, files, RabbitMQ, Docker, and WebSockets; then test, optimize, challenge, review, and finish Notes P4 as this week’s mini-project.
- 1. Caching with RedisOpen
No install is required this week. The goal is judgment: when caching solves a real, measured problem, and when it just adds a second source of truth to babysit.
- 2. File uploads / blob / S3Open
The judgment call is not how to call a storage SDK. It is why a file never belongs as a database BLOB column here.
- 3. Background work with RabbitMQOpen
The same conceptual lens as Redis and file storage: recognize when work does not belong inside the request and response cycle, without installing anything today.
- 4. Docker & ComposeOpen
Judge Docker the same conceptual way as Redis or RabbitMQ: where it solves a real environment problem, and where it stops mattering for this course.
- 5. WebSockets / Socket.IOOpen
The judgment call: which features actually need a live push channel versus which just need a refetch or a short poll.
- 6. Configuration & secrets managementOpen
A typical Nest setup does this well: a shared env schema validates every variable with Zod and its loader throws on a bad environment, while ConfigModule is registered globally. Establish that foundation before adding new config.
- 7. Logging & observabilityOpen
In a typical Nest app, a correlation id is threaded through every request and stamped onto error responses. Build the mental model on that pattern, then see what structured logging and health checks add.
- 8. Postman + VS Code debuggingOpen
These are everyday tools for isolating whether a bug is frontend, backend, or a contract mismatch, before touching any code.
- 9. Nest testing (unit + e2e / Supertest)Open
Learn how automated tests assert HTTP behavior without clicking a UI — the backbone of backend confidence.
- 10. Performance (indexes, lean queries, pagination)Open
This connects directly to the challenge topics ahead. Recognize the patterns here so they are easy to diagnose in the challenges.
- 11. Lint, format, Nest pitfallsOpen
Beyond generic JavaScript and TypeScript lint rules, Nest has framework-specific pitfalls that lint rules alone will not catch.
- 12. Challenge: JWT + RBAC holeOpen
This challenge reuses the authentication and authorization habits from earlier weeks: the difference between not authenticated and not authorized, and the role guard pattern.
- 13. Challenge: missing index / slow listOpen
This reuses the performance judgment from earlier in this week: recognizing the missing-index smell on a slow, filtered, frequently used endpoint.
- 14. Challenge: broken pagination / soft-delete leakOpen
Combines pagination correctness with a realistic soft-delete pitfall.
- 15. Code review & feedbackOpen
Use the same checklist mindset from this week when reviewing a teammate Nest PR — migrations, guards, DTOs, and contracts.
- 16. Notes API — Ship slice milestoneOpen
Replaces the old all-in-one hands-on topic. Capstone coding concepts, not a long deployment essay.
End-of-week mini-project · practice only
Realtime Orders Platform (Docker, Redis, RabbitMQ, WS)
A dockerized order service: queue work with RabbitMQ, cache with Redis, push live status over WebSockets, and prove it with tests.
Definition
A capstone platform slice where placing an order enqueues background work, a worker processes it, status streams to clients over WebSockets, and the whole stack runs under Docker Compose with tests, logging, and performance tuning.
In simpler words
Build a mini order system that behaves like production: you place an order, a background worker handles it, and your screen updates live — all running in containers.
Concepts covered this week
- Caching with Redis
- Cache hot order/product reads and hold rate-limit counters in Redis.
- File uploads / blob / S3
- Store generated invoice PDFs in a blob/S3 (or a disk adapter behind an interface).
- Background work with RabbitMQ
- Placing an order publishes a job; a worker consumes it and updates status.
- Docker & Compose
- One compose file runs api, worker, postgres, redis, and rabbitmq.
- WebSockets / Socket.IO
- A gateway pushes order-status changes to subscribed clients.
- Configuration & secrets management
- Zod-validated env; no secrets in git or logs.
- Logging & observability
- Structured logs + correlation IDs across api→queue→worker, plus a health check.
- Postman + VS Code debugging
- A Postman collection drives the API; VS Code breakpoints debug the worker.
- Nest testing (unit + e2e)
- Unit-test the order service; Supertest e2e for POST /orders.
- Performance (indexes, lean queries, pagination)
- Index orders(status, createdAt); paginate and select lean columns.
- Lint, format, Nest pitfalls
- ESLint/Prettier clean; avoid circular deps and request-scoped traps.
- Challenge: JWT + RBAC hole
- Audit and fix an endpoint that leaks another user’s orders.
- Challenge: missing index / slow list
- Diagnose a slow order list and add the missing index.
- Challenge: broken pagination / soft-delete leak
- Fix a feed whose totals include soft-deleted or duplicated rows.
- Code review & feedback
- Run a self code-review pass against the course rubric before "shipping".
Deliverables
- docker-compose.yml running api + worker + postgres + redis + rabbitmq
- POST /orders enqueues work; a worker processes it and updates status
- WebSocket gateway pushing live status; Redis-cached reads
- Unit + e2e tests, an indexed/paginated order list, and clean lint
Build guide
- Compose the stackWrite docker-compose.yml for api, worker, postgres, redis, and rabbitmq with healthchecks and validated env.
- Place + enqueuePOST /orders validates, persists a pending order, and publishes an order.created message to RabbitMQ.
- Process in a workerA separate worker consumes the queue, does the work, and updates the order status idempotently.
- Stream statusA Socket.IO gateway broadcasts status changes to clients subscribed to their order.
- Cache + tuneCache hot reads in Redis, add an index on orders(status, createdAt), and paginate the list with lean selects.
- Observe + debugThread a correlation id through api→queue→worker logs, add a health endpoint, and debug the worker with VS Code.
- Test itUnit-test the order service and write a Supertest e2e for POST /orders → status transition.
- Audit & reviewFix the three planted issues (RBAC leak, missing index, pagination/soft-delete leak) and do a self code-review pass.
Acceptance checklist
- [ ] docker compose up runs api + worker + postgres + redis + rabbitmq
- [ ] POST /orders enqueues; worker processes idempotently and updates status
- [ ] WebSocket clients receive live status updates
- [ ] Redis caches hot reads; orders list is indexed + paginated
- [ ] Correlation-id logging + health check; secrets only via validated env
- [ ] Unit + e2e tests pass; lint/format clean
- [ ] RBAC hole, missing index, and pagination/soft-delete leak all fixedStretch goals
- Add a dead-letter queue and a retry policy for failed jobs.
- Add Prometheus metrics and a simple dashboard.
- Swap the disk blob adapter for real S3 without touching callers.
Tips
- You need the seams (queue, cache, WS, Compose), not a giant cluster — keep each piece small.
- Make the worker idempotent: the same message processed twice must not double-charge.