The Compose lab topology: a Quarkus container and a FastAPI container both serving the same OpenAPI contract on their own ports, both backed by a shared Postgres container, with an optional LGTM observability lane gated behind a profile flag that is off by default, and CI shown schema-validating the live responses from both services against that one contract.
Figure 0.1: The lab: two stacks, one contract, optional LGTM, CI as the drift gate.
Download .excalidraw source
·
Edit on excalidraw.com
A split diagram contrasting an RPC-style API, shown as a flat list of named procedure calls like confirmBooking and cancelBooking each with its own bespoke request and response shape, against a Web API shown as a small fixed set of HTTP methods (GET, POST, PUT, PATCH, DELETE) acting uniformly on addressable resources such as a booking, its cargo, and its confirmation; below the split, the five REST constraints are listed as labeled bands (client-server, stateless, cacheable, uniform interface, layered system) with the uniform interface band visually emphasized as the one that lets a single generic client work against every resource without a custom SDK.
Figure 1.1: The REST constraints, and the uniform interface that makes them pay off.
Download .excalidraw source
·
Edit on excalidraw.com
Seven labeled axes (interaction shape, payload size and shape, latency and real-time need, cacheability, client diversity, evolution and versioning needs, and operational constraints) each feeding into a central decision diamond that resolves to a chosen pattern, style, and transport such as REST, gRPC, GraphQL, WebSockets, or webhooks.
Figure 2.1: The decision axes, reused in every Decision callout that follows.
Download .excalidraw source
·
Edit on excalidraw.com
The Booking aggregate exposed three ways: as a collection at /bookings returning a page of bookings, as an item at /bookings/{id} returning one full booking with its cargo embedded, and as a sub-resource at /bookings/{id}/cargo for the owned cargo items, with a callout noting resources are nouns modeled on client access patterns, not a copy of the bookings and cargo_items database tables.
Figure 3.1: The Booking aggregate as resources: collection, item, and sub-resource.
Download .excalidraw source
·
Edit on excalidraw.com
The shared OpenAPI and JSON Schema contract scaffolds both the Quarkus and the FastAPI stack, each stack serves live HTTP responses, CI's verify.sh schema-validates every live response body against the same contract, and the pipeline either merges on a match or fails the build on drift.
Figure 4.1: Contract-first: one schema, two stacks, CI as the drift gate.
Download .excalidraw source
·
Edit on excalidraw.com
A two-axis matrix with safe and idempotent as the dimensions, placing GET as safe and idempotent, PUT and DELETE as idempotent but not safe, POST and the item-level PATCH as neither safe nor idempotent, and the two 405 cases marked not-applicable because the method has no supported semantics on that resource.
Figure 5.1: The idempotency matrix, with the booking operations placed.
Download .excalidraw source
·
Edit on excalidraw.com
A request's Accept and Content-Type headers are checked against what the matched endpoint can produce and consume, branching to a 200/201/204 success response when both are satisfied or to a 406/415 Problem response when either is not, alongside a separate status-code map showing 400 for a malformed request, 404 for a missing resource, and 409 for a well-formed request against a resource in the wrong state.
Figure 6.1: Negotiation outcomes and the status-code map.
Download .excalidraw source
·
Edit on excalidraw.com
The same Booking resource shown receiving two different partial-update requests side by side: a JSON Merge Patch sent as application/merge-patch+json, a sparse object with requestedPickup changed and a null field marked for deletion, merged recursively into the target; and a JSON Patch sent as application/json-patch+json, an ordered array of add/remove/replace/test operations addressed by JSON Pointer paths like /cargo/0/description, applied in sequence to the same target, with a failing test operation shown short-circuiting the whole array before any operation after it runs.
Figure 7.1: JSON Patch vs JSON Merge Patch on the same booking.
Download .excalidraw source
·
Edit on excalidraw.com
Three pagination strategies compared side by side against the same GET /bookings endpoint: offset/limit using a row count that drifts when a concurrent insert shifts the window, keyset/cursor using an opaque token over the monotonic booking-id sort key that stays stable under concurrent inserts, and seek using an explicit after_id with the same stability property, with a limit clamp shown capping all three to a maximum page size as a denial-of-service guard regardless of what the client requests.
Figure 8.1: Three pagination strategies, and why keyset is the stable default.
Download .excalidraw source
·
Edit on excalidraw.com
Two parallel URL trees contrasted: on the left, Booking owning Cargo at /bookings/{id}/cargo, shown as a solid containment arrow because cargo has no identity outside its booking, with a single canonical address and a cache key scoped correctly to the parent; on the right, Location data shown NOT nested under any booking, reachable instead at its own top-level /locations/{unLocode} address shared and cached across every booking that references it, with a crossed-out hypothetical /bookings/{id}/locations/{unLocode} path and a second crossed-out flat /cargo/{cargoId} path illustrating the redundant-endpoint pitfall of the same resource reachable at two drifting addresses.
Figure 9.1: Nest when the parent owns the child; don't nest shared reference data.
Download .excalidraw source
·
Edit on excalidraw.com
A sequence diagram showing a client POSTing a confirmation request and receiving 202 Accepted with a Location header pointing at a new operation resource, the client polling that operation and receiving 200 with status RUNNING while a background worker completes the confirmation, the poll eventually receiving 303 See Other with a Location pointing at the confirmed booking, and a parallel cancel branch where a DELETE on the still-running operation moves it to FAILED and leaves the booking PENDING instead of reaching SUCCEEDED.
Figure 10.1: The 202 -> poll -> 303 lifecycle, with cancel.
Download .excalidraw source
·
Edit on excalidraw.com
A diagram showing a server-owned schedule configured once by PUT /jobs/manifest-reconcile on one side, feeding a periodic scheduler that fires automatic runs at the configured interval, alongside an on-demand run-now POST that produces an additional run outside the schedule, with every run (whether scheduled or on-demand) following the identical PENDING to RUNNING to SUCCEEDED-or-FAILED lifecycle as its own queryable record.
Figure 11.1: Configure the schedule once; each run is its own record.
Download .excalidraw source
·
Edit on excalidraw.com
The booking finite-state machine showing PENDING transitioning via confirm to CONFIRMED and via cancel to CANCELLED, CONFIRMED transitioning via load to IN_TRANSIT and via cancel to CANCELLED, IN_TRANSIT transitioning via deliver to DELIVERED, with each state's box annotated with the exact _links relation set its response exposes: PENDING shows self, confirm, cancel; CONFIRMED shows self, cancel; IN_TRANSIT, DELIVERED and CANCELLED each show self only.
Figure 12.1: The response as a finite-state machine: each state exposes only its valid links.
Download .excalidraw source
·
Edit on excalidraw.com
A flow diagram contrasting DELETE /bookings/{id} (soft delete), which moves a booking's status to CANCELLED, records a deletion audit entry, hides it from the default collection and single-item reads while leaving it addressable via GET ?includeDeleted=true with X-Audit-* headers, against DELETE /bookings/{id}/purge (GDPR erasure), which hard-deletes both the booking and its audit entry so that every read path, including the audit view, returns 404 afterward.
Figure 13.1: Soft delete keeps the audit trail; purge erases it under GDPR.
Download .excalidraw source
·
Edit on excalidraw.com
A diagram comparing four versioning strategies against one stored booking: URI versioning routing /v1/bookings and /v2/bookings to distinct cache-friendly URLs, query-parameter versioning as URI versioning's cousin via ?version=, header versioning via a custom X-API-Version header, and media-type versioning negotiating one URL /bookings/{id} via the Accept header with a required Vary: Accept response header to prevent a cache from serving the wrong representation; alongside the v1 price+cargoDescription shape versus the v2 quote+cargo[] shape produced by the same underlying resource.
Figure 14.1: Four versioning strategies and their caching implications.
Download .excalidraw source
·
Edit on excalidraw.com
A sequence diagram showing a client first sending HEAD to a manifest endpoint and receiving 200 with Accept-Ranges and Content-Length metadata but no body, then sending GET with a Range header and receiving 206 Partial Content with a Content-Range header and exactly the requested byte slice as the body, then sending GET with an out-of-bounds Range header and receiving 416 Range Not Satisfiable with a Content-Range header of bytes */total and no body.
Figure 15.1: HEAD, a 206 Range response, and a 416.
Download .excalidraw source
·
Edit on excalidraw.com
Three streaming modes delivering pieces of data over one HTTP connection over time, shown left to right: chunked transfer encoding writing a series of length-prefixed byte chunks with no Content-Length known up front, Server-Sent Events emitting discrete data colon frames spaced out over a long-lived text/event-stream connection, and NDJSON writing one complete JSON object per newline-terminated line that a consumer can parse as each line arrives.
Figure 16.1: Chunked, SSE, and NDJSON: three ways to stream over HTTP.
Download .excalidraw source
·
Edit on excalidraw.com
Four protocols compared side by side by direction, connection model, and best-fit use case: REST plus SSE shown as client-initiated request with optional one-directional server push over a short-lived HTTP connection for cacheable lookups and status watching; WebSockets shown as a full-duplex, stateful, long-lived connection for bidirectional low-latency conversation; webhooks shown as a server-initiated outbound POST to a client-owned endpoint with retry and signature verification for fire-and-forget events to offline receivers; gRPC shown as binary HTTP/2 request/response and streaming RPCs between service-to-service callers with generated contracts.
Figure 17.1: REST, WebSockets, webhooks, and gRPC by interaction shape.
Download .excalidraw source
·
Edit on excalidraw.com
Quarkus blocking worker pool exhausting under many concurrent slow calls next to Quarkus reactive Uni and virtual threads serving the same load on a small fixed pool, alongside Python's async event loop interleaving many coroutines on one thread versus a bounded threadpool queuing once its workers are all asleep, all labeled to show the same requests-waiting-on-I/O workload served without thread exhaustion versus with it.
Figure 18.1: Blocking pools versus non-blocking/virtual threads and the async event loop.
Download .excalidraw source
·
Edit on excalidraw.com
HTTP/1.1 serial head-of-line blocking across one request per connection at a time compared with HTTP/2 multiplexed streams over one TCP connection using HPACK header compression but still subject to TCP head-of-line blocking on packet loss, compared with HTTP/3 running independent QUIC streams over UDP with QPACK header compression, connection migration across network changes, and 0-RTT handshake resumption.
Figure 19.1: HTTP/1.1, HTTP/2, and HTTP/3 under a REST API.
Download .excalidraw source
·
Edit on excalidraw.com
A shared contract schema feeds a drift check; the Quarkus stack serves a hand-authored static OpenAPI document and the FastAPI stack serves a generated-and-patched OpenAPI document, each exposing a type-array nullable field and a webhooks section, and CI's drift check compares each served document's required-field set against the contract, passing on a match and failing the build on divergence.
Figure 20.1: The living-contract loop: edit the contract, each stack serves its document, drift check compares, CI gates on the result.
Download .excalidraw source
·
Edit on excalidraw.com
A single shared JSON Schema feeds both a synchronous REST path, where an OpenAPI endpoint and client exchange a Booking, and an asynchronous event path, where a service emits a CloudEvents-enveloped BookingEvent to Kafka for a consumer; below that, an Arazzo workflow spans booking, routing, and tracking as one business process; at the bottom, a governance tier kept out of CI shows Apicurio Registry as the schema/artifact registry and xRegistry touchpoint beside OpenMetadata as a data catalog tracking schema and version history over time, explicitly not an xRegistry implementation.
Figure 21.1: One schema, two protocol contracts, an Arazzo workflow across them, and a local-only governance tier.
Download .excalidraw source
·
Edit on excalidraw.com
Quarkus REST's build-time bytecode-generation path resolving @RestHeader and @RestQuery bindings ahead of request time, alongside the reactive NDJSON export's tick-driven Multi pipeline delivering one line at a time through a dedicated MessageBodyWriter to the client.
Figure 22.1: Build-time parameter binding and tick-driven reactive streaming in Quarkus REST.
Download .excalidraw source
·
Edit on excalidraw.com
A single uvicorn process with one event loop on the main thread serving an async StreamingResponse that drips SSE frames over time, a BackgroundTasks call returning a 202 while its deferred work finishes later on the same loop, and a plain-def handler offloaded through AnyIO to a threadpool worker thread distinct from the main thread.
Figure 23.1: One event loop, one threadpool: where StreamingResponse, BackgroundTasks, and plain def handlers each actually run inside a single FastAPI process.
Download .excalidraw source
·
Edit on excalidraw.com
A test pyramid for a REST API with contract tests validating live responses against the shared JSON Schema at the base, in-process @QuarkusTest and pytest integration tests above that running locally and at build time, a Newman end-to-end layer running the same Postman collection against both live stacks in CI, and a thin bounded load layer on top running the same collection thirty times and asserting success and schema conformance rather than latency.
Figure 24.1: The test pyramid for a REST API: contract, integration, end-to-end, and a thin bounded load layer, split by what runs in CI and what runs locally.
Download .excalidraw source
·
Edit on excalidraw.com
A Docker Compose topology with Quarkus and FastAPI containers both exporting OTLP traces to a single grafana/otel-lgtm container bundling Grafana, Tempo, Loki, and Mimir behind one OpenTelemetry Collector, Postgres present but unused, and verify.sh sending a traced POST with a fixed W3C traceparent header then polling Tempo's trace API by that exact id before asserting service name and route attributes on the returned span.
Figure 25.1: Both stacks exporting OTLP to one default LGTM container; a fixed trace id ties the POST to a bounded Tempo lookup.
Download .excalidraw source
·
Edit on excalidraw.com
The Chapter 25 Compose topology on the left (published host ports, Docker embedded DNS, a single healthcheck, plaintext environment variables, manual scale commands) mapped against the Chapter 26 Kubernetes topology on the right (a ClusterIP Service and host/path-routed Ingress, three-tier startup/readiness/liveness probes, a ConfigMap and Secret injected via envFrom, and a CPU-based HorizontalPodAutoscaler), with a kustomize base and minikube overlay pinning the real image tag in between.
Figure 26.1: The same two booking images, Compose primitives on the left mapped to their Kubernetes equivalents on the right, assembled by a kustomize base + minikube overlay.
Download .excalidraw source
·
Edit on excalidraw.com
A single Booking resource, on Quarkus and FastAPI, surrounded by every pattern the book taught (contract-first create/read, keyset pagination, HATEOAS links, async confirmation, media-type versioning, soft delete and purge, an NDJSON manifest, and a background CloudEvents publish to Kafka) all reading and writing the one shared JSON Schema and the Arazzo workflow tying the request sequence together.
Figure 27.1: One Booking resource, both stacks, every pattern this book taught assembled around it.
Download .excalidraw source
·
Edit on excalidraw.com
OpenShift Local topology: a client reaching an edge-TLS Route served by the cluster's router, routing to a Service in front of app pods assigned a UID by the restricted-v2 SCC, with a BuildConfig streaming binary source into the cluster and pushing the built image to an ImageStream in the integrated registry that the Deployment pulls from.
Figure A.1: Edge-TLS Routes, an in-cluster BuildConfig/ImageStream build, and restricted-v2 SCC admission, replacing minikube's Ingress, host-engine image build, and permissive default pod security.
Download .excalidraw source
·
Edit on excalidraw.com