Skip to main content

Litestar Autowire

Domain package discovery for Litestar applications.

litestar-autowire lets a Litestar app treat each feature or bounded context as a small Python package. Group the domain's controllers, listeners, and jobs together, then wire the domain root into the app once.

Use it when your app has a domains/ package and each domain owns its Litestar surface:

my_app/
  domains/
    accounts/
      controllers.py
      events.py
      jobs.py
    billing/
      controllers.py

Installation

pip install litestar-autowire

Optional integrations:

pip install "litestar-autowire[dishka]"
pip install "litestar-autowire[queues]"

Quick Start

Define normal Litestar controllers inside a domain package:

# my_app/domains/accounts/controllers.py
from litestar import Controller, get


class AccountController(Controller):
    path = "/accounts"

    @get("/", sync_to_thread=False)
    def list_accounts(self) -> dict[str, str]:
        return {"status": "ok"}

Register the domain root once:

from litestar import Litestar
from litestar_autowire import AutowireConfig, AutowirePlugin

app = Litestar(
    plugins=[
        AutowirePlugin(
            AutowireConfig(domain_packages=["my_app.domains"]),
        )
    ],
)

Autowire checks the configured domain package root and its direct child domain packages for these module names:

  • controllers: controllers, routes, controller, route
  • listeners: events, listeners
  • queue tasks: jobs

By default, Autowire defers discovery logs to the Litestar startup lifespan. The summary includes the number of loaded controllers, domains, listeners, and tasks. Debug logs include the controller inventory grouped by domain. Set log_discovered=False to disable these logs.

Integrations

Built-in integrations use string aliases:

AutowireConfig(
    domain_packages=["my_app.domains"],
    integrations=["dishka", "queues"],
)
  • dishka: wrap discovered controllers in Dishka's Litestar router. Configure Dishka separately with setup_dishka(...).
  • queues: import task modules through litestar_queues.discover_tasks. Configure QueuePlugin separately in the Litestar app.

Unknown string aliases raise ValueError so typos do not silently disable an integration.

Use AutowireLoader when another registry needs each discovered domain module loaded:

from litestar_autowire import AutowireConfig, AutowireLoader

config = AutowireConfig(
    domain_packages=["my_app.domains"],
    integrations=[
        AutowireLoader(
            name="inventory_jobs",
            modules="jobs",
            loader="my_app.jobs:discover_jobs",
        )
    ],
)

The loader receives existing module paths such as my_app.domains.accounts.jobs. Use the pkg.module:func form to make the module import and callable lookup explicit. If the loader returns an integer, Autowire adds it to the startup task count.

For custom behavior, pass an integration object:

from litestar_autowire import AutowireConfig, AutowireContext


class InventoryIntegration:
    name = "inventory"

    def on_autowire(self, context: AutowireContext) -> None:
        context.app_config.state["autowire_domain_packages"] = context.config.domain_packages


config = AutowireConfig(
    domain_packages=["my_app.domains"],
    integrations=[InventoryIntegration()],
)

Custom integration names cannot reuse built-in names.

Development

uv sync --all-extras --dev
make lint
make test
make docs

Metadata

Release files for litestar-autowire 0.2.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 litestar-autowire 0.2.0
File Size Uploaded
litestar_autowire-0.2.0.tar.gz 151.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for litestar-autowire 0.2.0
File Interpreter ABI Platform
litestar_autowire-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 165.0 kB

Release files / litestar_autowire-0.2.0.tar.gz

Download URL litestar_autowire-0.2.0.tar.gz
Size 151.9 kB
Tags Source
SHA-256 checksum
How to use checksums
db71621dec2563bd84eecea9377080ec1ec3b30ce5c4afae36bf8f440e2a51fc
BLAKE2b-256 checksum
How to use checksums
974580b71ce065883100863f2c614acb15fa66e95b856a1ca3755543c967b2f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 7, 2026.

Transparency log

Release files / litestar_autowire-0.2.0-py3-none-any.whl

Download URL litestar_autowire-0.2.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba4811777fbb01a53ac2f02841f2ecd595740b80c7135fdc74443193623b1e79
BLAKE2b-256 checksum
How to use checksums
98c1abc6042f0b06cb9665a58df9a01d7a51cde73e2f32255e5b5017a93477b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 Jul 7, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 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