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.0.tar.gz (119.3 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.0-py3-none-any.whl (153.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sonnet_server-0.7.0.tar.gz
  • Upload date:
  • Size: 119.3 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.0.tar.gz
Algorithm Hash digest
SHA256 dbed489a72dc351c9f9f023763f8dc767681a9878d307026f3fa1fd6af2b1764
MD5 34a759dd8360674e44118da2fa188a63
BLAKE2b-256 74f4f2ef4895e1d0373680fa21af274aa54ca8d3b580cc8f82cc7bb4c921a2c0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sonnet_server-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 153.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3a3ea710bb1cf24671012f13fa945fcf601c4b29887bb5c5ce476feb2455a4ad
MD5 ed5d3141e6186ca7c50daa3b60598aba
BLAKE2b-256 f470bed54a46f4f3c01a6d4aba98e7b6714709fff66a3b99aa471d09f5387080

See more details on using hashes here.

Provenance

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

0.8.0

2 files

0.7.1

2 files

This release

0.7.0 This release

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