This release is a pre-release and may not be stable for production use.
A modular architecture engine for building scalable, testable ASGI applications in Python.
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
Applicationwrapper. - 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
Metadata
Release files for bustan 2.0.0rc7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bustan-2.0.0rc7.tar.gz | 272.4 kB | With provenance | Details for bustan-2.0.0rc7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bustan-2.0.0rc7-py3-none-any.whl | Python 3 | none | any | Details for bustan-2.0.0rc7-py3-none-any.whl |
Total release size: 622.3 kB
Release files / bustan-2.0.0rc7.tar.gz
| Download URL | bustan-2.0.0rc7.tar.gz |
|---|---|
| Size | 272.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5ee281e3898a15bb6f8094d6b63f7834547c7dfaf1d4759ae1055f6a11eef6bc
|
|
BLAKE2b-256 checksum How to use checksums |
5a49162d937115da474c061c5560404a3ad364589701068f48805741c1e4a93e
|
| 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 logRelease files / bustan-2.0.0rc7-py3-none-any.whl
| Download URL | bustan-2.0.0rc7-py3-none-any.whl |
|---|---|
| Size | 349.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0555a21a07f4c565e0bf0ef498f66be16a12cefe2d82dfbefb49a69bd840dbb6
|
|
BLAKE2b-256 checksum How to use checksums |
3ccc1f2a20464e7c54ec7420db17e835fe07d03e20bceb5eb59e5ee1adccb36d
|
| 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 logSecurity for bustan 2.0.0rc7
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.
Attestation for bustan-2.0.0rc7.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 logA 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.