Skip to main content

Async DDD framework for microservices on Starlette

Project description

Urich

Async DDD framework for microservices on Starlette.

Documentation: kashn9sh.github.io/urich · Contributing: CONTRIBUTING.md · Community & promotion: docs/community.md

The application is composed from module objects via app.register(module) — similar to FastAPI with routers, but one consistent style for domain, events, RPC and discovery.

Idea

  • One object = one building block: DomainModule, EventBusModule, OutboxModule, DiscoveryModule, RpcModule. All configured via fluent API and attached with app.register(module).
  • DDD: Bounded context as DomainModule with .aggregate(), .repository(), .command(), .query(), .on_event(). Commands and queries get HTTP routes automatically.
  • No lock-in: Protocols (EventBus, ServiceDiscovery, RpcTransport) in core; implementations (Redis, Consul, HTTP+JSON) supplied by the user or optional out-of-the-box adapters.

Install

pip install urich
# CLI for generating skeletons:
pip install "urich[cli]"

Quick start

from urich import Application
from urich.ddd import DomainModule

# One object = full bounded context
from orders.module import orders_module

app = Application()
app.register(orders_module)

# Run: python -m uvicorn main:app --reload  (or: pip install uvicorn && uvicorn main:app --reload)

Routes by convention: POST /orders/commands/create_order, GET /orders/queries/get_order.

OpenAPI / Swagger

After registering all modules, call app.openapi(title="My API", version="0.1.0"). Then:

  • GET /openapi.json — OpenAPI 3.0 spec
  • GET /docs — Swagger UI
app = Application()
# ... app.register(module) ...
app.openapi(title="My API", version="0.1.0")

CLI

urich create-app myapp
cd myapp
urich add-context orders --dir .
urich add-aggregate orders Order --dir .
# In main.py: from orders.module import orders_module; app.register(orders_module)

Module structure (DomainModule)

  • domain — aggregate (AggregateRoot), domain events (DomainEvent).
  • application — commands/queries (Command/Query), handlers (one per command/query).
  • infrastructure — repository interface and implementation (e.g. in-memory for prototypes).
  • module.py — one object DomainModule("orders").aggregate(...).repository(...).command(...).query(...).on_event(...); register in the app with app.register(orders_module).

Other modules

  • EventBusModule.adapter(impl) or .in_memory(); in container as EventBus.
  • OutboxModule.storage(...) and .publisher(...); contracts in core.
  • DiscoveryModule.static({"svc": "http://..."}) or .adapter(impl); ServiceDiscovery protocol.
  • RpcModule.server(path="/rpc") and .client(discovery=..., transport=...); optional JsonHttpRpcTransport (requires httpx).

Full composition example: examples/ecommerce/main.py.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

urich-0.1.1.tar.gz (18.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

urich-0.1.1-py3-none-any.whl (24.9 kB view details)

Uploaded Python 3

File details

Details for the file urich-0.1.1.tar.gz.

File metadata

  • Download URL: urich-0.1.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for urich-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2dd2ed479fa7eeb33aaf180e466f934bc4b3e5e8378996b469fc70263ad09450
MD5 58c7a561a1ceed1265c22878992bae14
BLAKE2b-256 ee660f60b1585c24fd09afbf0b571c71f7a09b215ffacf07db4ef6f1e17e39a4

See more details on using hashes here.

Provenance

The following attestation bundles were made for urich-0.1.1.tar.gz:

Publisher: publish.yml on KashN9sh/urich

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file urich-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: urich-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for urich-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 889faaa27cffe5585d9065987cc42033c992cd3929db6b15f6a88215c217b3b7
MD5 b7cd5af025a359eabe9ce0fb8287bf88
BLAKE2b-256 2426ca52fb5654c32df0ed6c481a39e54e82cb17f51c7c13a450fde3d2ee7dec

See more details on using hashes here.

Provenance

The following attestation bundles were made for urich-0.1.1-py3-none-any.whl:

Publisher: publish.yml on KashN9sh/urich

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page