# pranavdev-g/financial-fraud-detection architecture

> Architecture diagram of the GitHub repository pranavdev-g/financial-fraud-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pranavdev-g/financial-fraud-detection
- Repository: https://github.com/pranavdev-g/financial-fraud-detection

## Overview

This is a financial-fraud detection application with a FastAPI backend and browser dashboard. Its main workflow accepts a transaction CSV, prepares transaction data, and exposes risk-scored results and analysis through API endpoints for the dashboard. Separate routes provide algorithm-specific analyses and transaction simulation. The sampled code also shows model scoring, hash-based sender profiles, caching, and PDF report generation. The README contains no feature detail, and frontend and report wiring were not shown, so those connections are left out rather than inferred.

Main entry points: [`backend/main.py`](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/main.py) (FastAPI routes), [`backend/risk_engine.py`](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py) (Risk scoring), [`frontend/dashboard.html`](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/frontend/dashboard.html) (Browser dashboard), [`backend/caches.py`](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/caches.py) (Analysis cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and interface"]
  node_browser["Browser dashboard<br/>[dashboard.html]"]
  node_webapp["FastAPI routes<br/>[main.py]"]
end

subgraph group_data["Transaction data"]
  node_upload["CSV upload and loading<br/>[fraud_service.py]"]
  node_dataset[("Loaded transaction data<br/>[fraud_service.py]")]
  node_sample["Sample transactions"]
end

subgraph group_analysis["Fraud analysis"]
  node_risk["Risk scoring<br/>[risk_engine.py]"]
  node_model["Fraud ML model<br/>[ai_model.py]"]
  node_divide["Outlier analysis<br/>[divide_conquer.py]"]
  node_dynamic["Pattern analysis"]
  node_greedy["Suspicious ranking<br/>[greedy.py]"]
  node_hashing["Sender profiles and search"]
  node_cache["Analysis cache<br/>[caches.py]"]
  node_simulation["Transaction simulation<br/>[risk_engine.py]"]
end

subgraph group_insights["Analysis outputs"]
  node_dashboard["Dashboard payload<br/>[risk_engine.py]"]
  node_report["PDF report generation"]
end

node_user(("Analyst"))

node_user -->|"views"| node_browser
node_browser -.->|"requests data"| node_webapp
node_webapp -->|"serves pages"| node_browser
node_webapp -->|"routes upload"| node_upload
node_upload -->|"loads and prepares"| node_dataset
node_webapp -->|"requires loaded data"| node_dataset
node_webapp -->|"runs scoring"| node_risk
node_risk -->|"scores transactions"| node_model
node_risk -->|"computes outliers"| node_divide
node_risk -->|"computes patterns"| node_dynamic
node_webapp -->|"runs analysis"| node_divide
node_webapp -->|"runs analysis"| node_dynamic
node_webapp -->|"runs ranking"| node_greedy
node_greedy -->|"evaluates dataset"| node_risk
node_webapp -->|"runs search and analysis"| node_hashing
node_webapp -->|"simulates transactions"| node_simulation
node_webapp -->|"builds dashboard data"| node_dashboard
node_cache -->|"builds sender profiles"| node_hashing
node_cache -->|"precomputes predictions"| node_model

click node_browser "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/frontend/dashboard.html"
click node_webapp "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/main.py"
click node_upload "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/services/fraud_service.py"
click node_dataset "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/services/fraud_service.py"
click node_risk "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py"
click node_model "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/ai_model.py"
click node_divide "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/divide_conquer.py"
click node_dynamic "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/dynamic_programming.py"
click node_greedy "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/greedy.py"
click node_hashing "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/hashing_implementation.py"
click node_cache "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/caches.py"
click node_simulation "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py"
click node_dashboard "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py"
click node_report "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/report_generator.py"
click node_sample "https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/dataset/sample_transactions.csv"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_webapp toneBlue
class node_upload,node_dataset,node_sample toneAmber
class node_risk,node_model,node_divide,node_dynamic,node_greedy,node_hashing,node_cache,node_simulation toneMint
class node_dashboard,node_report toneRose
class node_user toneIndigo
```

## Components

### API and interface

- [Browser dashboard](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/frontend/dashboard.html): `frontend/dashboard.html`
- [FastAPI routes](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/main.py): `backend/main.py`

### Transaction data

- [CSV upload and loading](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/services/fraud_service.py): `backend/services/fraud_service.py`
- [Loaded transaction data](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/services/fraud_service.py): `backend/services/fraud_service.py`
- [Sample transactions](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/dataset/sample_transactions.csv): `backend/dataset/sample_transactions.csv`

### Fraud analysis

- [Risk scoring](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py): `backend/risk_engine.py`
- [Fraud ML model](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/ai_model.py): `backend/ai_model.py`
- [Outlier analysis](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/divide_conquer.py): `backend/algorithms/divide_conquer.py`
- [Pattern analysis](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/dynamic_programming.py): `backend/algorithms/dynamic_programming.py`
- [Suspicious ranking](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/greedy.py): `backend/algorithms/greedy.py`
- [Sender profiles and search](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/algorithms/hashing_implementation.py): `backend/algorithms/hashing_implementation.py`
- [Analysis cache](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/caches.py): `backend/caches.py`
- [Transaction simulation](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py): `backend/risk_engine.py`

### Analysis outputs

- [Dashboard payload](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/risk_engine.py): `backend/risk_engine.py`
- [PDF report generation](https://github.com/pranavdev-g/financial-fraud-detection/blob/main/backend/report_generator.py): `backend/report_generator.py`

### Other components

- **Analyst**

## Connections

- Analyst → Browser dashboard: views
- Browser dashboard → FastAPI routes: requests data
- FastAPI routes → Browser dashboard: serves pages (evidence: `backend/main.py`)
- FastAPI routes → CSV upload and loading: routes upload (evidence: `backend/main.py`)
- CSV upload and loading → Loaded transaction data: loads and prepares (evidence: `backend/services/fraud_service.py`)
- FastAPI routes → Loaded transaction data: requires loaded data (evidence: `backend/main.py`)
- FastAPI routes → Risk scoring: runs scoring (evidence: `backend/main.py`)
- Risk scoring → Fraud ML model: scores transactions (evidence: `backend/risk_engine.py`)
- Risk scoring → Outlier analysis: computes outliers (evidence: `backend/risk_engine.py`)
- Risk scoring → Pattern analysis: computes patterns (evidence: `backend/risk_engine.py`)
- FastAPI routes → Outlier analysis: runs analysis (evidence: `backend/main.py`)
- FastAPI routes → Pattern analysis: runs analysis (evidence: `backend/main.py`)
- FastAPI routes → Suspicious ranking: runs ranking (evidence: `backend/main.py`)
- Suspicious ranking → Risk scoring: evaluates dataset (evidence: `backend/algorithms/greedy.py`)
- FastAPI routes → Sender profiles and search: runs search and analysis (evidence: `backend/main.py`)
- FastAPI routes → Transaction simulation: simulates transactions (evidence: `backend/main.py`)
- FastAPI routes → Dashboard payload: builds dashboard data (evidence: `backend/main.py`)
- Analysis cache → Sender profiles and search: builds sender profiles (evidence: `backend/caches.py`)
- Analysis cache → Fraud ML model: precomputes predictions (evidence: `backend/caches.py`)
