BE·55
Backend Projects
Eight build-it-yourself projects that grow one backend, the tiffin centre's ordering service, from a plain-Java API to a secure, resilient, observable Spring Boot service with messaging, caching and a full test pipeline: what each teaches, a milestone plan, measurable definitions of done, and stretch goals for experienced readers.
How to approach the projects
One product, built up in layers
The labs in this volume each isolate one idea. Projects put the ideas together, which is where most of the real learning happens: choosing between options, discovering how pieces interact, and debugging things no chapter warned you about. All eight projects grow one backend: the ordering service for the same South Indian tiffin centre whose frontend Volume 2's projects built. Customers browse the menu and place orders, the kitchen sees a queue, payments go through a provider, and customers get confirmations. By the end you have a service that would survive a real launch, and a portfolio piece that shows the whole of Part III.
| # | Project | Main chapters | Roughly |
|---|---|---|---|
| 1 | The order API in plain Java | Start Here, 33–38, 44, 45 | 1 week |
| 2 | The Spring Boot service with PostgreSQL | 46–49 | 2 weeks |
| 3 | Sign-in and access control | 50 | 1 week |
| 4 | Notifications through a message broker | 51 | 1–2 weeks |
| 5 | Payments that survive failure | 44, 45, 52 | 1–2 weeks |
| 6 | A fast menu: caching and profiling | 40, 41, 53 | 1 week |
| 7 | The test and build pipeline | 42, 43, 54 | 1–2 weeks |
| 8 | Production readiness | 39, 44, 47 | 1 week |
If you're new to backend work, do them in order after the Start Here chapter's warm-up exercises; each assumes the previous ones. If you're experienced, skim 1–2, then treat each later project's stretch goals as the real assignment.
The working method
For every project:
- Write the definition of done first. Each project lists measurable checks (a latency percentile, a test result, a count of queries or duplicate messages). Copy them into a checklist before writing code.
- Build the thinnest end-to-end slice first: one endpoint, one table, one test, deployed and running, before widening.
- Reproduce the failure before fixing it. For anything about concurrency, retries, caching or security, write the test or load script that shows the problem (as the chapter labs did), then make it pass.
- Measure with the tools from the labs: SQL logs and query counts, a load generator,
jcmdand JFR,EXPLAIN ANALYZE, curl with-wtimings. - Write a short README per project: what you built, the decisions and their alternatives, what you measured, and what you'd do next. That README is what interviewers read.
The eight projects
Project 1: the order API in plain Java
Goal. An HTTP API for menu and orders using only the JDK (HttpServer, records, collections, virtual threads), in the style of the Start Here chapter and chapter 44, with no frameworks, so you understand what frameworks later do for you.
Milestones. Domain records (Dish, Order, OrderLine, money in paise as long) and a sealed OrderStatus with a pattern-matching state machine → an in-memory repository behind an interface, made thread-safe → controller, service and repository layers → GET /v1/dishes with cursor pagination and filtering, POST /v1/orders returning 201 and Location, GET /v1/orders/{id} with an ETag → Problem Details for every error, with field-level validation messages → a request-id filter, structured JSON access logs and a /health endpoint → configuration from environment variables → graceful shutdown.
Done when. A script of at least 15 curl calls shows every status code you use (200, 201, 204, 304, 400, 404, 405, 412, 422) with correct headers; 1,000 concurrent order creations from a load generator produce exactly 1,000 orders with unique ids (prove there's no lost update); the order state machine rejects illegal transitions (cancelling a delivered order) with 409; request bodies over 10 KB are refused; kill -TERM during a 2-second request still completes it.
Stretch. Idempotency keys on POST /v1/orders; If-Match on order updates; port the API to Go's net/http or Rust's Axum and compare code size, startup time and memory (chapter 40's lab method).
Project 2: the Spring Boot service with PostgreSQL
Goal. Rebuild project 1 as a Spring Boot 4 service backed by PostgreSQL, keeping the same API contract so project 1's curl script still passes.
Milestones. A Boot application with @ConfigurationProperties records and profiles → schema migrations with Flyway (tables, keys, CHECK and UNIQUE constraints, indexes for every query) → repositories with Spring Data JPA (or JdbcClient, and justify the choice) → transactions in the service layer → optimistic locking with @Version mapped to ETags → MVC controllers with Bean Validation and ProblemDetail everywhere (spring.mvc.problemdetails.enabled) → keyset pagination for the order history → virtual threads on, with a HikariCP pool sized by measurement.
Done when. The project 1 script passes unchanged; the menu page and order history each run a fixed number of SQL statements regardless of result size (assert query counts in a test: no N+1); creating an order with 5 lines runs in one transaction and leaves nothing behind when any line is invalid; two concurrent edits of one order give one success and one 412; importing 100,000 historical orders takes under 10 seconds (batching or COPY); spring.jpa.open-in-view is off.
Stretch. Read-only projections for list endpoints; a SKIP LOCKED kitchen queue endpoint where several kitchen screens claim orders without collisions; compare JPA and JdbcClient implementations of the hottest query.
Project 3: sign-in and access control
Goal. Customers, kitchen staff and administrators sign in through an identity provider (run Keycloak in a container), and the API enforces who may do what.
Milestones. Configure a realm with roles and a public client using the authorisation code flow with PKCE → make the service an OAuth 2.0 resource server validating JWTs (issuer, audience, expiry, signature from JWKS) → a SecurityFilterChain that denies by default, with public menu endpoints → role rules (kitchen queue for staff, menu editing for admins) and ownership rules (customers see only their own orders) with method security → a BFF or session-cookie approach for the Volume 2 frontend, with SameSite cookies and CSRF protection → CORS restricted to the frontend's origin.
Done when. An automated test suite covers every endpoint with no token, an expired token, a token for the wrong audience, a customer token, a staff token and an admin token, asserting 401 vs 403 vs 200 exactly; a customer requesting another customer's order gets 404 or 403 (decide which and document why); an alg: none or tampered token is rejected; the frontend's origin can call the API and a different origin can't read responses (verify with a browser test, as in chapter 50's lab).
Stretch. Passkeys (WebAuthn) for staff; service-to-service calls with the client credentials flow; audit logging of every admin change with the acting user's id.
Project 4: notifications through a message broker
Goal. Placing an order publishes an event; separate consumers send the confirmation SMS (a stub provider), update the kitchen display, and award loyalty points, without slowing or failing the order request.
Milestones. An order_events outbox table written in the order transaction → a relay publishing to Kafka or RabbitMQ (run in a container) → three consumers in separate processes, each idempotent (a processed-messages table, or idempotency keys sent to the SMS stub) → retries with backoff and jitter, then a dead-letter topic or queue → ordering per order id (partition key or single-active consumer) → consumer lag and DLQ size exposed as metrics.
Done when. Order latency is unchanged when the SMS provider is down; killing the relay or any consumer mid-stream and restarting it loses no events and sends no duplicate SMS (prove it with a script that kills processes randomly during 1,000 orders and then counts); a poison message lands in the DLQ after a bounded number of attempts while other messages keep flowing; the kitchen sees each order's status changes in order.
Stretch. Change-data capture with Debezium instead of a polling relay; a saga for "order → payment → kitchen" with compensation when payment fails; replay a consumer from an earlier offset to rebuild the loyalty table.
Project 5: payments that survive failure
Goal. Integrate a payment provider (write a stub that can be slow, fail, time out or succeed after a delay) so that customers are charged exactly once, and a struggling provider never takes down ordering.
Milestones. A payment client with connect and read timeouts → idempotency keys on every charge request, stored with the payment attempt → retries only for transient failures, at one layer, with jittered backoff → a circuit breaker (Resilience4j) with a fallback ("pay at counter") → a bulkhead so payment calls can't use more than a fixed share of request threads (@ConcurrencyLimit) → reconciliation: a scheduled job that asks the provider for the status of payments stuck in "pending" → a load test with k6 or Gatling while the stub misbehaves.
Done when. Under a load test where the provider times out 20% of the time, no customer is charged twice (check the stub's ledger) and no order is marked paid without a successful charge; when the provider is fully down, checkout responds within your stated deadline (for example 1 second) with the fallback, and the menu endpoint's p99 latency is unaffected; the breaker's state is visible as a metric and reopens within its configured window when the provider recovers.
Stretch. Webhook handling from the provider (signature verification, idempotent processing, out-of-order events); hedged requests for the read-only payment-status call; a retry budget shared across instances.
Project 6: a fast menu: caching and profiling
Goal. Make the menu and popular-dish endpoints fast and cheap under heavy read traffic, and prove where the time goes.
Milestones. A load test of the menu endpoint establishing a baseline (throughput, p50, p99, database CPU) → a profile with JFR or async-profiler under that load, and a written explanation of the top three costs → HTTP caching (ETags, Cache-Control) for the public menu → cache-aside with Redis for computed views, with TTLs and invalidation on menu edits → stampede protection (single-flight or Caffeine loading cache, plus TTL jitter) → an in-process cache for the hottest, smallest data, with invalidation across instances (Redis pub/sub) → a JMH benchmark for any hot code path you optimise.
Done when. At the same hardware, the menu endpoint serves at least 5× the baseline throughput with p99 under 50 ms; a menu edit is visible to customers within your stated staleness budget (test it); expiring the hottest key during a load test causes one database query, not hundreds (count them); the service still works, more slowly, with Redis stopped.
Stretch. A heap analysis of the service under load (histogram, then a dump in MAT) with one memory reduction you can measure; compare G1 and ZGC for your service's p99 under load; run with compact object headers and the AOT cache and measure the difference.
Project 7: the test and build pipeline
Goal. A build that any contributor can trust: fast unit feedback, realistic integration tests, protected contracts, and reproducible artifacts.
Milestones. A Gradle (or Maven) build with the wrapper, --release, a version catalog or BOM, and dependency locking → unit tests for the domain with property-based tests for money (totals, splits, discounts) → repository tests against PostgreSQL with Testcontainers, and API tests with @SpringBootTest → WireMock stubs for the payment and SMS providers → contract tests between the frontend (Volume 2) and this API, or OpenAPI-based checks → ArchUnit rules for layering (controllers don't touch repositories) → mutation testing (PIT) on the pricing and order-state code → CI on every push with the build cache, and a container image built reproducibly (Buildpacks or a layered JAR) with a software bill of materials.
Done when. The unit suite runs in under 30 seconds and the full suite in under 5 minutes in CI; mutation score on pricing is at least 85% with every surviving mutant explained; the Spring test suite creates at most three application contexts (show the log); two clean builds of the same commit produce byte-identical JARs; a deliberately broken API change (renaming a response field) fails the contract tests; zero flaky tests over 20 consecutive CI runs.
Stretch. A performance test in CI with an SLO assertion (p99 under a threshold at a given rate); jdeps and a jlink runtime in the image; dependency updates automated with Renovate and gated by the suite.
Project 8: production readiness
Goal. Everything an on-call engineer needs on the first night: the service starts fast, stops cleanly, explains itself, and upgrades without drama.
Milestones. Actuator with liveness and readiness groups wired to Kubernetes-style probes → graceful shutdown with a readiness flip and a drain shorter than the platform's kill timeout → structured logs with request and trace ids, metrics (RED for endpoints, pool and queue saturation, breaker state, consumer lag) and traces across the service, broker and database (OpenTelemetry) → a runbook with the five most likely incidents and how to diagnose each from your telemetry → startup tuning (AOT cache or native image, measured) → a JDK upgrade from 21 to 25 performed with jdeps, the test suite and a staged rollout.
Done when. A rolling restart under steady load produces zero failed requests (measure with a load generator); a dashboard shows each dependency's health and the service's SLO burn rate; one simulated incident from the runbook (database slow, provider down, broker full) is detected by an alert and diagnosed from telemetry alone by someone who didn't build the service; startup time and memory before and after tuning are recorded in the README.
Stretch. A game day injecting faults with Toxiproxy or a chaos tool; per-tenant rate limiting; a blue-green or canary deployment with automatic rollback on SLO burn.
Tracking your progress
Portfolio checklist
Keep the service in one repository with a README per project covering: the goal, an architecture diagram, the key decisions and their alternatives, the measurements against the definition of done, and what you'd improve. Backend work is invisible, so measurements and failure demonstrations are what make it convincing: "1,000 orders while killing consumers at random: 0 lost events, 0 duplicate SMS; checkout p99 410 ms with the payment provider down; 3 SQL statements for any page of order history" says far more than a list of technologies.
Mapping to mastery levels
Completing projects 1–3 with their checks puts you solidly at L2 across the volume. Doing the stretch goals, and being able to explain every measurement and failure you reproduced, is L3–L4. Making and defending the design decisions in projects 4–8 (consistency between database and broker, retry and timeout budgets, cache staleness budgets, test strategy, operational readiness) is L5 work, the level that senior and staff backend interviews probe.