Getting started
Modules and handlers are fully typed; your IDE will suggest methods and fields and catch type errors.
Prerequisites
- Python 3.12+
- (Optional) uv or
pipfor install
Install
pip install urich
# For running the app:
pip install "urich[dev]"
# For CLI code generation:
pip install "urich[cli]"
Minimal app
- Create a file
main.py:
from urich import Application
from orders.module import orders_module
app = Application()
app.register(orders_module)
app.openapi(title="My API", version="0.1.0")
- Run with uvicorn:
-
Open http://localhost:8000/docs for interactive Swagger UI (no extra config). You'll see routes like:
-
POST /orders/commands/create_order GET /orders/queries/get_order
The orders module in this example is a DomainModule: one object that declares aggregate, repository, command, query and event handler. You can scaffold it with the CLI or copy from the ecommerce example.
Using the CLI
From an empty directory:
urich create-app myapp
cd myapp
urich add-context orders --dir .
urich add-aggregate orders Order --dir .
Then in main.py (or your app entrypoint):
from urich import Application
from orders.module import orders_module
app = Application()
app.register(orders_module)
app.openapi(title="My API", version="0.1.0")
Run with uvicorn main:app --reload and visit /docs.
Next
- Application & modules — how
Applicationandapp.register()work - Domain module — structure of a bounded context (domain, application, infrastructure, module.py)