Skip to content

[FEATURE] Fraud Detection API — Serve trained Deep SVDD + GraphSAGE models for real-time scoring #234

@gelluisaac

Description

@gelluisaac

Description

Expose the trained anomaly detection models (DeepSVDD + InductiveGraphSAGE) through
a REST API so the web dashboard can display real fraud predictions.

Endpoints

  • POST /api/v1/fraud/score — Score one or more accounts
    • Input: {"accounts": ["GABC...", "GDEF..."], "edges": [...]}
    • Output: {"scores": {"GABC...": 0.85, "GDEF...": 0.12}}
  • GET /api/v1/fraud/alerts — Recent fraud alerts (paginated, filterable by risk level)
  • GET /api/v1/fraud/stats — Aggregated fraud statistics (total alerts, high/med/low, risk over time)

Implementation Details

  • Load model checkpoints from the model registry on startup
  • Implement a model caching layer to avoid reloading on every request
  • Handle the case where models are not yet trained (return 503 or graceful message)
  • Input validation via Pydantic schemas

Acceptance Criteria

  • /fraud/score returns scores in <500ms for batches up to 50 accounts
  • /fraud/alerts returns data matching FraudStats type in the frontend
  • Model loading is cached and doesn't block the server startup if models are absent
  • Graceful error handling for missing or corrupted model checkpoints

Dependencies

Labels

enhancement, api, ml, fraud-detection

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions