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
That installs no web server. It is the whole install for using the framework as a library: modules,
providers and injection resolved through create_app_context, with no HTTP served. Serving HTTP
needs a transport, and bustan init puts the extra for the shipped adapter onto the requirement it
finds, so a scaffolded project never names one by hand.
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
uv run bustan init
uv sync
uv run dev
bustan init writes a runnable application and its tests, and declares in pyproject.toml
everything the project needs to serve, test, lint and type-check: the transport extra on the
bustan requirement, the start and dev scripts, and a dev group holding pytest, ruff and ty.
That is why one uv sync follows it and no second install step does. Call the app:
curl http://127.0.0.1:3000/
{"message":"Hello from My App"}
What init writes:
src/my_app/ app_main.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
app_main.py holds the entry points the two scripts run, and uv run dev is uvicorn watching
src/, so an edited handler answers the next request. A file already in the project is kept and
reported as kept rather than overwritten - here README.md and the src/my_app/__init__.py that
uv init wrote - so a second bustan init destroys no work. Pass --force to replace a file that
was kept.
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.1
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.1.tar.gz | 280.1 kB | With provenance | Details for bustan-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bustan-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for bustan-2.0.1-py3-none-any.whl |
Total release size: 638.8 kB
Release files / bustan-2.0.1.tar.gz
| Download URL | bustan-2.0.1.tar.gz |
|---|---|
| Size | 280.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1761f928b76ee6f25221bfd2fce79ade728ac2d1fefae1b1e21a8b77ce611f43
|
|
BLAKE2b-256 checksum How to use checksums |
291a7adbaafc367404618d4038fd3dd94aea3910fbc9d1f2e7593f04d4ecd9d2
|
| 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 12, 2026.
Transparency logRelease files / bustan-2.0.1-py3-none-any.whl
| Download URL | bustan-2.0.1-py3-none-any.whl |
|---|---|
| Size | 358.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e996c6781ca4d5018c2338521e7b0519dfd7ed493c6e59e5864703371a82c1e7
|
|
BLAKE2b-256 checksum How to use checksums |
28f80558400ea3d6857fa05467a7c582a7429212af4c0e4a9def6ffa9ad3276b
|
| 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 12, 2026.
Transparency logSecurity for bustan 2.0.1
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.1.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 12, 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.