Skip to main content

Infrastructure for building and deploying prod-ready services

Project description

svc-infra

PyPI Docs

svc-infra packages the shared building blocks we use to ship production FastAPI services fast—HTTP APIs with secure auth, durable persistence, background execution, cache, observability, and webhook plumbing that all share the same batteries-included defaults.

Helper index

Helper What it covers Guide
API FastAPI bootstrap, envelopes, middleware, docs wiring FastAPI guide
Auth Sessions, OAuth/OIDC, MFA, SMTP delivery Auth settings
Database SQL + Mongo wiring, Alembic helpers, inbox/outbox patterns Database guide
Jobs JobQueue, scheduler, CLI worker Jobs quickstart
Cache cashews decorators, namespace management, TTL helpers Cache guide
Observability Prometheus middleware, Grafana automation, OTEL hooks Observability guide
Ops Probes, breaker, SLOs & dashboards SLOs & Ops
Webhooks Subscription store, signing, retry worker Webhooks framework
Security Password policy, lockout, signed cookies, headers Security hardening
Contributing Dev setup and quality gates Contributing guide
Data Lifecycle Fixtures, retention, erasure, backups Data lifecycle

Minimal FastAPI bootstrap

from fastapi import Depends
from svc_infra.api.fastapi.ease import easy_service_app
from svc_infra.api.fastapi.db.sql.add import add_sql_db
from svc_infra.cache import init_cache
from svc_infra.jobs.easy import easy_jobs
from svc_infra.webhooks.fastapi import require_signature

app = easy_service_app(name="Billing", release="1.2.3")
add_sql_db(app)              # reads SQL_URL / DB_* envs
init_cache()                 # honors CACHE_PREFIX / CACHE_VERSION
queue, scheduler = easy_jobs()  # switches via JOBS_DRIVER / REDIS_URL

@app.post("/webhooks/billing")
async def handle_webhook(payload = Depends(require_signature(lambda: ["current", "next"]))):
    queue.enqueue("process-billing-webhook", payload)
    return {"status": "queued"}

Environment switches

  • API – toggle logging/observability and docs exposure with ENABLE_LOGGING, LOG_LEVEL, LOG_FORMAT, ENABLE_OBS, METRICS_PATH, OBS_SKIP_PATHS, and CORS_ALLOW_ORIGINS. 【F:src/svc_infra/api/fastapi/ease.py†L67-L111】【F:src/svc_infra/api/fastapi/setup.py†L47-L88】
  • Auth – configure JWT secrets, SMTP, cookies, and policy using the AUTH_… settings family (e.g., AUTH_JWT__SECRET, AUTH_SMTP_HOST, AUTH_SESSION_COOKIE_SECURE). 【F:src/svc_infra/api/fastapi/auth/settings.py†L23-L91】
  • Database – set connection URLs or components via SQL_URL/SQL_URL_FILE, DB_DIALECT, DB_HOST, DB_USER, DB_PASSWORD, plus Mongo knobs like MONGO_URL, MONGO_DB, and MONGO_URL_FILE. 【F:src/svc_infra/api/fastapi/db/sql/add.py†L55-L114】【F:src/svc_infra/db/sql/utils.py†L85-L206】【F:src/svc_infra/db/nosql/mongo/settings.py†L9-L13】【F:src/svc_infra/db/nosql/utils.py†L56-L113】
  • Jobs – choose the queue backend with JOBS_DRIVER and provide Redis via REDIS_URL; interval schedules can be declared with JOBS_SCHEDULE_JSON. 【F:src/svc_infra/jobs/easy.py†L11-L27】【F:docs/jobs.md†L11-L48】
  • Cache – namespace keys and lifetimes through CACHE_PREFIX, CACHE_VERSION, and TTL overrides CACHE_TTL_DEFAULT, CACHE_TTL_SHORT, CACHE_TTL_LONG. 【F:src/svc_infra/cache/README.md†L20-L173】【F:src/svc_infra/cache/ttl.py†L26-L55】
  • Observability – turn metrics on/off or adjust scrape paths with ENABLE_OBS, METRICS_PATH, OBS_SKIP_PATHS, and Prometheus/Grafana flags like SVC_INFRA_DISABLE_PROMETHEUS, SVC_INFRA_RATE_WINDOW, SVC_INFRA_DASHBOARD_REFRESH, SVC_INFRA_DASHBOARD_RANGE. 【F:src/svc_infra/api/fastapi/ease.py†L67-L111】【F:src/svc_infra/obs/metrics/asgi.py†L49-L206】【F:src/svc_infra/obs/cloud_dash.py†L85-L108】
  • Webhooks – reuse the jobs envs (JOBS_DRIVER, REDIS_URL) for the delivery worker and queue configuration. 【F:docs/webhooks.md†L32-L53】
  • Security – enforce password policy, MFA, and rotation with auth prefixes such as AUTH_PASSWORD_MIN_LENGTH, AUTH_PASSWORD_REQUIRE_SYMBOL, AUTH_JWT__SECRET, and AUTH_JWT__OLD_SECRETS. 【F:docs/security.md†L24-L70】

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

svc_infra-0.1.606.tar.gz (238.4 kB view details)

Uploaded Source

Built Distribution

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

svc_infra-0.1.606-py3-none-any.whl (347.1 kB view details)

Uploaded Python 3

File details

Details for the file svc_infra-0.1.606.tar.gz.

File metadata

  • Download URL: svc_infra-0.1.606.tar.gz
  • Upload date:
  • Size: 238.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for svc_infra-0.1.606.tar.gz
Algorithm Hash digest
SHA256 893e877eb960fd881c4412afd306ce39850cd05c2f28ee1f7eb790283b17e34f
MD5 055787f1698cd23a839d3f5519ebc89b
BLAKE2b-256 68ad0c7ae9679cd6878c014d79cc7bc9d5c7654091f1cf7930c734e302226412

See more details on using hashes here.

Provenance

The following attestation bundles were made for svc_infra-0.1.606.tar.gz:

Publisher: publish-pypi.yml on Aliikhatami94/svc-infra

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

File details

Details for the file svc_infra-0.1.606-py3-none-any.whl.

File metadata

  • Download URL: svc_infra-0.1.606-py3-none-any.whl
  • Upload date:
  • Size: 347.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for svc_infra-0.1.606-py3-none-any.whl
Algorithm Hash digest
SHA256 2fa5508707b0d2dc4a0c82f95d88854785f398e1c00cfe5d1dd49f329f154c6e
MD5 1e241f75266f409532f48b0f0c2e121c
BLAKE2b-256 7e77c50294c18574f6c3cab31a1e77af6bc1b7ffe42097b8c500f2db3c4fbc29

See more details on using hashes here.

Provenance

The following attestation bundles were made for svc_infra-0.1.606-py3-none-any.whl:

Publisher: publish-pypi.yml on Aliikhatami94/svc-infra

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

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page