Skip to content

TaranjyotS/real-time-financial-analytics-platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ˆ Real-Time Financial Analytics Platform

Production-grade event-driven fintech analytics platform for transactions, portfolios, market data, fraud, risk, observability, and AI-style anomaly detection.

Overview β€’ Features β€’ Screenshots β€’ Architecture β€’ Quick Start β€’ API β€’ Troubleshooting


πŸ“Œ Overview

Real-Time Financial Analytics Platform is a portfolio-grade fintech simulation system that ingests financial transactions, simulates market prices, calculates portfolio performance, classifies fraud and risk alerts, and exposes operational metrics through Prometheus and Grafana.

The project is designed to demonstrate senior-level engineering across backend systems, event-driven architecture, data engineering, observability, DevSecOps, cloud-ready deployment, and full-stack product delivery.

It simulates how a fintech organization could process market and transaction events across a streaming architecture while maintaining operational visibility through dashboards and metrics.


✨ Features

⚑ Real-Time Platform

  • Transaction ingestion APIs
  • Market price simulation
  • Kafka event publishing
  • Portfolio valuation
  • Live dashboard refresh
  • Event-oriented backend flow

πŸ›‘οΈ Risk & Fraud

  • Fraud rules engine
  • Large transaction detection
  • AI-style anomaly scoring
  • Portfolio concentration risk
  • Alert severity classification
  • Alert history API

πŸš€ Engineering

  • FastAPI service layer
  • React analytics dashboard
  • PostgreSQL persistence
  • Redis-ready cache layer
  • Prometheus metrics
  • Grafana provisioning
  • Docker Compose runtime
  • Kubernetes manifests
  • GitHub Actions + Jenkins

🧱 Tech Stack


Python
Backend

FastAPI
API

Kafka
Streaming

PostgreSQL
Database

Redis
Cache

React
Frontend

Docker
Runtime

Kubernetes
Orchestration

GitHub Actions
CI/CD

AWS
Cloud Design

πŸ“Έ Screenshots


πŸ—οΈ Architecture

flowchart TD
    A[React Analytics Dashboard] --> B[FastAPI Backend]
    B --> C[(PostgreSQL)]
    B --> D[(Redis Cache)]
    B --> E[Kafka Broker]
    E --> F[Transaction Events]
    E --> G[Market Price Events]
    B --> H[Fraud Rules Engine]
    B --> I[Risk Analytics Engine]
    B --> J[AI-Style Anomaly Scoring]
    H --> K[Alerts]
    I --> K
    J --> K
    B --> L[Prometheus Metrics]
    L --> M[Grafana Dashboard]
    N[Airflow DAGs] --> O[PySpark Batch Jobs]
Loading

πŸ”„ End-to-End Workflow

User Opens React Dashboard
        ↓
User Clicks Generate Live Events
        ↓
FastAPI Creates Simulated Transactions and Market Events
        ↓
Transaction Data Is Persisted in PostgreSQL
        ↓
Kafka Event Publishing Simulates Streaming Architecture
        ↓
Anomaly Scoring Calculates Transaction Risk Probability
        ↓
Fraud Rules Engine Creates High-Severity Alerts
        ↓
Portfolio Valuation and Performance Metrics Are Refreshed
        ↓
React Dashboard Displays Portfolio, Market, Fraud, Risk, and Transaction Data
        ↓
Prometheus Scrapes API Metrics
        ↓
Grafana Visualizes API Request and Latency Metrics

System Flow

Step What Happens
1 Dashboard checks backend health and displays online/offline status
2 Demo event generation creates realistic transaction and market records
3 Backend persists transactions, prices, alerts, and portfolio state
4 Fraud and anomaly logic classify suspicious transactions
5 Dashboard fetches summarized analytics from backend APIs
6 Prometheus scrapes /metrics from FastAPI
7 Grafana displays platform-level observability metrics

πŸ—„οΈ Database Design

erDiagram
    USERS ||--o{ PORTFOLIOS : owns
    USERS ||--o{ TRANSACTIONS : creates
    PORTFOLIOS ||--o{ HOLDINGS : contains
    PORTFOLIOS ||--o{ TRANSACTIONS : records
    PORTFOLIOS ||--o{ RISK_METRICS : has
    PORTFOLIOS ||--o{ ALERTS : triggers
    ASSETS ||--o{ HOLDINGS : held_as
    ASSETS ||--o{ TRANSACTIONS : traded_as
    ASSETS ||--o{ MARKET_PRICES : priced_as
Loading

Core Entities

Entity Purpose
users Demo users and authentication records
assets Tradable instruments such as AAPL, MSFT, NVDA, JPM
portfolios User-owned investment portfolios
holdings Asset quantities and average cost basis
transactions Buy/sell activity with anomaly scores
market_prices Simulated market price snapshots
alerts Fraud, risk, and anomaly alerts
risk_metrics Portfolio-level risk calculations

πŸ”Œ API Reference

Health and Monitoring

curl http://localhost:8000/health
curl http://localhost:8000/ready
curl http://localhost:8000/metrics

Generate Demo Events

curl -X POST "http://localhost:8000/api/v1/demo/generate-events?count=20"
curl -X POST "http://localhost:8000/api/v1/market/simulate?count=10"

Dashboard Summary

curl http://localhost:8000/api/v1/dashboard/summary

Transactions

curl http://localhost:8000/api/v1/transactions

Alerts

curl http://localhost:8000/api/v1/alerts

API Surface

Method Endpoint Purpose
GET /health Backend liveness check
GET /ready Backend readiness check
GET /metrics Prometheus metrics endpoint
POST /api/v1/auth/register Register demo user
POST /api/v1/auth/login Demo login
GET /api/v1/assets List supported assets
POST /api/v1/assets Create asset
GET /api/v1/portfolios List portfolios
POST /api/v1/portfolios Create portfolio
POST /api/v1/portfolios/{portfolio_id}/holdings Add portfolio holding
GET /api/v1/portfolios/{portfolio_id}/performance Portfolio performance
GET /api/v1/transactions List transactions
POST /api/v1/transactions Create transaction
GET /api/v1/market/prices List latest market prices
POST /api/v1/market/prices Create market price
POST /api/v1/market/simulate Simulate market updates
GET /api/v1/risk/portfolio/{portfolio_id} Portfolio risk summary
GET /api/v1/alerts List risk/fraud alerts
GET /api/v1/dashboard/summary Frontend analytics payload
POST /api/v1/demo/generate-events Generate demo transaction events

πŸ“ Folder Structure
real-time-financial-analytics-platform/
β”œβ”€β”€ .github/
β”‚   └── workflows/                 # GitHub Actions CI/CD
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app/                       # FastAPI application
β”‚   β”‚   β”œβ”€β”€ main.py                # API startup and route registration
β”‚   β”‚   β”œβ”€β”€ models.py              # SQLAlchemy models
β”‚   β”‚   β”œβ”€β”€ schemas.py             # Pydantic schemas
β”‚   β”‚   β”œβ”€β”€ db.py                  # Database session/config
β”‚   β”‚   β”œβ”€β”€ security.py            # Demo auth/password helpers
β”‚   β”‚   └── metrics.py             # Prometheus metrics
β”‚   β”œβ”€β”€ tests/                     # Unit/integration tests
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── requirements.txt
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/                       # React dashboard
β”‚   β”œβ”€β”€ public/                    # Static assets/favicon
β”‚   β”œβ”€β”€ Dockerfile
β”‚   └── package.json
β”œβ”€β”€ data-engineering/
β”‚   β”œβ”€β”€ airflow/                   # Airflow DAGs
β”‚   └── spark/                     # PySpark jobs
β”œβ”€β”€ infrastructure/
β”‚   β”œβ”€β”€ docker-compose.yml         # Local full-stack runtime
β”‚   └── k8s/                       # Kubernetes manifests
β”œβ”€β”€ monitoring/
β”‚   β”œβ”€β”€ prometheus/                # Prometheus configuration
β”‚   └── grafana/                   # Grafana datasource/dashboard provisioning
β”œβ”€β”€ docs/
β”‚   └── screenshots/               # README screenshots
β”œβ”€β”€ sample-data/                   # Demo data samples
β”œβ”€β”€ Jenkinsfile
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ LICENSE
└── README.md

⚑ Quick Start

Prerequisites

Requirement Version
Docker Desktop Latest
Docker Compose v2+
Git Any recent version
Python 3.11 optional
Node.js 20+ optional

Run Full Platform with Docker

cp .env.example .env
docker compose -p rtfa -f infrastructure/docker-compose.yml up --build

Open:

API Docs:    http://localhost:8000/docs
Frontend:   http://localhost:5173
Grafana:    http://localhost:3000
Prometheus: http://localhost:9090

Grafana local login:

username: admin
password: admin

Generate Live Events

Use the frontend button:

Generate Live Events

Or use curl:

curl -X POST "http://localhost:8000/api/v1/demo/generate-events?count=20"

Clean Rebuild

docker compose -p rtfa -f infrastructure/docker-compose.yml down -v --remove-orphans
docker compose -p rtfa -f infrastructure/docker-compose.yml build --no-cache
docker compose -p rtfa -f infrastructure/docker-compose.yml up

πŸ“Š Monitoring

Prometheus scrapes FastAPI metrics from:

http://backend:8000/metrics

Useful Prometheus queries:

up
finanalytics_api_requests_total
finanalytics_api_latency_seconds_count

Grafana includes a local dashboard for:

  • API request volume
  • API latency
  • Backend availability
  • Platform observability proof

☁️ AWS Deployment Design

flowchart LR
    A[Route 53] --> B[CloudFront]
    B --> C[S3 React Frontend]
    B --> D[Application Load Balancer]
    D --> E[EKS FastAPI Services]
    E --> F[Amazon MSK Kafka]
    E --> G[(RDS PostgreSQL)]
    E --> H[(ElastiCache Redis)]
    E --> I[S3 Data Lake]
    I --> J[MWAA Airflow]
    J --> K[EMR / Glue PySpark]
    E --> L[CloudWatch]
    E --> M[Prometheus + Grafana]
Loading

πŸ§ͺ Testing

Backend Tests

cd backend
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\\Scripts\\activate
pip install -r requirements.txt
pytest tests

Quality Checks

ruff check app tests
bandit -r app

Docker Smoke Test

curl http://localhost:8000/health
curl http://localhost:8000/api/v1/dashboard/summary

πŸ›‘οΈ Security & DevSecOps

βœ… Included

  • Pydantic request validation
  • Environment-based configuration
  • Demo authentication endpoints
  • Password hashing for local demo auth
  • Dockerized runtime
  • CI/CD workflow structure
  • Bandit security scan support
  • Prometheus visibility into API health

πŸ”œ Production Extensions

  • OAuth/OIDC authentication
  • JWT-protected dashboard routes
  • API gateway rate limiting
  • Secrets Manager integration
  • Trivy image scanning
  • Terraform AWS infrastructure
  • Helm charts
  • Dedicated Kafka consumer deployments

πŸ§ͺ What This Project Demonstrates

Skill Area Demonstrated Through
Backend Engineering FastAPI APIs, service logic, validation, health checks
System Design Event-driven architecture, streaming topics, separate platform components
Data Engineering Airflow/PySpark structure, market and transaction analytics flow
Full-Stack Development React dashboard connected to backend APIs
Fintech Domain Transactions, portfolios, market prices, risk, fraud, anomaly scoring
Database Design PostgreSQL schema for users, portfolios, assets, transactions, alerts
Observability Prometheus metrics and Grafana dashboard provisioning
DevOps Docker Compose, Kubernetes manifests, GitHub Actions, Jenkinsfile
Cloud Architecture AWS EKS/MSK/RDS/ElastiCache/MWAA/EMR deployment design
Portfolio Readiness Screenshots, architecture diagrams, API docs, troubleshooting guidance

🧰 Troubleshooting

Docker Desktop engine pipe error on Windows

Open Docker Desktop and wait until it says Docker is running.

Then run:

docker version
docker compose version

If using WSL, enable Docker Desktop WSL integration and restart Docker Desktop.

Postgres role does not exist

This usually means an old Docker volume was reused.

Run:

docker compose -p rtfa -f infrastructure/docker-compose.yml down -v --remove-orphans
docker compose -p rtfa -f infrastructure/docker-compose.yml up --build
Frontend shows backend offline

Check backend health:

curl http://localhost:8000/health

Then reload:

http://localhost:5173
Grafana login failed

Use local Docker credentials:

admin / admin

GitHub login is not enabled in local Grafana unless a GitHub OAuth app is configured.

Prometheus page opens but shows no data

Run this query:

up

Then query:

finanalytics_api_requests_total

Open the frontend and generate events to increase metrics.


πŸ”„ Recommended Clean Rebuild

docker compose -p rtfa -f infrastructure/docker-compose.yml down -v --remove-orphans
docker compose -p rtfa -f infrastructure/docker-compose.yml build --no-cache
docker compose -p rtfa -f infrastructure/docker-compose.yml up

πŸ—ΊοΈ Roadmap

Priority Improvement
High Add WebSocket streaming instead of dashboard polling
High Add dedicated Kafka consumer worker containers
High Add Alembic migrations
High Add JWT-protected dashboard routes
Medium Add MLflow model registry for anomaly models
Medium Add Terraform for AWS EKS/MSK/RDS/ElastiCache
Medium Add Trivy image scanning to CI/CD
Medium Add Helm chart for Kubernetes deployment
Low Add synthetic load testing with Locust
Low Add downloadable portfolio analytics reports

πŸ“„ License

This project is licensed under the MIT License.


⚠️ Disclaimer

This project uses simulated financial data and is intended for portfolio, engineering, and educational demonstration purposes only.

It is not financial advice and should not be used for real trading, investment decisions, or production financial operations.

About

Production-grade event-driven fintech analytics platform with FastAPI, Kafka, PostgreSQL, Redis, React, Prometheus, Grafana, Docker, Kubernetes, risk analytics, fraud detection, and AI anomaly scoring.

Topics

Resources

License

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors