Infrastructure for building and deploying prod-ready services
Project description
svc-infra
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
| Area | What it covers | Guide |
|---|---|---|
| Getting Started | Overview and entry points | This page |
| Environment | Feature switches and env vars | Environment |
| API | FastAPI bootstrap, middleware, docs wiring | API guide |
| Auth | Sessions, OAuth/OIDC, MFA, SMTP delivery | Auth |
| Security | Password policy, lockout, signed cookies, headers | Security |
| Database | SQL + Mongo wiring, Alembic helpers, inbox/outbox patterns | Database |
| Storage | File storage with S3, local, memory backends | Storage |
| Documents | Generic document management with metadata | Documents |
| Tenancy | Multi-tenant boundaries and helpers | Tenancy |
| Idempotency | Idempotent endpoints and middleware | Idempotency |
| Rate Limiting | Middleware, dependency limiter, headers | Rate limiting |
| Cache | cashews decorators, namespace management, TTL helpers | Cache |
| Jobs | JobQueue, scheduler, CLI worker | Jobs |
| Observability | Prometheus, Grafana, OpenTelemetry | Observability |
| Ops | Probes, breakers, SLOs & dashboards | Ops |
| Webhooks | Subscription store, signing, retry worker | Webhooks |
| CLI | Command groups for sql/mongo/obs/docs/dx/sdk/jobs | CLI |
| Docs & SDKs | Publishing docs, generating SDKs | Docs & SDKs |
| Acceptance | Acceptance harness and flows | Acceptance, Matrix |
| Contributing | Dev setup and quality gates | Contributing |
| Repo Review | Checklist for releasing/PRs | Repo review |
| Data Lifecycle | Fixtures, retention, erasure, backups | Data lifecycle |
Quick Start with Template Example
See ALL svc-infra features working together in a complete example:
# One-time setup (from repo root)
make setup-template # Scaffolds models, runs migrations
# Run the example server
make run-template # Starts at http://localhost:8001
See examples/README.md for full documentation and manual setup options.
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, andCORS_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 likeMONGO_URL,MONGO_DB, andMONGO_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】 - Storage – choose backend with
STORAGE_BACKEND(local, s3, memory) and configure withSTORAGE_S3_BUCKET,STORAGE_S3_REGION,STORAGE_BASE_PATH, or auto-detect fromRAILWAY_VOLUME_MOUNT_PATH/ AWS credentials. 【F:src/svc_infra/storage/settings.py】【F:src/svc_infra/docs/storage.md】 - Jobs – choose the queue backend with
JOBS_DRIVERand provide Redis viaREDIS_URL; interval schedules can be declared withJOBS_SCHEDULE_JSON. 【F:src/svc_infra/jobs/easy.py†L11-L27】【F:src/svc_infra/docs/jobs.md†L11-L48】 - Cache – namespace keys and lifetimes through
CACHE_PREFIX,CACHE_VERSION, and TTL overridesCACHE_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 likeSVC_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:src/svc_infra/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, andAUTH_JWT__OLD_SECRETS. 【F:src/svc_infra/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
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 svc_infra-0.1.666.tar.gz.
File metadata
- Download URL: svc_infra-0.1.666.tar.gz
- Upload date:
- Size: 346.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2800ce7dfc10aa789a806c111de847c3228ec4146442bd0b8ff1d11930e8196
|
|
| MD5 |
eb8b1f596047ffccc4e855be19c58a50
|
|
| BLAKE2b-256 |
06ba3c2af42ae28d5efeffe52c5bccb5bbd0d66c03ccaa67d8daa11989c2a769
|
Provenance
The following attestation bundles were made for svc_infra-0.1.666.tar.gz:
Publisher:
publish-pypi.yml on Aliikhatami94/svc-infra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svc_infra-0.1.666.tar.gz -
Subject digest:
a2800ce7dfc10aa789a806c111de847c3228ec4146442bd0b8ff1d11930e8196 - Sigstore transparency entry: 707824849
- Sigstore integration time:
-
Permalink:
Aliikhatami94/svc-infra@5102d06ffcdd19853de68fd7bb77db2a985fcd1e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Aliikhatami94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5102d06ffcdd19853de68fd7bb77db2a985fcd1e -
Trigger Event:
push
-
Statement type:
File details
Details for the file svc_infra-0.1.666-py3-none-any.whl.
File metadata
- Download URL: svc_infra-0.1.666-py3-none-any.whl
- Upload date:
- Size: 491.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85d16661f070b19f18e06f96eb5d162e7a04750df0ff4877ef87d1cb5f6364c1
|
|
| MD5 |
bcf0b438950fffbdb74182a5847a78e3
|
|
| BLAKE2b-256 |
6003ffeaa44dfe1d564a2cf586ed9e454cb26c90dea3fece7074b5fb0a248fe2
|
Provenance
The following attestation bundles were made for svc_infra-0.1.666-py3-none-any.whl:
Publisher:
publish-pypi.yml on Aliikhatami94/svc-infra
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
svc_infra-0.1.666-py3-none-any.whl -
Subject digest:
85d16661f070b19f18e06f96eb5d162e7a04750df0ff4877ef87d1cb5f6364c1 - Sigstore transparency entry: 707824850
- Sigstore integration time:
-
Permalink:
Aliikhatami94/svc-infra@5102d06ffcdd19853de68fd7bb77db2a985fcd1e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Aliikhatami94
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@5102d06ffcdd19853de68fd7bb77db2a985fcd1e -
Trigger Event:
push
-
Statement type: