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.

Download files

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

Source Distribution

sonnet_server-0.8.0.tar.gz (112.6 kB view details)

Uploaded Source

Built Distribution

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

sonnet_server-0.8.0-py3-none-any.whl (144.1 kB view details)

Uploaded Python 3

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

Hashes for sonnet_server-0.8.0.tar.gz
Algorithm Hash digest
SHA256 8b009e7747191f4ed261b838835117f1341a379a0f0830fd01bbf86ec87f2b39
MD5 03cf751ece05812d185cfd6dcc1ad02d
BLAKE2b-256 f6a7aad54031e5fc471ee15bb94d09521a2fee48cbabb941601b79182cbdb300

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_server-0.8.0.tar.gz:

Publisher: publish.yml on petrarca/sonnet-server

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

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

Hashes for sonnet_server-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bbeea52c97aaa1f5df2590cd911dca477fcb45364a008a6f8c6e7c974370d33e
MD5 e88bf9fa152947884733b5fb36774549
BLAKE2b-256 de9b9cbb53a0440ae50f2ccbfaf3203a07eb7a5cc04710d4dcfc5f29f046cf26

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_server-0.8.0-py3-none-any.whl:

Publisher: publish.yml on petrarca/sonnet-server

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.8.1

2 files

This release

0.8.0 This release

2 files

0.7.1

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.0

2 files

0.3.0

2 files

0.2.1

2 files

0.2.0

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

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