Skip to content

Add REST API endpoint for real-time transaction scoring #3

Description

@stabrea

Summary

Wrap the trained fraud detection model in a FastAPI service that accepts transaction data and returns fraud probability scores in real time.

Motivation

  • Production fraud detection requires low-latency scoring at transaction time
  • REST API enables integration with payment processing pipelines
  • Demonstrates deployment readiness beyond notebook-stage ML

Proposed Approach

  1. FastAPI service:

    • POST /score endpoint accepting transaction JSON
    • Returns fraud probability, risk tier (low/medium/high), and top contributing features
    • Input validation with Pydantic models
    • Health check endpoint at GET /health
  2. Model serving:

    • Load serialized model on startup
    • Feature preprocessing pipeline included in serving path
    • Model versioning support (load by version tag)
  3. Containerization:

    • Dockerfile with multi-stage build
    • docker-compose.yml for local development
    • Environment-based configuration (model path, threshold, port)
  4. Performance:

    • Target <50ms p95 latency for single transaction scoring
    • Add request logging for monitoring
    • Rate limiting for abuse prevention

Acceptance Criteria

  • FastAPI app with /score and /health endpoints
  • Pydantic request/response models with validation
  • Dockerfile and docker-compose.yml
  • Example curl commands in README
  • Latency benchmarks documented

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions