feat: backend ingest API, Docker Compose, Ubuntu install guide

- FastAPI: POST /api/v1/events, GET /health, JSON Schema validation

- PostgreSQL models, Alembic migration, bootstrap API key

- deploy/docker-compose.yml, .env.example

- docs/install-ubuntu-24.04.md, updated work-plan (agents first)
This commit is contained in:
PTah
2026-05-26 20:21:31 +10:00
parent bf1c1c9fe9
commit 69a232d08a
34 changed files with 1139 additions and 134 deletions
+24
View File
@@ -0,0 +1,24 @@
import json
from functools import lru_cache
from pathlib import Path
import jsonschema
from jsonschema import Draft202012Validator
from app.config import get_settings
@lru_cache
def get_event_validator() -> Draft202012Validator:
path = Path(get_settings().event_schema_path)
if not path.is_file():
path = Path(__file__).resolve().parents[3] / "schemas" / "event-schema-v1.json"
schema = json.loads(path.read_text(encoding="utf-8"))
Draft202012Validator.check_schema(schema)
return Draft202012Validator(schema)
def validate_event_payload(payload: dict) -> list[str]:
validator = get_event_validator()
errors = sorted(validator.iter_errors(payload), key=lambda e: e.path)
return [e.message for e in errors]