Add FastAPI catalog backend (games/snapshots/diff) + tests
Modular-monolith backend over SQLAlchemy (SQLite by default, Postgres-ready
via DATABASE_URL). The full snapshot.json is stored verbatim; diffing reads it
back through the ams.diff engine, so the DB never mirrors the snapshot schema.
- ams.api.db/models/schemas/service : Game 1-N Snapshot, sha256-deduped upsert
- routes: POST/GET /games, POST/GET /snapshots (import, deduped), GET /diff
(?old&new[&owner]) running compute_diff on stored snapshots, /health
- ams.api.importer : bulk CLI loader (python -m ams.api.importer --game ...)
- run: uvicorn ams.api.app:create_app --factory
11 tests pass (6 diff + 5 API via TestClient over the golden pair). Smoke-tested
live on uvicorn: import -> /snapshots -> /diff returns the BlooMoo deltas.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
43
ams/api/schemas.py
Normal file
43
ams/api/schemas.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""Pydantic request/response models."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
|
||||
|
||||
class GameCreate(BaseModel):
|
||||
name: str
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class GameOut(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
id: int
|
||||
name: str
|
||||
notes: str | None = None
|
||||
|
||||
|
||||
class SnapshotOut(BaseModel):
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
id: int
|
||||
game_id: int | None
|
||||
binary_name: str
|
||||
sha256: str
|
||||
engine: str | None
|
||||
compiler: str | None
|
||||
schema_version: int | None
|
||||
n_types: int
|
||||
n_methods: int
|
||||
n_events: int
|
||||
n_fields: int
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class SnapshotDetail(SnapshotOut):
|
||||
data: dict
|
||||
|
||||
|
||||
class GameDetail(GameOut):
|
||||
snapshots: list[SnapshotOut] = []
|
||||
Reference in New Issue
Block a user