Skip to content

M1: foundation — Database per Service, Bounded Context, API Gateway, Observability - #2

Merged
MAOFILHO merged 1 commit into
mainfrom
m1/foundation
Nov 15, 2026
Merged

MAOFILHO merged 1 commit into
mainfrom
m1/foundation

Conversation

@MAOFILHO

Copy link
Copy Markdown
Owner

Summary

4 of 12 patterns are now live, each with a page explaining it, when not to use it, and a demo against the real services.

Pattern What a visitor can do
1. Database per Service See each of the 5 services report only its own tables; make the order service try to read another service's table and watch the database refuse (no such table: product).
2. Bounded Context Context map of 5 business contexts; one product shown as Catalog sees it (name, price) and as Inventory sees it (on hand, reserved).
5. API Gateway One browser call to /api/order-summary fans out to user, order, catalog and inventory; the page lists every call, status, timing and the shared request ID.
6. Observability One click traced through every process (gateway + 4 services + their DB queries) as a waterfall; per-service request and latency metrics from /metrics.

What changed

  • New services: services/payment (5104) and services/inventory (5105), each with its own DB.
  • New shared package shared/shop_common: OpenTelemetry tracing, JSON logs with trace/request IDs, Prometheus metrics, /health/db, /debug/spans, /metrics.
  • Gateway: request IDs, tracing, aggregation and demo endpoints; proxy limited to GET/POST.
  • Security: removed the unauthenticated DELETE /api/product/<slug> (only used by the old benchmark).
  • Infra: Bicep and provision.py deploy payment and inventory; images include shop_common; gunicorn runs 1 worker + 4 threads so the span store sees every request. Not deployed.
  • CI: 2 new suites; each suite installs shop_common.

Screenshots

See the README section "The live demos" (images in docs/screenshots/).

Test plan

  • make test: 38 passed across 7 suites
  • make smoke with make run up: 15 passed, 3 skipped (Azure-only), including table isolation, bounded-context views and a cross-service trace
  • npm run build and az bicep build pass
  • Clicked through all 4 pattern pages in the browser
  • CI green on this PR

🤖 Generated with Claude Code

Pattern 1, Database per Service: add payment and inventory services, each
with its own database; /health/db on every service; order-service isolation
probe shows a real 'no such table' when it tries another service's table.

Pattern 2, Bounded Context: inventory owns StockItem keyed by the catalog's
product id; gateway endpoint returns one product as Catalog and Inventory
each see it; context map page.

Pattern 5, API Gateway: request IDs forwarded to every service and echoed
back; /api/order-summary aggregates user, order, catalog and inventory;
only GET/POST proxied.

Pattern 6, Observability: shared shop_common package with OpenTelemetry
tracing (Flask, FastAPI, requests, httpx, SQLAlchemy), JSON logs carrying
trace and request IDs, Prometheus metrics, and an in-memory span store the
gateway stitches into a trace waterfall. Optional OTLP export.

Also: remove the unauthenticated DELETE /api/product/<slug>; Bicep and
provision deploy payment and inventory; CI installs shop_common per suite;
pattern pages with live demos and screenshots in the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MAOFILHO
MAOFILHO merged commit 8bd736d into main Nov 15, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant