feat: project skeleton

- infra (k8s, kind, helm, docker) backbone is implemented
- security: implementation + unit tests are done
This commit is contained in:
2026-01-21 03:14:09 -05:00
commit 0d99ba0b31
46 changed files with 3468 additions and 0 deletions

0
app/api/v1/__init__.py Normal file
View File

46
app/api/v1/health.py Normal file
View File

@@ -0,0 +1,46 @@
"""Health check endpoints."""
from fastapi import APIRouter, Response, status
from app.db import db, redis_client
router = APIRouter()
@router.get("/healthz")
async def healthz() -> dict[str, str]:
"""Liveness probe - returns 200 if the service is running."""
return {"status": "ok"}
@router.get("/readyz")
async def readyz(response: Response) -> dict[str, str | dict[str, bool]]:
"""
Readiness probe - checks database and Redis connectivity.
- Check Postgres status
- Check Redis status
- Return overall healthiness
"""
checks = {
"postgres": False,
"redis": False,
}
try:
if db.pool:
async with db.connection() as conn:
await conn.fetchval("SELECT 1")
checks["postgres"] = True
except Exception:
pass
checks["redis"] = await redis_client.ping()
all_healthy = all(checks.values())
if not all_healthy:
response.status_code = status.HTTP_503_SERVICE_UNAVAILABLE
return {
"status": "ok" if all_healthy else "degraded",
"checks": checks,
}