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
  • optional apps for reliable messaging, audit trails, and idempotent requests
pip install "domainkit[postgres]"     # extras: postgres, sqlite, metrics, tracing, testing

Documentation

Quick start

A project is a pyproject.toml, a manage.py, a config package, and a domains package for its bounded contexts. The project's name sets the environment variable prefix: billingAPI reads BILLING_API_*.

billing/
  pyproject.toml
  manage.py
  src/config/__init__.py
  src/config/settings/__init__.py
  src/config/settings/local.py
  src/config/settings/test.py
  src/config/urls.py
  src/config/asgi.py
  src/domains/__init__.py
# pyproject.toml
[project]
name = "billingAPI"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = ["domainkit[sqlite]"]

[dependency-groups]
dev = ["domainkit[testing]"]                # pytest and httpx2, for the fixtures

[tool.pytest.ini_options]
pythonpath = ["src"]
addopts = "-p domainkit.testing"           # the database and client fixtures
domainkit_settings = "config.settings.test"
# manage.py
import sys
from pathlib import Path

if __name__ == "__main__":
    sys.path.insert(0, str(Path(__file__).resolve().parent / "src"))
    from domainkit.management import execute_from_command_line

    execute_from_command_line(sys.argv)
# src/config/settings/local.py
from pathlib import Path

from domainkit.conf.env import Env

env = Env()
BASE_DIR = Path(__file__).resolve().parents[3]

DEBUG = True
INSTALLED_DOMAINS = ["domainkit.contrib.messaging"]
ROOT_ROUTER = "config.urls.router"
ASGI_APPLICATION = "config.asgi:application"
DATABASES = {
    "default": {
        "URL": env.str("DATABASE_URL", f"sqlite+aiosqlite:///{BASE_DIR / 'db.sqlite3'}")
    },
}
# src/config/settings/test.py
from config.settings.local import *

DEBUG = False
ALLOWED_HOSTS = ["testserver"]
DATABASES = {"default": {"URL": "sqlite+aiosqlite:///:memory:"}}
# src/config/urls.py
from fastapi import APIRouter

from domainkit.http.health import router as health_router

router = APIRouter()
router.include_router(health_router)
# src/config/asgi.py
from domainkit.http import get_asgi_application

application = get_asgi_application()

Then:

pip install "domainkit[sqlite,testing]"                    # in a virtual environment
export BILLING_API_SETTINGS_MODULE=config.settings.local   # or put it in .env
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                                                      # the generated tests
python manage.py runserver                                  # http://127.0.0.1:8000/docs

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

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
  • 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.1.1

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.1.1
File Size Uploaded
domainkit-0.1.1.tar.gz 86.3 kB Details

Built distribution (wheel)

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

Total release size: 218.0 kB

Release files / domainkit-0.1.1.tar.gz

Download URL domainkit-0.1.1.tar.gz
Size 86.3 kB
Tags Source
SHA-256 checksum
How to use checksums
5d4bacbe3139ce860c46c3ee28e44996719a2183f775aa5df047c1deff20a1cd
BLAKE2b-256 checksum
How to use checksums
c8bd5d5abab3391680bf980062da2f338cf220680c9476fe69f913e86b02a078
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.1.1-py3-none-any.whl

Download URL domainkit-0.1.1-py3-none-any.whl
Size 131.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7dafafd771b91ccce3da7fea74970d5adebb51a5807c17ce4f16c02edf9625d
BLAKE2b-256 checksum
How to use checksums
c1149c07ad1bdf8b147e01813c5ddfa2df5b4487b0c7ce0a797c5509992601e4
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

0.3.0

2 release files

0.2.0

2 release files

This release

0.1.1 This release

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