Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Bustan

A modular architecture engine for building scalable, testable ASGI applications in Python.

CI PyPI Python License

Bustan gives Python projects explicit composition boundaries, constructor injection, lifecycle hooks and a predictable request pipeline, while still exposing the underlying platform directly. The design follows NestJS; the semantics are Python's.

The HTTP transport sits behind an adapter port. Two adapters ship - Starlette, the default, and a raw ASGI one needing no third-party web framework - and both are held to the same conformance suite. An application that serves no HTTP needs neither.

Why Bustan

  • Modules as real composition boundaries, not ad hoc import graphs.
  • Thin controllers, with business logic in dependency-injected providers.
  • Guards, pipes, interceptors and exception filters in a documented order.
  • Direct access to the underlying platform through the public Application wrapper.
  • Applications you can test with focused module builders, route snapshots and provider overrides.

Install

Requires Python 3.13 or newer and uv, which is the only supported package manager.

uv add 'bustan[starlette]'

Plain bustan installs no web server. That is the install for using the framework as a library: modules, providers and injection resolved through create_app_context, with no HTTP served.

Bustan is built, locked, tested and released with uv throughout. Another installer may resolve the package, but nothing here is tested against one and no issue is accepted for one.

Quickstart

uv init --package my-app
cd my-app
uv add 'bustan[starlette]'
uv add --dev pytest ruff ty
uv run bustan init
uv run dev

That scaffolds a runnable application, its tests, and start and dev script entries. Call it:

curl http://127.0.0.1:3000/
{"message":"Hello from My App"}

The generated package:

src/my_app/          __init__.py  app_module.py  app_controller.py  app_service.py
tests/my_app/        test_app_controller.py  test_app_module.py  test_app_service.py

For the walkthrough, the generated file contents and a first test, see Your first app - the first of six tutorials that build a working link shortener from this scaffold.

Documentation

Read the docs, organised by what you are doing:

Tutorials Learning. One path, start to finish.
How-to guides A task in hand: deploy, observe, harden, migrate, test.
Reference Looking something up: API, CLI, errors, routing, lifecycle.
Explanation Understanding: request scope, layering, the security model.

Upgrading from 1.x? 2.0 is a clean break and a 1.x application will not start on it until it is corrected. Start at Migrate from 1.x; bustan doctor finds most of it for you.

What you get

Composition and injection. Module discovery, validation and export-based visibility. Constructor injection for providers and controllers, with scope rules enforced while the application is built rather than on the request that trips them. Singleton, request, durable and transient lifetimes, plus request-scoped controllers. Dynamic modules and ConfigurableModuleBuilder.

Serving requests. Route compilation onto either adapter behind one port. Inferred and explicit binding with Annotated[...] markers. Response coercion for the neutral HttpResponse, the transport's own responses, dataclasses, iterators, Path and None. Middleware, guards, pipes, interceptors and exception filters. Automatic Pydantic validation. An HttpException family covering fifteen statuses, rendered as RFC 9457 problem details - including the responses the router itself produces. Finite request limits an application serves under whether or not it configures them.

Running in production. Lifecycle hooks wired through the adapter's lifespan. Graceful shutdown: readiness turns negative, in-flight requests drain, teardown hooks run with the signal's name, the port is released. Liveness and readiness probes. Correlation ids, request timing, and pluggable metrics and tracing sinks. Configuration, OpenAPI, throttling and CORS.

Tooling. Application and ApplicationContext bootstrapping, route snapshots and diffs, runtime discovery, and a CLI: init, doctor, graph, routes, config, governance.

Supported public API

The compatibility boundary is deliberately small: bustan, bustan.errors, bustan.testing.

from bustan import Application, Controller, Get, Injectable, Module, create_app, create_app_context
from bustan.errors import ProviderResolutionError
from bustan.testing import create_test_app, create_testing_module

Everything else - bustan.kernel.*, bustan.app.*, bustan.runtime.*, bustan.adapters.* - is an implementation detail and may be restructured without notice. Stability is the authority on that boundary, and the export sets derive from it. The supported Python floor is >=3.13.

Examples

Each is a standalone project. Browse them, or run one:

cd examples/blog_api
uv sync --group dev
uv run python -m blog_api.app

Contributing

Issues and pull requests are welcome. CONTRIBUTING.md covers development setup and the checks to run; GOVERNANCE.md covers how decisions get made.

uv sync --group dev
uv run lefthook install
uv run pytest

Report vulnerabilities privately, following SECURITY.md, not through public issues. Participation is governed by the Code of Conduct.

Project direction

Bustan is opinionated about application structure, not about hiding the underlying platform or competing on benchmark claims. If you want a small ASGI core with explicit module boundaries, injected services, lifecycle hooks and a predictable request pipeline, that is the target.

License

MIT

Metadata

Release files for bustan 2.0.0rc6

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

Source distribution (sdist)

Source distribution for bustan 2.0.0rc6
File Size Uploaded Provenance Actions
bustan-2.0.0rc6.tar.gz 260.1 kB With provenance Details for bustan-2.0.0rc6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bustan 2.0.0rc6
File Interpreter ABI Platform Actions
bustan-2.0.0rc6-py3-none-any.whl Python 3 none any Details for bustan-2.0.0rc6-py3-none-any.whl

Total release size: 596.6 kB

Release files / bustan-2.0.0rc6.tar.gz

Download URL bustan-2.0.0rc6.tar.gz
Size 260.1 kB
Tags Source
SHA-256 checksum
How to use checksums
b4774e7b859303cd2318438feeff50059f33f07b7bf6b884d8ee539b8c4276b0
BLAKE2b-256 checksum
How to use checksums
4178d1c870c32856cb8c066d1c9c6d5c47a0edb1c749562874a8a6d514ad58cd
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 Sep 9, 2026.

Transparency log

Release files / bustan-2.0.0rc6-py3-none-any.whl

Download URL bustan-2.0.0rc6-py3-none-any.whl
Size 336.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cebd702b3c0a31be00298a9ee732c589eb292d3caf7b19c1412e1cbbf3378512
BLAKE2b-256 checksum
How to use checksums
4cc060d0db4b0771e26d63ae9dd5327e00efe78f12ee1590a49d562b8743ba0b
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 Sep 9, 2026.

Transparency log

Security for bustan 2.0.0rc6

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bustan-2.0.0rc6.tar.gz

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 Sep 9, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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