Skip to content

Add example services, shared libraries and ARCHITECTURE.md - #3

Merged
sovikroy merged 1 commit into
mainfrom
claude/project-thread-pgmuzo
Nov 4, 2026
Merged

sovikroy merged 1 commit into
mainfrom
claude/project-thread-pgmuzo

Conversation

@sovikroy

@sovikroy sovikroy commented Nov 4, 2026

Copy link
Copy Markdown
Owner

Requested by Sovik · project thread

Summary

Adds a small "shop" example so the monorepo shows real services sharing real code.

Shared libraries (packages/)

  • contracts: pydantic models every service agrees on (Product, Order, OrderCreate, OrderPlaced event).
  • messaging: Broker interface with a Redis implementation (production) and an in-memory one (tests), plus typed publish_event / receive_event.
  • servicekit: env-var settings, one logging format, and (via the http extra) a FastAPI app factory with /health.

Services (apps/), each with tests and its own Dockerfile

  • catalog-api (HTTP): lists products and prices.
  • orders-api (HTTP): accepts an order, prices it by calling catalog-api, stores it, publishes OrderPlaced to Redis.
  • notifier-worker (worker): consumes OrderPlaced and sends a confirmation (logged). No FastAPI in its image.

Also

  • compose.yaml runs all three plus Redis locally (docker compose up --build).
  • ARCHITECTURE.md with 7 Mermaid diagrams: repo layout, dependency graph, runtime sequence, inside-a-service, CI flow, container build, deployment.
  • README layout and quick-start updated; root pyproject.toml gets the new mypy paths / first-party names, the pydantic mypy plugin and fakeredis for tests.

Testing

  • pre-commit run --all-files (ruff, ruff format, mypy strict, uv lock --check) passes.
  • pytest: 30 tests pass, and each member passes on its own as the CI matrix runs it.
  • Installed each app the way its Dockerfile does (uv sync --no-dev --no-editable --package <app>): each venv contains only its own libraries (e.g. the worker has no fastapi/uvicorn).
  • Ran the three services together against a Redis-compatible server: POST /orders returned 201 with the correct total, an unknown SKU returned 422, and the worker logged the notification.
  • Docker wasn't available in my environment, so the images themselves were not built here.
  • All Mermaid diagrams rendered with mermaid-cli.

Generated by Claude Code

- packages/contracts: shared pydantic models (Product, Order, OrderPlaced event)
- packages/messaging: Broker interface with Redis and in-memory implementations
- packages/servicekit: env settings, logging, FastAPI app factory with /health
- apps/catalog-api, apps/orders-api (HTTP) and apps/notifier-worker (queue
  consumer), each with tests and its own Dockerfile
- compose.yaml to run everything together with Redis
- ARCHITECTURE.md with Mermaid diagrams for layout, dependencies, runtime
  flow, CI and deployment

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SE2PhLkfsDeyxNHA9ozBD7
@sovikroy sovikroy self-assigned this Nov 4, 2026
@sovikroy
sovikroy merged commit 52881bb into main Nov 4, 2026
11 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.

2 participants