Skip to main content

fastware

A batteries-included ASGI framework: msgspec JSON, 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: msgspec JSON, 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

Metadata

Release files for fastware 0.6.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fastware 0.6.3
File Size Uploaded
fastware-0.6.3.tar.gz 378.6 kB Details

Built distribution (wheel)

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

Total release size: 479.6 kB

Release files / fastware-0.6.3.tar.gz

Download URL fastware-0.6.3.tar.gz
Size 378.6 kB
Tags Source
SHA-256 checksum
How to use checksums
53dca6813292da70d1b72373d7858d774dfc1fa95e1369eb1bacdea79c435784
BLAKE2b-256 checksum
How to use checksums
81b74ab11c89eb9a3c174d2465ca6bd6a633aa8817d458c23b2fa32a2cfe31ea
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 15, 2026.

Transparency log

Release files / fastware-0.6.3-py3-none-any.whl

Download URL fastware-0.6.3-py3-none-any.whl
Size 101.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
56146a5a45d5620563d146f12e103a81118070f6c9f45a30fa65d508b85996c6
BLAKE2b-256 checksum
How to use checksums
a50b3b5d17d00bd38302d11ab2001b7fb3f5107adfbafc80cb5779bbce30414d
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 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.6.3 This release

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.2.0

2 release files

0.1.0

2 release 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