Skip to main content

sonnet-server

The web layer for Petrarca Labs backend services. A FastAPI application factory, an extension mechanism for composing subsystems, and the infrastructure that sits behind a request: database wiring, messaging, caching, guards and readiness.

Version 0.6.0. It is a library, not a running service -- the consuming application owns its entry point and its factory call (ADR-0001).

What it provides

  • Application factory -- create_app wires logging, DI, profiles, extension lifecycle, exception handlers, CORS and the system endpoints (/ping, /version, /health-check), and returns the app plus a startup check coroutine.
  • Extensions -- opt-in subsystem lifecycle with routers, middleware and checks contributed per capability. Extensions may live in other packages.
  • Routing and guards -- router factories that apply preconditions (authenticated caller, tenant context, per-request session) before a handler runs, with the implementations filled by protocol slots.
  • List endpoints -- one pagination envelope with sorting, search and declared client filters.
  • Messaging -- a content-based router over in-process, PostgreSQL LISTEN/NOTIFY, NATS and RabbitMQ channels, with a CloudEvents envelope and request/reply.
  • Caching -- a managed cache with local, distributed and near-cache modes and cross-process invalidation.
  • Readiness stages -- concrete database, messaging and cache checks on the sonnet-core engine.
  • Settings and profiles -- a Settings base you subclass with your own env prefix, and per-deployment subsystem toggles.

Command-line building blocks are not here. They live in sonnet-cli; this package depends on neither typer nor rich. The data layer -- repositories, sessions, filtering, the readiness engine -- lives in sonnet-core, which comes with this package.

Install

uv add "sonnet-server[postgres]"
Extra Adds Use when
postgres psycopg Always, in practice -- PostgreSQL is the target database.
filtering lark Accepting client filter expressions.
graphql strawberry-graphql Serving GraphQL.
nats nats-py Using NATS as the message broker.
rabbitmq aio-pika Using RabbitMQ as the message broker.
redis redis Using a distributed or near cache.
all all of the above Development, or a service that uses most of it.

For a project file, pin the current floor:

[project]
dependencies = ["sonnet-server[all]>=0.6.0"]

Usage

Register the extensions the service needs and hand them to the factory. The factory drives them in registration order and does not know what any of them are.

from sonnet_server.app import create_app
from sonnet_server.database.extension import DatabaseExtension
from sonnet_server.extensions import create_extension_registry

_registry = create_extension_registry(
    DatabaseExtension(),
    RestExtension(),
)

app, perform_startup_checks = create_app(
    extension_registry=_registry,
    register_services=register_all_services,
    title="My Server",
    server_name="my_server",
)

Infrastructure extensions go first. See the usage guides for settings, routing, list endpoints, messaging, caching and GraphQL.

Documentation

License

Apache 2.0 -- see LICENSE.md.

Metadata

Release files for sonnet-server 0.9.0

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

Source distribution (sdist)

Source distribution for sonnet-server 0.9.0
File Size Uploaded Provenance Actions
sonnet_server-0.9.0.tar.gz 124.5 kB With provenance Details for sonnet_server-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sonnet-server 0.9.0
File Interpreter ABI Platform Actions
sonnet_server-0.9.0-py3-none-any.whl Python 3 none any Details for sonnet_server-0.9.0-py3-none-any.whl

Total release size: 284.4 kB

Release files / sonnet_server-0.9.0.tar.gz

Download URL sonnet_server-0.9.0.tar.gz
Size 124.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5e7e317e1d23d48394796e2569e466c5224efc45f77b27be72fe273543a60010
BLAKE2b-256 checksum
How to use checksums
17c781495bcca53279c81e6a58c2acb7f5e472acd9bd14d3bd6c717be35b3178
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Release files / sonnet_server-0.9.0-py3-none-any.whl

Download URL sonnet_server-0.9.0-py3-none-any.whl
Size 159.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2794588d9042e85dfcac0e62bdac6565e76ce86c74a16f4cc23b9e4969406009
BLAKE2b-256 checksum
How to use checksums
58bd2a8341517b3f910ad3e374e508de07b912b365c3b881dfeeaea9e1377978
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 11, 2026.

Transparency log

Security for sonnet-server 0.9.0

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 sonnet_server-0.9.0.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 Nov 11, 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