Skip to content

HamiYasir/FraudWatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FraudWatch Agent - Reactive AI Agent for Fraud Detection

A reactive AI system that detects fraudulent financial transactions in real time using Machine Learning, Apache Kafka, Spring Boot, Flask, WebSockets, and SMTP-based email alerts.

The project demonstrates how an AI Agent can operate within a live transaction environment, make fraud predictions, react to suspicious activity, and notify subscribed clients automatically.

PROJECT GOAL

The objective of this project is to create a Reactive AI Agent capable of operating in a transaction-processing environment.

The agent continuously monitors incoming transactions, identifies potentially fraudulent activities using Machine Learning, sends alerts to subscribed clients when fraud is detected, and streams live predictions to a web-based dashboard for monitoring and analysis.

THINGS THAT I WILL BE LEARNING FROM THS PROJECT:

  • Building event-driven systems using Apache Kafka
  • Working with Kafka Producers and Consumers
  • Deploying Machine Learning models through Flask APIs
  • Integrating Machine Learning with distributed systems
  • Real-time transaction streaming and processing
  • Building reactive AI agents that perceive environments and take actions
  • Implementing WebSocket communication using Spring Boot
  • Streaming live predictions to frontend applications
  • Sending automated email alerts using SMTP
  • Designing end-to-end fraud detection pipelines
  • Working with Spring Boot as a middleware layer
  • Managing communication between Python and Java services
  • Deploying full-stack AI applications
  • Building deployment-friendly hosted versions of distributed systems

FRAMEWORKS AND OTHER RESOURCES USED IN THIS PROJECT:

  • Backend & Middleware

    • Java 17: Used to build the backend application that coordinates communication between system components.
    • Spring Boot: Acts as the middleware layer between the fraud prediction pipeline and the frontend dashboard.
    • Spring WebSocket: Streams transaction and prediction updates to the frontend in real time.
    • STOMP: Provides a messaging protocol over WebSockets for publishing fraud detection events.
    • SockJS: Ensures reliable browser-to-server WebSocket communication.
    • Gradle: Used to build, manage dependencies, and run the Spring Boot application.
  • Data Streaming

    • Apache Kafka: Acts as the event streaming platform that transports transactions through the fraud detection pipeline.
    • Apache ZooKeeper: Coordinates and manages the Kafka broker during local deployment.
    • Kafka Producer: Reads transactions from a CSV file and publishes them to a Kafka topic.
    • Kafka Consumer: Consumes streamed transactions, requests fraud predictions, and triggers system actions.
  • Machine Learning

    • Python: Used to implement the machine learning and AI agent components.
    • Flask: Exposes the trained fraud detection model through a REST API.
    • Scikit-Learn: Provides machine learning utilities used during model training and evaluation.
    • XGBoost: Serves as the fraud detection model that predicts whether a transaction is fraudulent.
    • Pandas: Processes and transforms transaction datasets before model inference.
    • NumPy: Handles numerical operations required by the machine learning pipeline.
    • Joblib: Loads the trained machine learning model for prediction serving.
  • AI Agent Components

    • SMTP: Sends automated fraud alert emails when suspicious transactions are detected.
    • Gmail App Password Authentication: Authenticates the AI Agent email account used for fraud notifications.
  • Frontend

    • HTML: Provides the user interface for displaying live transactions and fraud predictions.
    • CSS: Styles the fraud monitoring dashboard and prediction cards.
    • JavaScript: Handles WebSocket communication and dynamically updates the user interface. Dataset
  • Dataset

  • Deployment -Render: Used to deploy the frontend and host the xgboost model.

REPOSITORY STRUCTURE

Documentation

This fodler contains files and other documentations realting to the various aspects of this project.

Hosted Deployment

The hosted deployment provides a simplified public demonstration of the project. All the files related to this deployment are found in hosted-deployment.

Users can:

  • Start a hosted simulation
  • View live transaction streams
  • Observe fraud predictions in real time
  • Explore the project without installing Kafka or ZooKeeper

Architecture Diagram for Hosted Deployment:

architecture_diagram_hosted

Local Deployment

The local deployment contains the complete architecture. This is the full implementation of this project and can be run locally. All the files related to this deployment are found in local-deployment. Refer README.md file inside local-deployment to get this running locally. It includes:

  • Apache Kafka
  • ZooKeeper
  • Flask Machine Learning API
  • Kafka Producer
  • Kafka Consumer
  • Spring Boot Backend
  • WebSocket Frontend
  • SMTP Email Alerts

Architecture Diagram for Local Deployment:

architecture_diagram_local

DEPLOYMENT

This app has been deployed at https://fraud-detection-agent-model-frontend.onrender.com

You can check it out there. Enjoy :)