fastware
fastware is a batteries-included ASGI framework that pairs msgspec JSON with a managed Granian server, dependency injection, SSE, WebSockets, auth and a test client. It is for Python teams building JSON and streaming APIs who would rather have those pieces assembled than gather them from separate packages. Its core installs only msgspec and Granian; everything else -- auth, structured logging, testing, MCP support and Pydantic integration -- is an opt-in extra.
Why fastware?
- msgspec for JSON -- 10-75x faster serialization than Pydantic. No schema compilation step, no startup penalty.
- Granian server included -- Rust-based ASGI server with managed lifecycle, PID files, and signal handling. No need to install or configure a separate server.
- Batteries included -- SSE broadcasting, dependency injection, authentication (JWT + passwords + CSRF), middleware suite (CORS, tracing, trusted host), test client, background tasks, and structured logging are all built in.
- Minimal core dependencies -- The framework core depends only on msgspec and granian. Everything else is opt-in via extras.
Quick example
import msgspec
from fastware import Router, JSONResponse, create_app, serve
router = Router()
class User(msgspec.Struct):
id: int
name: str
email: str
USERS = {
1: User(id=1, name="Alice", email="alice@example.com"),
2: User(id=2, name="Bob", email="bob@example.com"),
}
@router.get("/users")
async def list_users(req):
return JSONResponse([u for u in USERS.values()])
@router.get("/users/{id:int}")
async def get_user(req):
user = USERS.get(req.path_params["id"])
if not user:
return JSONResponse({"error": "not found"}, status=404)
return JSONResponse(user)
app = create_app(router)
if __name__ == "__main__":
serve(app, foreground=True, host="127.0.0.1", port=8000)
Feature overview
- src.fastware (
src/fastware/__init__.py): A batteries-included ASGI framework that pairs msgspec JSON with a managed Granian server, dependency injection, SSE, WebSockets, auth and a test client. - src.fastware.main (
src/fastware/__main__.py): Enable running the fastware CLI withpython -m fastware. - src.fastware._assets (
src/fastware/_assets.py): Framework browser assets (service workers, registration snippet, update client) shipped as package data and rendered with per-app substitutions. - src.fastware._fswrite (
src/fastware/_fswrite.py): A small thread-safe file writer shared by the append/overwrite call sites. - src.fastware._scope (
src/fastware/_scope.py): Scope-level header and cookie access shared across the ASGI layer. - src.fastware.app (
src/fastware/app.py): ASGI application factory with middleware chain composition, static file serving, SPA fallback routing, async lifespan hooks, and WebSocket support. - src.fastware.audit (
src/fastware/audit.py): Append-only JSONL audit log writer for recording timestamped application events with structured payloads, using thread-safe file writes. - src.fastware.auth (
src/fastware/auth.py): Authentication module providing JWT token creation and verification, bcrypt password hashing, user storage, CSRF protection, and rate limiting. - src.fastware.cli (
src/fastware/cli.py): Thefastwarecommand-line interface (strictcli). - src.fastware.config (
src/fastware/config.py): Config loading utility providing standalone TOML config file parsing with optional Pydantic validation. - src.fastware.dev (
src/fastware/dev.py): Development mode combining Vite frontend dev server and fastware ASGI backend in a single command with hot reload and proxy routing. - src.fastware.devconfig (
src/fastware/devconfig.py): File-driven dev configuration for thefastware devCLI. - src.fastware.di (
src/fastware/di.py): Dependency injection container providing per-request resolution with automatic caching, generator cleanup, and scope-aware dependency override support. - src.fastware.error_log (
src/fastware/error_log.py): SQLite-backed error log for recording and querying 5xx server responses with request context, tracebacks, and timestamps for post-mortem analysis. - src.fastware.features (
src/fastware/features.py): Boolean feature flags with per-machine JSON overrides, providing enabled/disabled checks, runtime toggle, and hot reload for gradual rollouts. - src.fastware.logging (
src/fastware/logging.py): Structured logging configuration using structlog with automatic JSON output in production and colored console rendering in development mode. - src.fastware.mcp (
src/fastware/mcp.py): MCP (Model Context Protocol) server factory providing role-based agent tool provisioning, tool filtering, and stdio-based server lifecycle management. - src.fastware.middleware (
src/fastware/middleware.py): Pure ASGI middleware for request tracing, CORS headers, trusted-host validation, and Vite dev proxy routing, all streaming-safe for SSE and WebSocket. - src.fastware.request (
src/fastware/request.py): HTTP request wrapper providing lazy body parsing, query parameter extraction, JSON deserialization via msgspec, header access, and per-request state. - src.fastware.responses (
src/fastware/responses.py): HTTP response types including JSON, text, HTML, bytes, and streaming responses, plus cookie helpers and low-level ASGI send functions. - src.fastware.routing (
src/fastware/routing.py): Path-based HTTP router with curly-brace parameter placeholders, automatic type coercion, method-based dispatch, and route group composition. - src.fastware.server (
src/fastware/server.py): Granian ASGI server lifecycle management with PID file tracking, port availability checks, foreground and background serve modes, and graceful stop. - src.fastware.sse (
src/fastware/sse.py): SSE (Server-Sent Events) broadcaster with typed event registration, per-client async queues, automatic disconnect pruning, and strict mode enforcement. - src.fastware.supervise (
src/fastware/supervise.py): Process supervision for thefastware devCLI. - src.fastware.tasks (
src/fastware/tasks.py): Background task registry with feature-gated lifecycle management, supporting start/stop protocol, factory registration, and graceful shutdown ordering. - src.fastware.testing (
src/fastware/testing.py): Sync and async test clients for fastware apps, wrapping httpx with ASGITransport to exercise routes without starting a real network server. - src.fastware.types (
src/fastware/types.py): ASGI type aliases (Scope, Receive, Send) used throughout fastware for consistent type-checked request and response handling. - src.fastware.websocket (
src/fastware/websocket.py): WebSocket helper class wrapping the raw ASGI scope/receive/send triple with typed accept, send, receive, and close methods for ergonomic usage.
Installation
pip install fastware # core only
pip install fastware[auth] # + JWT, password hashing, CSRF
pip install fastware[testing] # + async test client (httpx)
pip install fastware[all] # everything
Dependencies
| Package | Version Constraint |
|---|---|
msgspec |
>=0.21.1 |
granian |
>=2.7,<3.0 |
strictcli |
>=0.41.0 |
| [auth] | |
pyjwt |
* |
bcrypt |
* |
| [logging] | |
structlog |
* |
| [dev] | |
httpx |
>=0.28 |
watchfiles |
* |
websockets |
* |
| [testing] | |
httpx |
>=0.28 |
| [mcp] | |
mcp |
* |
| [pydantic] | |
pydantic |
* |
| [all] | |
fastware[auth] |
* |
fastware[logging] |
* |
fastware[dev] |
* |
fastware[testing] |
* |
fastware[mcp] |
* |
fastware[pydantic] |
* |
Project structure
fastware/
├── __init__.py
├── __main__.py
├── _assets/
├── _assets.py
├── _fswrite.py
├── _scope.py
├── app.py
├── audit.py
├── auth.py
├── cli.py
├── config.py
├── dev.py
├── devconfig.py
├── di.py
├── error_log.py
├── features.py
├── logging.py
├── mcp.py
├── middleware.py
├── request.py
├── responses.py
├── routing.py
├── server.py
├── sse.py
├── supervise.py
├── tasks.py
├── testing.py
├── types.py
└── websocket.py
How it compares
| Feature | fastware | FastAPI | Starlette | Litestar |
|---|---|---|---|---|
| JSON engine | msgspec | Pydantic | none (BYO) | msgspec or attrs |
| ASGI server | Granian (included) | BYO (uvicorn) | BYO (uvicorn) | BYO (uvicorn) |
| SSE built-in | yes | no | no | yes |
| DI built-in | yes | yes | no | yes |
| Server lifecycle | PID files, signals, status checks | none | none | none |
| SPA fallback | yes | no | no | no |
| Test client | built-in (httpx) | via Starlette | yes | yes |
| Middleware suite | CORS, tracing, trusted host, Vite proxy | via Starlette | yes | yes |
Documentation
Full documentation is available at smmh.dev/fastware.
Built on fastware
- wesktop -- a Python framework for building web-based desktop applications, using fastware for its ASGI layer and server lifecycle.
License
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastware-0.6.2.tar.gz.
File metadata
- Download URL: fastware-0.6.2.tar.gz
- Upload date:
- Size: 377.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
924779d2a031690aec0ac3c0e33475ae8683ad30ef10796b9d2629ee5d5b2ead
|
|
| MD5 |
12582355135f20ddd16453a62c2712b5
|
|
| BLAKE2b-256 |
8533ee3f7738038bc47bea3cbf59c04c6e1df3f6cc38c020ce5976784b793643
|
Provenance
The following attestation bundles were made for fastware-0.6.2.tar.gz:
Publisher:
publish.yml on smm-h/fastware
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastware-0.6.2.tar.gz -
Subject digest:
924779d2a031690aec0ac3c0e33475ae8683ad30ef10796b9d2629ee5d5b2ead - Sigstore transparency entry: 2833419738
- Sigstore integration time:
-
Permalink:
smm-h/fastware@25f78b0cc98922a23a6dfa1ec8d5ff75f0b2d3aa -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/smm-h
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@25f78b0cc98922a23a6dfa1ec8d5ff75f0b2d3aa -
Trigger Event:
release
-
Statement type:
File details
Details for the file fastware-0.6.2-py3-none-any.whl.
File metadata
- Download URL: fastware-0.6.2-py3-none-any.whl
- Upload date:
- Size: 101.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd6bd23c6e011353bef9f3aac6ac57a322b0ec633d6da8d9b5be7396439e739f
|
|
| MD5 |
4d2fb59b8895f0235620ba41d4601180
|
|
| BLAKE2b-256 |
521e5d8a11e6d5ad8d598bbeef52035bd9741ed9610de26f9995a6c05fee66df
|
Provenance
The following attestation bundles were made for fastware-0.6.2-py3-none-any.whl:
Publisher:
publish.yml on smm-h/fastware
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fastware-0.6.2-py3-none-any.whl -
Subject digest:
dd6bd23c6e011353bef9f3aac6ac57a322b0ec633d6da8d9b5be7396439e739f - Sigstore transparency entry: 2833419752
- Sigstore integration time:
-
Permalink:
smm-h/fastware@25f78b0cc98922a23a6dfa1ec8d5ff75f0b2d3aa -
Branch / Tag:
refs/tags/v0.6.2 - Owner: https://github.com/smm-h
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@25f78b0cc98922a23a6dfa1ec8d5ff75f0b2d3aa -
Trigger Event:
release
-
Statement type: