Namespace RinhaBackend
Classes
- CustomerInfo
Customer behavioral profile used for anomaly detection: spending average, recent activity, and known merchants.
- FraudDetectionService
Orchestrates fraud scoring for a single transaction request. Normalizes the request into a feature vector, runs KNN search via IReferenceDataStore, and applies the approval threshold to produce a FraudScoreResponse.
- FraudScoreRequest
Full payload for the
POST /fraud-scoreendpoint, aggregating all context needed to score a transaction.
- FraudScoreResponse
Scoring result returned by
POST /fraud-score.ApprovedistruewhenFraudScoreis below the approval threshold (0.6).
- LastTransactionInfo
Timestamp and location delta of the customer's immediately preceding transaction. Null when no prior transaction exists for this customer.
- MerchantInfo
Merchant context: identifier, Merchant Category Code (MCC), and the merchant's average transaction amount.
- ReferenceDataStore
Immutable in-memory KNN store that holds ~3 million pre-indexed reference transactions. Vectors are stored as Half (float16) for memory efficiency (~87 MB per instance). On first load the source
references.json.gzis converted to a compact binary cache (references.bin) so subsequent startups skip JSON parsing entirely.
- TerminalInfo
Terminal and card-present flags, plus the physical distance from the customer's registered home address.
- TransactionInfo
Core transaction data: amount, installments, and the UTC timestamp of the request.
- VectorNormalizer
Converts a FraudScoreRequest into a normalized 14-dimensional float vector in [0, 1]. Each dimension captures a distinct behavioral or contextual signal used by the KNN classifier.
Interfaces
- IReferenceDataStore
Abstraction over the KNN reference store, used to allow test doubles without loading production data.