sense1tapo4ek.

Projects · posts

s1t-python-backend-templates

My universal base templates for all kinds of Python services: an event-driven monorepo — a Litestar API (strict S-DDD, outbox, admin UI) plus a FastStream/SAQ worker. MIT.

This is where I keep my universal base templates for all kinds of Python services. It is not a library — it is a template: fork it, rename it, delete what you don't need, and start writing business logic inside a ready-made structure.

What's inside

A monorepo of two independent services. They share no code — only a wire contract over Valkey Streams:

  • litestar_backend — a Litestar API with strict S-DDD context layering: Dishka DI, transactional outbox + relay, an SSE feed, role-based auth, an admin UI with a dashboard and a file-tail log viewer, Prometheus metrics.
  • event_microservice — a FastStream consumer + SAQ worker: reads the stream, fans heavy work out to jobs (async / thread pool / process pool), joins the results and publishes events back.

The full live cycle: POST /videos -> outbox -> video_uploaded -> three jobs -> join -> video_status -> a PENDING -> PROCESSING -> DONE/FAILED state machine -> SSE to the browser.

Why

Every new service used to start with the same decisions: layers, errors, DI, logging, metrics, tests. I got tired of solving that again and again — now it is solved once and lives as a template. Two model contexts inside: media_example (full S-DDD: domain events, outbox, a unit/flow/integration/e2e test pyramid) and db_example_litestar (thin CRUD with no domain layer — for when there are no invariants).

The docs are self-sufficient: architecture.md, wire contracts, an ADR log. MIT — fork away.

posts