Skip to main content

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.

PyPI version Python 3.11+ MIT License PyPI downloads

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 with python -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): The fastware command-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 the fastware dev CLI.
  • 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 the fastware dev CLI.
  • 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

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastware-0.6.1.tar.gz (376.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastware-0.6.1-py3-none-any.whl (101.0 kB view details)

Uploaded Python 3

File details

Details for the file fastware-0.6.1.tar.gz.

File metadata

  • Download URL: fastware-0.6.1.tar.gz
  • Upload date:
  • Size: 376.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fastware-0.6.1.tar.gz
Algorithm Hash digest
SHA256 9254c9546777c72c910137b1a25655aa6de0768559d6dfefecb89953bfe2a1b5
MD5 d982c4081eff3f908d8260905d98e8e5
BLAKE2b-256 8469ee5c1cb46ae7155f20ed6723b87f16336c92237a26ff9c1f9510e32c27c5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastware-0.6.1.tar.gz:

Publisher: publish.yml on smm-h/fastware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fastware-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: fastware-0.6.1-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

Hashes for fastware-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 04831019261df0fc261cc8cf9554e150f8653c0aa912a09e9ae1802a61c2078d
MD5 ff2ed8f3fe8c7f94eb76b81938c99f80
BLAKE2b-256 ceb97cb2b09135c94d9bef85012bf49d5b02b8b1c40f272cab199e8f1c1ff184

See more details on using hashes here.

Provenance

The following attestation bundles were made for fastware-0.6.1-py3-none-any.whl:

Publisher: publish.yml on smm-h/fastware

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.6.2

2 files

This release

0.6.1 This release

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.1

2 files

0.2.0

2 files

0.1.0

2 files

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