On this page
Documentation for fastware, a fast batteries-included ASGI framework built on msgspec (10-75x faster JSON) and Granian (Rust-based server).
#fastware
A fast, batteries-included ASGI framework. The FastAPI alternative.
Current version: 0.1.0
#Install
pip install fastware#Minimal example
from fastware import Router, create_app, serve
router = Router()
@router.get("/hello/{name}")
async def hello(request):
return {"message": f"Hello, {request.path_params['name']}!"}
app = create_app(router)
serve(app, foreground=True, host="127.0.0.1", port=8000)Run it and visit http://127.0.0.1:8000/hello/world to see {"message": "Hello, world!"}.
#Features
| Feature | Description | Docs |
|---|---|---|
| Routing and Requests | Path parameters with type coercion, query validation, request body parsing, WebSocket routes | Core API |
| SSE Broadcasting | Typed server-sent events with per-client queues and automatic disconnect pruning | SSE Guide |
| Middleware Suite | CORS, request tracing, trusted host, request ID, Vite dev proxy -- all pure ASGI | Middleware API |
| Auth and Security | JWT tokens, bcrypt password hashing, CSRF double-submit, role-based access, rate limiting | Auth API |
| Server Lifecycle | Granian integration with PID files, port checks, background mode, status, and hot reload | Server API |
| Dependency Injection | Per-request DI with sync/async factories, generator cleanup, caching, and test overrides | DI Guide |
| Testing | Sync and async test clients wrapping httpx with ASGITransport -- no real server needed | Testing API |
| Migration from FastAPI | Side-by-side comparison and step-by-step guide for porting FastAPI applications | Migration Guide |
#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, middleware suite, 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.
#Dependencies
The table below lists all runtime and optional dependencies that fastware can install. The core has only 2 required packages (msgspec for JSON serialization and granian for ASGI serving); all others are opt-in via 6 extras groups (auth, logging, dev, testing, mcp, pydantic) that add specific capabilities without bloating the default install:
| Package | Version Constraint |
|---|---|
msgspec | >=0.21.1 |
granian | >=2.7.4 |
| [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
The source tree consists of 20 modules organized by feature area (routing, responses, middleware, SSE, server, auth, DI, testing, and more). Each module is independently importable with no circular dependencies, and optional features use late imports to avoid loading unused packages:
fastware/
├── __init__.py
├── __main__.py
├── app.py
├── audit.py
├── auth.py
├── config.py
├── dev.py
├── di.py
├── error_log.py
├── features.py
├── logging.py
├── mcp.py
├── middleware.py
├── request.py
├── responses.py
├── routing.py
├── server.py
├── sse.py
├── tasks.py
├── testing.py
├── types.py
└── websocket.py