Draft

svc-ml — ML Inference Routing Service

Clientnovameraactive

FastAPI service routing ML inference requests — auto-labelling, horizon detection, file reorganization — to SageMaker endpoints, with Redis caching and PostgreSQL persistence for results (30-day retention).

flowchart LR
    CLIENT[consuming services] -->|POST /api/v1/infer| ML[svc-ml
FastAPI · Fargate] ML --> CACHE[(Redis
24h TTL)] ML --> DB[(PostgreSQL
ml_results · 30d)] ML --> SM[SageMaker
Batch + Real-Time] SM -->|inference result| ML style ML fill:#EDEDFF,stroke:#3B54F7 style SM fill:#F3EDFF,stroke:#8A54E8

Task types: auto_label · auto_horizons · file_reorg

API:

  • POST /api/v1/infer — submit job → returns run_id + status

  • GET /api/v1/infer/{run_id}/{task_type} — poll cached/stored result

  • GET /api/v1/models — list task types + endpoints + versions

  • GET /health — unauthenticated

  • Caching: cache-aside pattern — Redis checked before SageMaker; 24h TTL; results also persisted to PostgreSQL for 30 days.

  • Auth: API key (X-API-Key header).

  • Stack: Python 3.13+, FastAPI, boto3/aiobotocore (SageMaker), psycopg3 + asyncpg pool, Redis 5+, orjson.

  • Built on: the ecs-service pattern.