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_appwires 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-coreengine. - Settings and profiles -- a
Settingsbase 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
- Usage --
docs/usage/index.md - Design --
docs/design/index.md - Workspace --
../../docs/README.md
License
Apache 2.0 -- see LICENSE.md.
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 sonnet_server-0.8.0.tar.gz.
File metadata
- Download URL: sonnet_server-0.8.0.tar.gz
- Upload date:
- Size: 112.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b009e7747191f4ed261b838835117f1341a379a0f0830fd01bbf86ec87f2b39
|
|
| MD5 |
03cf751ece05812d185cfd6dcc1ad02d
|
|
| BLAKE2b-256 |
f6a7aad54031e5fc471ee15bb94d09521a2fee48cbabb941601b79182cbdb300
|
Provenance
The following attestation bundles were made for sonnet_server-0.8.0.tar.gz:
Publisher:
publish.yml on petrarca/sonnet-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonnet_server-0.8.0.tar.gz -
Subject digest:
8b009e7747191f4ed261b838835117f1341a379a0f0830fd01bbf86ec87f2b39 - Sigstore transparency entry: 2567955677
- Sigstore integration time:
-
Permalink:
petrarca/sonnet-server@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/petrarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonnet_server-0.8.0-py3-none-any.whl.
File metadata
- Download URL: sonnet_server-0.8.0-py3-none-any.whl
- Upload date:
- Size: 144.1 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 |
bbeea52c97aaa1f5df2590cd911dca477fcb45364a008a6f8c6e7c974370d33e
|
|
| MD5 |
e88bf9fa152947884733b5fb36774549
|
|
| BLAKE2b-256 |
de9b9cbb53a0440ae50f2ccbfaf3203a07eb7a5cc04710d4dcfc5f29f046cf26
|
Provenance
The following attestation bundles were made for sonnet_server-0.8.0-py3-none-any.whl:
Publisher:
publish.yml on petrarca/sonnet-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonnet_server-0.8.0-py3-none-any.whl -
Subject digest:
bbeea52c97aaa1f5df2590cd911dca477fcb45364a008a6f8c6e7c974370d33e - Sigstore transparency entry: 2567955995
- Sigstore integration time:
-
Permalink:
petrarca/sonnet-server@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/petrarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@8fb257794749ed1922438cbfb5ef82eeb548d71d -
Trigger Event:
push
-
Statement type: