Skip to main content

domainkit

A Django-style framework for domain-driven FastAPI services. It provides:

  • settings modules and installed domains
  • manage.py commands and migrations
  • DDD building blocks, with the layer rules between them enforced
  • several databases: domains routed to their own, sharding by key, PostgreSQL range partitioning, and immudb ledgers for evidence
  • optional apps for reliable messaging, audit trails, idempotent requests, and tamper-evident evidence
pip install "domainkit[postgres]"     # extras: postgres, sqlite, immudb, metrics, tracing, testing

Documentation

Quick start

python3.13 -m venv .venv && . .venv/bin/activate
pip install "domainkit[postgres,sqlite,testing]"
domainkit init billingAPI billing     # the name sets the variable prefix: BILLING_API_*
cd billing
python manage.py check
python manage.py startdomain invoices --aggregate Invoice   # prints how to install it
python manage.py makemigrations -m "create invoices" && python manage.py migrate
pytest
python manage.py runserver            # http://127.0.0.1:8000/docs

domainkit init creates a project that passes check and its tests as it is:

billing/
  pyproject.toml          the name, dependencies, and the pytest plugin
  manage.py
  .env                    selects config.settings.local on this machine
  .gitignore
  src/config/settings/    base, local, test, and production settings
  src/config/urls.py      the root router: mount each domain's router here
  src/config/asgi.py      the application, for uvicorn
  src/domains/            the bounded contexts
  tests/test_health.py

The production settings read BILLING_API_ALLOWED_HOSTS and BILLING_API_DATABASE_URL from the environment, and the deployment checks refuse to start without them, or without verified TLS to the database.

Developing domainkit

poetry install --all-extras            # Python 3.13
pre-commit install                     # after: pipx install pre-commit

poetry run ruff check . && poetry run ruff format --check . && poetry run mypy
poetry run pytest --cov                # random order; coverage gate in pyproject.toml
poetry run mutmut run "domainkit.http*" && poetry run mutmut results

The database tests use SQLite unless DOMAINKIT_TEST_POSTGRES_URL names a PostgreSQL server; each test then creates a database there and drops it. Use a throwaway server:

docker run -d --rm --name domainkit-postgres -e POSTGRES_PASSWORD=postgres \
  -p 127.0.0.1:55432:5432 postgres:18-alpine
DOMAINKIT_TEST_POSTGRES_URL=postgresql+asyncpg://postgres:postgres@127.0.0.1:55432/postgres \
  poetry run pytest

CI (.github/workflows/ci.yml) runs the same checks on every push and pull request:

  • lint and strict typing
  • the tests on Python 3.13 and 3.14
  • the tests again with PostgreSQL 18, including row locking, the audit triggers, and server-side timeouts
  • a wheel build, installed and imported in a clean environment
  • pip-audit, and a gitleaks scan of the whole history

A full mutation testing run happens weekly. Releases are published to PyPI from a version tag; see docs/versioning.md.

License

MIT; see LICENSE.

Metadata

Release files for domainkit 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for domainkit 0.3.0
File Size Uploaded
domainkit-0.3.0.tar.gz 110.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for domainkit 0.3.0
File Interpreter ABI Platform
domainkit-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 279.4 kB

Release files / domainkit-0.3.0.tar.gz

Download URL domainkit-0.3.0.tar.gz
Size 110.3 kB
Tags Source
SHA-256 checksum
How to use checksums
53b8949dbe168906614b4d46a40706b1f972d212450bf3ef36fe1424ad659f5d
BLAKE2b-256 checksum
How to use checksums
aa878c958d85b510f4f95e3986ed1615abcfc2a0eff21b2d67cc13713bd73793
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / domainkit-0.3.0-py3-none-any.whl

Download URL domainkit-0.3.0-py3-none-any.whl
Size 169.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb8acaeb178db95a6822fec49b60235c21e6f77d6b1e9c6d438a2a6edf154834
BLAKE2b-256 checksum
How to use checksums
c57ab6c82ea2ed38536b365d2e3855e20ad461158dfef3ee0778f62a086a9420
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

0.5.0

2 release files

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page