# patilyash9172/fraud-detection-system architecture

> Architecture diagram of the GitHub repository patilyash9172/fraud-detection-system, 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/patilyash9172/fraud-detection-system
- Repository: https://github.com/patilyash9172/fraud-detection-system

## Overview

This directory contains a fraud-scoring API and a data-loading utility; the README identifies the analyst dashboard as a separate React app in ../frontend. The main scoring path is visible in main.py, but feature engineering, model, risk-scoring, and explainability implementations are referenced rather than present in this file tree, so their internal wiring is shown only where the API calls them.

Main entry points: [`main.py`](https://github.com/patilyash9172/fraud-detection-system/blob/main/main.py) (FastAPI service), [`load_data.py`](https://github.com/patilyash9172/fraud-detection-system/blob/main/load_data.py) (Data loader), [`schemas.py`](https://github.com/patilyash9172/fraud-detection-system/blob/main/schemas.py) (Request contracts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Scoring API"]
  node_service["FastAPI service<br/>[main.py]"]
  node_contracts["Request contracts<br/>[schemas.py]"]
end

subgraph group_models["Scoring internals"]
  node_features["Feature engineering"]
  node_model["Fraud model"]
  node_risk["Risk scoring"]
  node_explain["SHAP explanations"]
  node_anomaly["Anomaly detection"]
end

subgraph group_operations["Operations and data"]
  node_registry["Model registry<br/>[main.py]"]
  node_artifacts["Model artifacts"]
  node_loader["Data loader<br/>[load_data.py]"]
  node_source_data["Processed data"]
  node_postgres[("PostgreSQL")]
end

node_caller(("API client"))

node_caller -->|"submits transactions"| node_service
node_service -->|"validates and responds"| node_contracts
node_service -->|"loads artifacts"| node_registry
node_registry -->|"reads"| node_artifacts
node_service -->|"engineers features"| node_features
node_service -->|"predicts probability"| node_model
node_service -->|"scores risk"| node_risk
node_service -.->|"requests explanations"| node_explain
node_service -.->|"scores anomalies"| node_anomaly
node_loader -->|"reads"| node_source_data
node_loader -->|"writes records"| node_postgres

click node_service "https://github.com/patilyash9172/fraud-detection-system/blob/main/main.py"
click node_contracts "https://github.com/patilyash9172/fraud-detection-system/blob/main/schemas.py"
click node_registry "https://github.com/patilyash9172/fraud-detection-system/blob/main/main.py"
click node_loader "https://github.com/patilyash9172/fraud-detection-system/blob/main/load_data.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_service,node_contracts,node_caller toneBlue
class node_features,node_model,node_risk,node_explain,node_anomaly toneAmber
class node_registry,node_artifacts,node_loader,node_source_data,node_postgres toneMint
```

## Components

### Scoring API

- [FastAPI service](https://github.com/patilyash9172/fraud-detection-system/blob/main/main.py): `main.py`
- [Request contracts](https://github.com/patilyash9172/fraud-detection-system/blob/main/schemas.py): `schemas.py`

### Scoring internals

- **Feature engineering**
- **Fraud model**
- **Risk scoring**
- **SHAP explanations**
- **Anomaly detection**

### Operations and data

- [Model registry](https://github.com/patilyash9172/fraud-detection-system/blob/main/main.py): `main.py`
- **Model artifacts**
- [Data loader](https://github.com/patilyash9172/fraud-detection-system/blob/main/load_data.py): `load_data.py`
- **Processed data**
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → FastAPI service: submits transactions
- FastAPI service → Request contracts: validates and responds
- FastAPI service → Model registry: loads artifacts
- Model registry → Model artifacts: reads
- FastAPI service → Feature engineering: engineers features
- FastAPI service → Fraud model: predicts probability
- FastAPI service → Risk scoring: scores risk
- FastAPI service → SHAP explanations: requests explanations
- FastAPI service → Anomaly detection: scores anomalies
- Data loader → Processed data: reads
- Data loader → PostgreSQL: writes records
