Skip to content

shubham0730/FinSight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FinSight

Real-time financial transaction intelligence platform built with Node.js, React, Kafka, AWS, and a local RAG-powered AI assistant.


What it does

FinSight ingests financial transactions through a Kafka event stream, runs real-time anomaly detection on each transaction, stores results in PostgreSQL, archives data to S3, and exposes a React dashboard with live WebSocket updates and an AI chat interface powered by Llama 3.2 and FAISS.


Architecture

React Frontend (nginx / EC2)
        |
        | REST + WebSocket
        v
Node.js API (PM2 / EC2)
        |
   _____|_____
  |           |
Kafka      PostgreSQL
Producer   (AWS RDS)
  |
Kafka Consumer
  |
  |-- Anomaly Detection Engine
  |-- S3 Archival (AWS S3)
  |-- WebSocket Broadcast
  |
FAISS Vector Store + Ollama (local)
  |-- nomic-embed-text embeddings
  |-- Llama 3.2 LLM

Tech Stack

Layer Technology
Frontend React, Recharts, WebSocket
Backend Node.js, Express
Messaging Apache Kafka (KafkaJS)
Database PostgreSQL (AWS RDS)
Storage AWS S3
Infra AWS EC2, Docker, PM2, nginx
Monitoring AWS CloudWatch
AI Ollama, Llama 3.2, nomic-embed-text, FAISS
Auth JWT

Features

  • Real-time transaction ingestion via Kafka producer/consumer pipeline
  • Rule-based anomaly detection: velocity checks, high-amount thresholds, odd-hour detection, high-risk location flagging
  • Live WebSocket feed showing transactions and anomaly alerts as they are processed
  • Paginated transaction table with filters by type, status, category, amount range, and anomaly flag
  • Analytics dashboard with volume charts and summary stats
  • Transaction simulator and CSV upload for seeding data
  • S3 archival of transaction batches and uploaded CSV files
  • RAG-powered AI chat using FAISS vector search and Llama 3.2 to answer natural language queries over transaction history
  • JWT-based authentication with rate limiting
  • Structured JSON logging shipped to CloudWatch

Project Structure

finsight/
├── backend/
│   ├── src/
│   │   ├── ai/               # RAG pipeline, embeddings, FAISS vector store
│   │   ├── config/           # DB connection, logger
│   │   ├── kafka/            # Producer and consumer
│   │   ├── middleware/       # JWT auth
│   │   ├── routes/           # auth, transactions, alerts, chat, upload
│   │   └── services/         # Anomaly detection, S3, simulator
│   └── .env
├── frontend/
│   └── src/
│       ├── components/       # Layout, StatCard, TransactionTable, AnomalyPanel, LiveFeed, ChatPanel, SimulateBar
│       ├── context/          # AuthContext
│       ├── hooks/            # useWebSocket, useTransactions
│       └── pages/            # Login, Dashboard, Transactions, Chat
└── docker-compose.yml

Local Setup

Prerequisites

  • Node.js 20+
  • Docker and Docker Compose
  • PostgreSQL (local or via Docker)
  • Ollama

1. Clone the repo

git clone https://github.com/shubham0730/FinSight.git
cd FinSight

2. Start Kafka

docker compose up -d

3. Start Ollama and pull models

ollama serve
ollama pull llama3.2
ollama pull nomic-embed-text

4. Set up the backend

cd backend
cp .env.example .env
npm install
npm run dev

5. Set up the frontend

cd frontend
npm install
npm run dev

Open http://localhost:3000, register an account, then simulate transactions from the dashboard.

6. Index transactions for AI chat

Click "Index transactions" in the AI Assistant page after simulating data.


Environment Variables

PORT=3001
DB_HOST=
DB_PORT=5432
DB_NAME=finsight
DB_USER=
DB_PASSWORD=
JWT_SECRET=
JWT_EXPIRES_IN=7d
KAFKA_BROKER=localhost:9092
AWS_REGION=ap-south-1
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
S3_BUCKET=
OLLAMA_URL=http://localhost:11434

AWS Infrastructure

Service Usage
EC2 t3.micro Hosts Node.js API, Kafka, nginx
RDS t3.micro Managed PostgreSQL database
S3 Transaction archival and CSV file storage
CloudWatch Application logs and CPU/memory metrics

Anomaly Detection Rules

Rule Condition
High amount Exceeds 3x user 30-day average AND above INR 45,000
Velocity More than 4 transactions within 10 minutes
Odd hours Transaction between 2 AM and 4 AM
High-risk location Transaction from Dubai or Singapore

Severity is set to high when two or more rules trigger simultaneously.


API Endpoints

POST   /api/auth/register
POST   /api/auth/login

GET    /api/transactions
GET    /api/transactions/summary
GET    /api/transactions/:id
POST   /api/transactions/simulate
POST   /api/transactions/export
GET    /api/transactions/exports

GET    /api/alerts
PATCH  /api/alerts/:id/resolve

POST   /api/upload

POST   /api/chat
GET    /api/chat/status
POST   /api/chat/ingest

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors