Skip to main content
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

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

MIT

Metadata

Release files for bustan 2.0.2

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.2
File Size Uploaded Provenance Actions
bustan-2.0.2.tar.gz 280.2 kB With provenance Details for bustan-2.0.2.tar.gz

Built distribution (wheel)

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

Total release size: 639.0 kB

Release files / bustan-2.0.2.tar.gz

Download URL bustan-2.0.2.tar.gz
Size 280.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2abd6b72d5c6aef63fb5ff7e2195d370a99b4683c26e1125183d2b8b93ef37eb
BLAKE2b-256 checksum
How to use checksums
f7101dfd5664134d2d85338eca5c5789f974a3c066baa813c29b822c4544e31a
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 14, 2026.

Transparency log

Release files / bustan-2.0.2-py3-none-any.whl

Download URL bustan-2.0.2-py3-none-any.whl
Size 358.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d2548e9b715de4bd98dd886cc22f587d582836be265f733ee43e313639a2cd4
BLAKE2b-256 checksum
How to use checksums
e59b62179530fd336deb20faf6215af0441e9a7ee22948c75f02d1b82631ecf1
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 14, 2026.

Transparency log

Security for bustan 2.0.2

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.2.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 14, 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