# svc-infra
[](https://pypi.org/project/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](getting-started.md) |
| Environment | Feature switches and env vars | [Environment](environment.md) |
| API | FastAPI bootstrap, middleware, docs wiring | [API guide](api.md) |
| Auth | Sessions, OAuth/OIDC, MFA, SMTP delivery | [Auth](auth.md) |
| Security | Password policy, lockout, signed cookies, headers | [Security](security.md) |
| Database | SQL + Mongo wiring, Alembic helpers, inbox/outbox patterns | [Database](database.md) |
| Tenancy | Multi-tenant boundaries and helpers | [Tenancy](tenancy.md) |
| Idempotency | Idempotent endpoints and middleware | [Idempotency](idempotency.md) |
| Rate Limiting | Middleware, dependency limiter, headers | [Rate limiting](rate-limiting.md) |
| Cache | cashews decorators, namespace management, TTL helpers | [Cache](cache.md) |
| Jobs | JobQueue, scheduler, CLI worker | [Jobs](jobs.md) |
| Observability | Prometheus, Grafana, OpenTelemetry | [Observability](observability.md) |
| Ops | Probes, breakers, SLOs & dashboards | [Ops](ops.md) |
| Webhooks | Subscription store, signing, retry worker | [Webhooks](webhooks.md) |
| CLI | Command groups for sql/mongo/obs/docs/dx/sdk/jobs | [CLI](cli.md) |
| Docs & SDKs | Publishing docs, generating SDKs | [Docs & SDKs](docs-and-sdks.md) |
| Acceptance | Acceptance harness and flows | [Acceptance](acceptance.md), [Matrix](acceptance-matrix.md) |
| Contributing | Dev setup and quality gates | [Contributing](contributing.md) |
| Repo Review | Checklist for releasing/PRs | [Repo review](repo-review.md) |
| Data Lifecycle | Fixtures, retention, erasure, backups | [Data lifecycle](data-lifecycle.md) |
## Minimal FastAPI bootstrap
```python
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:src/svc_infra/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: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`, and `AUTH_JWT__OLD_SECRETS`. 【F:src/svc_infra/docs/security.md†L24-L70】
Raw data
{
"_id": null,
"home_page": null,
"name": "svc-infra",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": "fastapi, sqlalchemy, alembic, auth, infra, async, pydantic",
"author": "Ali Khatami",
"author_email": "aliikhatami94@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/40/1a/bee238576fe386f2bd41729ee1707cb57dbf86435f1bcebf0e1da1e441b7/svc_infra-0.1.625.tar.gz",
"platform": null,
"description": "# svc-infra\n\n[](https://pypi.org/project/svc-infra/)\n[](.)\n\nsvc-infra packages the shared building blocks we use to ship production FastAPI services fast\u2014HTTP APIs with secure auth, durable persistence, background execution, cache, observability, and webhook plumbing that all share the same batteries-included defaults.\n\n## Helper index\n\n| Area | What it covers | Guide |\n| --- | --- | --- |\n| Getting Started | Overview and entry points | [This page](getting-started.md) |\n| Environment | Feature switches and env vars | [Environment](environment.md) |\n| API | FastAPI bootstrap, middleware, docs wiring | [API guide](api.md) |\n| Auth | Sessions, OAuth/OIDC, MFA, SMTP delivery | [Auth](auth.md) |\n| Security | Password policy, lockout, signed cookies, headers | [Security](security.md) |\n| Database | SQL + Mongo wiring, Alembic helpers, inbox/outbox patterns | [Database](database.md) |\n| Tenancy | Multi-tenant boundaries and helpers | [Tenancy](tenancy.md) |\n| Idempotency | Idempotent endpoints and middleware | [Idempotency](idempotency.md) |\n| Rate Limiting | Middleware, dependency limiter, headers | [Rate limiting](rate-limiting.md) |\n| Cache | cashews decorators, namespace management, TTL helpers | [Cache](cache.md) |\n| Jobs | JobQueue, scheduler, CLI worker | [Jobs](jobs.md) |\n| Observability | Prometheus, Grafana, OpenTelemetry | [Observability](observability.md) |\n| Ops | Probes, breakers, SLOs & dashboards | [Ops](ops.md) |\n| Webhooks | Subscription store, signing, retry worker | [Webhooks](webhooks.md) |\n| CLI | Command groups for sql/mongo/obs/docs/dx/sdk/jobs | [CLI](cli.md) |\n| Docs & SDKs | Publishing docs, generating SDKs | [Docs & SDKs](docs-and-sdks.md) |\n| Acceptance | Acceptance harness and flows | [Acceptance](acceptance.md), [Matrix](acceptance-matrix.md) |\n| Contributing | Dev setup and quality gates | [Contributing](contributing.md) |\n| Repo Review | Checklist for releasing/PRs | [Repo review](repo-review.md) |\n| Data Lifecycle | Fixtures, retention, erasure, backups | [Data lifecycle](data-lifecycle.md) |\n\n## Minimal FastAPI bootstrap\n\n```python\nfrom fastapi import Depends\nfrom svc_infra.api.fastapi.ease import easy_service_app\nfrom svc_infra.api.fastapi.db.sql.add import add_sql_db\nfrom svc_infra.cache import init_cache\nfrom svc_infra.jobs.easy import easy_jobs\nfrom svc_infra.webhooks.fastapi import require_signature\n\napp = easy_service_app(name=\"Billing\", release=\"1.2.3\")\nadd_sql_db(app) # reads SQL_URL / DB_* envs\ninit_cache() # honors CACHE_PREFIX / CACHE_VERSION\nqueue, scheduler = easy_jobs() # switches via JOBS_DRIVER / REDIS_URL\n\n@app.post(\"/webhooks/billing\")\nasync def handle_webhook(payload = Depends(require_signature(lambda: [\"current\", \"next\"]))):\n queue.enqueue(\"process-billing-webhook\", payload)\n return {\"status\": \"queued\"}\n```\n\n## Environment switches\n\n- **API** \u2013 toggle logging/observability and docs exposure with `ENABLE_LOGGING`, `LOG_LEVEL`, `LOG_FORMAT`, `ENABLE_OBS`, `METRICS_PATH`, `OBS_SKIP_PATHS`, and `CORS_ALLOW_ORIGINS`. \u3010F:src/svc_infra/api/fastapi/ease.py\u2020L67-L111\u3011\u3010F:src/svc_infra/api/fastapi/setup.py\u2020L47-L88\u3011\n- **Auth** \u2013 configure JWT secrets, SMTP, cookies, and policy using the `AUTH_\u2026` settings family (e.g., `AUTH_JWT__SECRET`, `AUTH_SMTP_HOST`, `AUTH_SESSION_COOKIE_SECURE`). \u3010F:src/svc_infra/api/fastapi/auth/settings.py\u2020L23-L91\u3011\n- **Database** \u2013 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`. \u3010F:src/svc_infra/api/fastapi/db/sql/add.py\u2020L55-L114\u3011\u3010F:src/svc_infra/db/sql/utils.py\u2020L85-L206\u3011\u3010F:src/svc_infra/db/nosql/mongo/settings.py\u2020L9-L13\u3011\u3010F:src/svc_infra/db/nosql/utils.py\u2020L56-L113\u3011\n- **Jobs** \u2013 choose the queue backend with `JOBS_DRIVER` and provide Redis via `REDIS_URL`; interval schedules can be declared with `JOBS_SCHEDULE_JSON`. \u3010F:src/svc_infra/jobs/easy.py\u2020L11-L27\u3011\u3010F:src/svc_infra/docs/jobs.md\u2020L11-L48\u3011\n- **Cache** \u2013 namespace keys and lifetimes through `CACHE_PREFIX`, `CACHE_VERSION`, and TTL overrides `CACHE_TTL_DEFAULT`, `CACHE_TTL_SHORT`, `CACHE_TTL_LONG`. \u3010F:src/svc_infra/cache/README.md\u2020L20-L173\u3011\u3010F:src/svc_infra/cache/ttl.py\u2020L26-L55\u3011\n- **Observability** \u2013 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`. \u3010F:src/svc_infra/api/fastapi/ease.py\u2020L67-L111\u3011\u3010F:src/svc_infra/obs/metrics/asgi.py\u2020L49-L206\u3011\u3010F:src/svc_infra/obs/cloud_dash.py\u2020L85-L108\u3011\n- **Webhooks** \u2013 reuse the jobs envs (`JOBS_DRIVER`, `REDIS_URL`) for the delivery worker and queue configuration. \u3010F:src/svc_infra/docs/webhooks.md\u2020L32-L53\u3011\n- **Security** \u2013 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`. \u3010F:src/svc_infra/docs/security.md\u2020L24-L70\u3011\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Infrastructure for building and deploying prod-ready services",
"version": "0.1.625",
"project_urls": {
"Documentation": "https://github.com/your-org/svc-infra#readme",
"Homepage": "https://github.com/your-org/svc-infra",
"Issues": "https://github.com/your-org/svc-infra/issues",
"Repository": "https://github.com/your-org/svc-infra"
},
"split_keywords": [
"fastapi",
" sqlalchemy",
" alembic",
" auth",
" infra",
" async",
" pydantic"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "19101b382bb869c01040e59204dde00447ce293e7e24c3cbfcd0ae8e2325e907",
"md5": "a081019a8b29f233dba69a30793848c9",
"sha256": "6c092d073384fefef55a65ea9378d73f70466a12019d5439838d28572625057b"
},
"downloads": -1,
"filename": "svc_infra-0.1.625-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a081019a8b29f233dba69a30793848c9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 399674,
"upload_time": "2025-10-20T03:55:32",
"upload_time_iso_8601": "2025-10-20T03:55:32.692908Z",
"url": "https://files.pythonhosted.org/packages/19/10/1b382bb869c01040e59204dde00447ce293e7e24c3cbfcd0ae8e2325e907/svc_infra-0.1.625-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "401abee238576fe386f2bd41729ee1707cb57dbf86435f1bcebf0e1da1e441b7",
"md5": "94124a6f4c49270597080845490f60f5",
"sha256": "176546eae8f55f075e544b59bba230a955509587ae15e0e733bbcc8e288131a3"
},
"downloads": -1,
"filename": "svc_infra-0.1.625.tar.gz",
"has_sig": false,
"md5_digest": "94124a6f4c49270597080845490f60f5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 275525,
"upload_time": "2025-10-20T03:55:35",
"upload_time_iso_8601": "2025-10-20T03:55:35.096063Z",
"url": "https://files.pythonhosted.org/packages/40/1a/bee238576fe386f2bd41729ee1707cb57dbf86435f1bcebf0e1da1e441b7/svc_infra-0.1.625.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-20 03:55:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "your-org",
"github_project": "svc-infra#readme",
"github_not_found": true,
"lcname": "svc-infra"
}