Domain-service foundation for Petrarca Labs backend services
Project description
Sonnet Server
Domain-service foundation for Petrarca backend services. Provides the infrastructure layer that every backend service inherits: FastAPI app factory, extension-based lifecycle, database connectivity, messaging, caching, DI, readiness pipeline, guards, CLI framework, and system endpoints.
What it provides
- Extension protocol -- opt-in subsystem lifecycle (database, messaging, cache, profiles). Infrastructure and profile extensions with conditional startup and router mounting.
- Database -- engine management, ambient sessions, CRUD repository, Alembic utilities, advisory locks.
- Messaging -- content-based router with pluggable channels (Postgres
LISTEN/NOTIFY, NATS, in-process), CloudEvents envelope,
@handlesdecorator. - Cache -- managed cache with pluggable backends (local, distributed, near-cache), cross-process invalidation via messaging.
- Readiness pipeline -- composable health check stages with decorator-based auto-discovery.
- Guards -- protocol-based authentication and tenant context validation.
- DI -- type-keyed service registry with factory and singleton patterns.
- CLI -- Typer-based framework with reusable
db check/db upgradecommands. - System endpoints --
/ping,/version,/health-check, plus extension-contributed routes (/messaging,/cache).
Prerequisites
Setup
task install
Development
# Format, check, test
task fct
# Individual steps
task format
task check
task test
Consumer usage
Dependency
Add to your project's pyproject.toml:
[project]
dependencies = [
"sonnet-server[all]>=0.1.0",
]
For local co-development, add an editable source override:
[tool.uv.sources]
sonnet-server = { path = "../../sonnet-server", editable = true }
Settings
Subclass Settings with your own env prefix. Call init_settings() at the
bottom of your settings module to register with sonnet-server:
# my_app/settings.py
from functools import lru_cache
from pydantic_settings import SettingsConfigDict
from sonnet_server.settings import Settings as SonnetSettings, init_settings
class Settings(SonnetSettings):
model_config = SettingsConfigDict(env_prefix="MY_APP_", ...)
# project-specific fields here
@lru_cache
def get_settings() -> Settings:
return Settings()
init_settings(get_settings())
All sonnet-server infrastructure (database, messaging, cache, checks) will
then read from MY_APP_* env vars.
License
Apache License 2.0. See LICENSE.md.
Project details
Release history Release notifications | RSS feed
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.1.2.tar.gz.
File metadata
- Download URL: sonnet_server-0.1.2.tar.gz
- Upload date:
- Size: 294.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7810408ebfa0a2cf23460bf8b63cc7d306d5ea9768343ac012304f3519a138a5
|
|
| MD5 |
77ac0d4be0a6f8598c5e0ba5833ed25d
|
|
| BLAKE2b-256 |
6a4947a234d57e60bd0b89adb061475cb7bd63650548d748c5eacb97bf348be8
|
Provenance
The following attestation bundles were made for sonnet_server-0.1.2.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.1.2.tar.gz -
Subject digest:
7810408ebfa0a2cf23460bf8b63cc7d306d5ea9768343ac012304f3519a138a5 - Sigstore transparency entry: 1280704305
- Sigstore integration time:
-
Permalink:
petrarca/sonnet-server@2400ea8c10a8d4aa8a5c55c5996f2b6dee9e2b65 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/petrarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2400ea8c10a8d4aa8a5c55c5996f2b6dee9e2b65 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonnet_server-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sonnet_server-0.1.2-py3-none-any.whl
- Upload date:
- Size: 186.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e31e6a8e3c02c7e78e938834a73a3397b22acc6ccc9c180264cedc9d273c5a39
|
|
| MD5 |
f010012e3b077d57be87be8f38f17970
|
|
| BLAKE2b-256 |
08b3776fa7fc66aab754629314f382fdf61bb1261b64dc0e8e9fae93b26786af
|
Provenance
The following attestation bundles were made for sonnet_server-0.1.2-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.1.2-py3-none-any.whl -
Subject digest:
e31e6a8e3c02c7e78e938834a73a3397b22acc6ccc9c180264cedc9d273c5a39 - Sigstore transparency entry: 1280704308
- Sigstore integration time:
-
Permalink:
petrarca/sonnet-server@2400ea8c10a8d4aa8a5c55c5996f2b6dee9e2b65 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/petrarca
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2400ea8c10a8d4aa8a5c55c5996f2b6dee9e2b65 -
Trigger Event:
push
-
Statement type: