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.7.1.tar.gz (119.5 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.7.1-py3-none-any.whl (153.4 kB view details)

Uploaded Python 3

File details

Details for the file sonnet_server-0.7.1.tar.gz.

File metadata

  • Download URL: sonnet_server-0.7.1.tar.gz
  • Upload date:
  • Size: 119.5 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.7.1.tar.gz
Algorithm Hash digest
SHA256 7762fe8fb2984796fce24cc080407e9db1c4c5099c60b9464a31c29ecc471d5f
MD5 0131af4666be0297c6bc97bd6883139b
BLAKE2b-256 82e485faa5db7286a17f0ae922d7c4e1d61c2ff0ca4ed952a5d49d2fe8978106

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_server-0.7.1.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.7.1-py3-none-any.whl.

File metadata

  • Download URL: sonnet_server-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 153.4 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.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92f0264a46dc47047a04a1b402fe32dd54546686d7f11b0bec83c727e9a7bf06
MD5 ca922be17f4e9b654b0dc6db0de8248d
BLAKE2b-256 0402437a933d2662d0811173fed39beed9c04acf8493352ee25f6823252aae19

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonnet_server-0.7.1-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

0.8.0

2 files

This release

0.7.1 This release

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