Member-only story

Detecting Fraud Transactions with Kafka Streams

theoneamin
4 min readOct 12, 2024

I recently wrote a small fun project where I wanted to explore transaction dataset I found on kaggle. I’ll take you through what I did to implement a system to monitor transactions for fraud. All the source code and the example dataset can be found here: https://github.com/mamin11/fraud-detection

Create new app

Head over to spring initializer and create a new app, or clone the example project from here https://github.com/mamin11/fraud-detection. The dependencies needed should be in pom file. You’ll also find sample dataset in /data directory.

Base Data Structure

First let’s define all the monitoring types we want to support in an enum. In the future, if the need to support more conditions we can add a new criteria type here. Please read through the code to see the structure of other classes like Transaction.

public enum MonitoringCriteriaType {
HIGH_TRANSACTION_AMOUNT, SMALL_INTERVAL, SPECIFIC_SECTOR
}

Before we create a class for each of the above criteria items, the idea is to be able to have custom logic for each criteria we have. Because of that we will create an abstract class that each criteria can extend and provide its own implementation. This is what our abstract class looks like.

public abstract class MonitoringCriteriaItem<T extends MonitoringCriteriaValue> {
public abstract boolean violatesRules(Transaction transaction);

public

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

theoneamin
theoneamin

No responses yet

Write a response