# sidd2721/fraud-detect-mini- architecture

> Architecture diagram of the GitHub repository sidd2721/fraud-detect-mini-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sidd2721/fraud-detect-mini-
- Repository: https://github.com/sidd2721/fraud-detect-mini-

## Overview

FraudDetect AI serves interactive credit-card fraud screening: a user enters one 29-feature transaction or uploads a labeled/unlabeled CSV; FastAPI validates and routes it through shared inference, which returns a classification, probability, and feature-level explanation for the browser to render. The API also exposes curated samples, static evaluation metrics, model information, and downloadable sample CSV; labeled batch uploads can include live evaluation. Training creates the saved pipeline and demo artifacts. Source excerpts establish the single/batch call paths, while other frontend wiring is only partially sampled.

Main entry points: [`main.py`](https://github.com/sidd2721/fraud-detect-mini-/blob/main/main.py) (FastAPI routes), [`frontend/script.js`](https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/script.js) (UI and charts), [`ml/model_train.py`](https://github.com/sidd2721/fraud-detect-mini-/blob/main/ml/model_train.py) (Training pipeline), [`frontend/index.html`](https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/index.html) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Browser experience"]
  node_frontend["Web interface<br/>[index.html]"]
  node_browser_logic["UI and charts<br/>[script.js]"]
  node_styles["Fintech styling<br/>[style.css]"]
end

subgraph group_api["API and evaluation"]
  node_api_app["FastAPI routes<br/>[main.py]"]
  node_metrics["Evaluation metrics<br/>[metrics.json]"]
  node_samples["Labeled samples"]
end

subgraph group_ml["Fraud inference"]
  node_predictor["Fraud detector"]
  node_model["Trained pipeline<br/>[fraud_model.joblib]"]
end

subgraph group_training["Model preparation"]
  node_trainer["Training pipeline<br/>[model_train.py]"]
end

node_user(("Analyst"))

node_user -->|"uses"| node_frontend
node_frontend -->|"loads"| node_browser_logic
node_browser_logic -->|"requests"| node_api_app
node_api_app -->|"invokes inference"| node_predictor
node_predictor -->|"loads pipeline"| node_model
node_api_app -->|"reads metrics"| node_metrics
node_api_app -->|"reads samples"| node_samples
node_trainer -->|"saves pipeline"| node_model
node_trainer -->|"writes metrics"| node_metrics
node_browser_logic -->|"uses styles"| node_styles

click node_frontend "https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/index.html"
click node_browser_logic "https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/script.js"
click node_styles "https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/style.css"
click node_api_app "https://github.com/sidd2721/fraud-detect-mini-/blob/main/main.py"
click node_metrics "https://github.com/sidd2721/fraud-detect-mini-/blob/main/metrics.json"
click node_samples "https://github.com/sidd2721/fraud-detect-mini-/blob/main/labeled_test_data.json"
click node_predictor "https://github.com/sidd2721/fraud-detect-mini-/blob/main/prediction_endpoint.py"
click node_model "https://github.com/sidd2721/fraud-detect-mini-/blob/main/ml/fraud_model.joblib"
click node_trainer "https://github.com/sidd2721/fraud-detect-mini-/blob/main/ml/model_train.py"

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_frontend,node_browser_logic,node_styles toneBlue
class node_api_app,node_metrics,node_samples toneAmber
class node_predictor,node_model toneMint
class node_trainer toneRose
class node_user toneIndigo
```

## Components

### Browser experience

- [Web interface](https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/index.html): `frontend/index.html`
- [UI and charts](https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/script.js): `frontend/script.js`
- [Fintech styling](https://github.com/sidd2721/fraud-detect-mini-/blob/main/frontend/style.css): `frontend/style.css`

### API and evaluation

- [FastAPI routes](https://github.com/sidd2721/fraud-detect-mini-/blob/main/main.py): `main.py`
- [Evaluation metrics](https://github.com/sidd2721/fraud-detect-mini-/blob/main/metrics.json): `metrics.json`
- [Labeled samples](https://github.com/sidd2721/fraud-detect-mini-/blob/main/labeled_test_data.json): `labeled_test_data.json`

### Fraud inference

- [Fraud detector](https://github.com/sidd2721/fraud-detect-mini-/blob/main/prediction_endpoint.py): `prediction_endpoint.py`
- [Trained pipeline](https://github.com/sidd2721/fraud-detect-mini-/blob/main/ml/fraud_model.joblib): `ml/fraud_model.joblib`

### Model preparation

- [Training pipeline](https://github.com/sidd2721/fraud-detect-mini-/blob/main/ml/model_train.py): `ml/model_train.py`

### Other components

- **Analyst**

## Connections

- Analyst → Web interface: uses
- Web interface → UI and charts: loads
- UI and charts → FastAPI routes: requests
- FastAPI routes → Fraud detector: invokes inference
- Fraud detector → Trained pipeline: loads pipeline
- FastAPI routes → Evaluation metrics: reads metrics
- FastAPI routes → Labeled samples: reads samples
- Training pipeline → Trained pipeline: saves pipeline
- Training pipeline → Evaluation metrics: writes metrics
- UI and charts → Fintech styling: uses styles
