https://github.com/yuberlinets/transactions-fraud
Fraudulent Transaction detection
https://github.com/yuberlinets/transactions-fraud
analysis docker-compose fastapi fraud-detection java kafka kafka-streams ml mongodb nginx python react real-time rest-api sockjs spring spring-boot typescript websocket
Last synced: 2 months ago
JSON representation
Fraudulent Transaction detection
- Host: GitHub
- URL: https://github.com/yuberlinets/transactions-fraud
- Owner: YuBerlinets
- License: apache-2.0
- Created: 2025-02-03T22:15:11.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-08T20:17:02.000Z (over 1 year ago)
- Last Synced: 2025-04-09T05:44:18.386Z (about 1 year ago)
- Topics: analysis, docker-compose, fastapi, fraud-detection, java, kafka, kafka-streams, ml, mongodb, nginx, python, react, real-time, rest-api, sockjs, spring, spring-boot, typescript, websocket
- Language: Java
- Homepage:
- Size: 386 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Transaction Fraud Detections
### Real-time analysis of banking transactions to detect fraudulent ones
## Overview
This project is a real-time fraud detection system for banking transactions. It utilizes Apache Kafka for event streaming, a machine learning model trained with DecisionTreeClassifier from sklearn, and a Spring Boot backend to process transactions. Fraudulent transactions are stored in MongoDB, while legitimate ones (in a real-world scenario) would be forwarded to an internal banking system.
## Architecture

### Transaction Producer (Python)
- Generates 100 transactions per minute for testing.
- Sends transactions to the Kafka topic transactions.
### Backend (Java Spring Boot)
- Consumes transactions from Kafka.
- Calls an ML-based fraud detection model (DecisionTreeClassifier).
- If fraudulent, stores the transaction in MongoDB and sends to "fraud-alert" Kafka topic
- If legitimate, in a real-world case, forwards the transaction to a banking system.
- Sends transaction updates via WebSocket to the frontend.
### Frontend (React + TypeScript)
- Real-time dashboard displaying: Transactions per 3 minutes, Blocked Transactions, Approved Transactions, Fraud Alerts
- HTTP server configured using Nginx
### Transactions Streaming (Kafka)
- Has two topics with events (fraud-alerts, transactions)
### ML Model (Python + FastAPI + SkLearn)
- Trained on datasets with transaction samples based on the Decision Tree Classifier
- Has endpoints to send and analyze transactions and evaluate a model
## Tech Stack
- **Backend**: Java, Spring Boot, Kafka Streams, MongoDB, FastAPI, WEBSocket
- **Machine Learning**: Python, Scikit-learn
- **Frontend**: React, TypeScript, Vite, SockJS, Nginx
- **Event Streaming**: Apache Kafka
## Client Layout
**Dashboard**


**Stored Fraudulent Transactions**


## Config (.env files)
### **Client**
VITE_BASE_URL=
### **Java Backend**
MONGODB_URI=
KAFKA_BOOTSTRAP_SERVERS=
ML_MODEL_URL=
KAFKA_STREAMS_APPLICATION_ID=
BOOTSTRAP_SERVERS_CONFIG=
### **Python Generator**
BASE_URL=
## How to run?
> [!WARNING]
Don't forget to change the .env files and properties in docker-compose.yml!
To run using Docker compose run this command in project folder.
```
docker-compose up --build
```