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.1.tar.gz (112.7 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.1-py3-none-any.whl (144.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sonnet_server-0.8.1.tar.gz
  • Upload date:
  • Size: 112.7 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.1.tar.gz
Algorithm Hash digest
SHA256 106bd19223beb39d7a6fd2674d84c49faf98865f28f6867c41777274ac3968f5
MD5 b3504eabd01f0bc5f565bb5467e4226c
BLAKE2b-256 51a23d6fc5cbb5f357ad378e5cdd9b7081a7845d0e0fa311d8f353804a02e2c3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: sonnet_server-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 144.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.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 94fdbb881b71a0b62ee4eb8050b78587e735896ff2d8a54642d9fe22078d0f9c
MD5 ff87b11961d490c326e730b2de0a3d25
BLAKE2b-256 c16a6bc0ea2b74d3459ea7cc11d921d6fbd2f4cfb629841fee714c6f00dcfbb4

See more details on using hashes here.

Provenance

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

This release

0.8.1 This release

2 files

0.8.0

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