# espoirdev22/smart-fraud-detection-platform architecture

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

- Interactive diagram: https://gitdiagram.com/espoirdev22/smart-fraud-detection-platform
- Repository: https://github.com/espoirdev22/smart-fraud-detection-platform

## Overview

Smart Fraud Detection is a mobile-money transaction fraud scoring application. A user enters or selects a transaction scenario; the frontend submits it for prediction, displays the risk score, and refreshes transaction history and aggregate statistics. The API prepares model features, applies a configured threshold, and persists predictions; history and statistics read the saved records. The frontend and API excerpts show these interactions. Training notebooks and the model artifact are not present in the tree, so the training workflow cannot be mapped further.

Main entry points: [`backend/app/routers/predict.py`](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/predict.py) (Prediction endpoint), [`backend/app/db/database.py`](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/db/database.py) (Database sessions), [`frontend/src/App.jsx`](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/App.jsx) (Dashboard app), [`frontend/src/services/api.js`](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_app["Dashboard app<br/>[App.jsx]"]
  node_form["Transaction form"]
  node_gauge["Risk gauge<br/>[RiskGauge.jsx]"]
  node_chart["Statistics chart<br/>[StatsChart.jsx]"]
  node_table["Transaction table"]
  node_client["API client<br/>[api.js]"]
end

subgraph group_api["API and domain"]
  node_entry["FastAPI entry<br/>[main.py]"]
  node_prediction["Prediction endpoint<br/>[predict.py]"]
  node_history["Transaction history<br/>[transactions.py]"]
  node_statistics["Statistics endpoint<br/>[statistics.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_ml["Fraud scoring"]
  node_scoring["Model scoring<br/>[ml_service.py]"]
  node_preprocessing["Feature preprocessing<br/>[preprocessing.py]"]
end

subgraph group_storage["Persistence"]
  node_dbsession["Database sessions<br/>[database.py]"]
  node_transactionmodel["Transaction model<br/>[models.py]"]
  node_database[("SQL database")]
end

node_user(("Analyst"))

node_user -->|"enters transaction"| node_form
node_form -->|"submits prediction"| node_client
node_client -->|"POST /predict"| node_prediction
node_client -->|"GET transactions"| node_history
node_client -->|"GET statistics"| node_statistics
node_entry -->|"registers route"| node_prediction
node_entry -->|"registers route"| node_history
node_entry -->|"registers route"| node_statistics
node_prediction -->|"validates payload"| node_schemas
node_prediction -->|"requests score"| node_scoring
node_prediction -->|"reads threshold"| node_config
node_scoring -->|"reads model path"| node_config
node_scoring -.->|"matches features"| node_preprocessing
node_prediction -->|"gets session"| node_dbsession
node_prediction -->|"creates record"| node_transactionmodel
node_history -->|"gets session"| node_dbsession
node_history -->|"queries records"| node_transactionmodel
node_statistics -->|"gets session"| node_dbsession
node_statistics -->|"counts records"| node_transactionmodel
node_dbsession -->|"opens connection"| node_database
node_transactionmodel -->|"uses ORM base"| node_dbsession
node_entry -->|"creates tables"| node_dbsession
node_app -->|"renders"| node_form
node_app -->|"renders score"| node_gauge
node_app -->|"renders statistics"| node_chart
node_app -->|"renders history"| node_table
node_app -->|"loads dashboard data"| node_client

click node_app "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/App.jsx"
click node_form "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/TransactionForm.jsx"
click node_gauge "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/RiskGauge.jsx"
click node_chart "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/StatsChart.jsx"
click node_table "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/TransactionTable.jsx"
click node_client "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/services/api.js"
click node_entry "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/main.py"
click node_prediction "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/predict.py"
click node_history "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/transactions.py"
click node_statistics "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/statistics.py"
click node_schemas "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/models/schemas.py"
click node_scoring "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/services/ml_service.py"
click node_preprocessing "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/ml/src/preprocessing.py"
click node_config "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/core/config.py"
click node_dbsession "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/db/database.py"
click node_transactionmodel "https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/db/models.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_app,node_form,node_gauge,node_chart,node_table,node_client toneBlue
class node_entry,node_prediction,node_history,node_statistics,node_schemas,node_config toneAmber
class node_scoring,node_preprocessing toneMint
class node_dbsession,node_transactionmodel,node_database toneRose
class node_user toneIndigo
```

## Components

### Web interface

- [Dashboard app](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Transaction form](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/TransactionForm.jsx): `frontend/src/components/TransactionForm.jsx`
- [Risk gauge](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/RiskGauge.jsx): `frontend/src/components/RiskGauge.jsx`
- [Statistics chart](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/StatsChart.jsx): `frontend/src/components/StatsChart.jsx`
- [Transaction table](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/components/TransactionTable.jsx): `frontend/src/components/TransactionTable.jsx`
- [API client](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and domain

- [FastAPI entry](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/main.py): `backend/app/main.py`
- [Prediction endpoint](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/predict.py): `backend/app/routers/predict.py`
- [Transaction history](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/transactions.py): `backend/app/routers/transactions.py`
- [Statistics endpoint](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/routers/statistics.py): `backend/app/routers/statistics.py`
- [API schemas](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/models/schemas.py): `backend/app/models/schemas.py`
- [Runtime settings](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Fraud scoring

- [Model scoring](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/services/ml_service.py): `backend/app/services/ml_service.py`
- [Feature preprocessing](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/ml/src/preprocessing.py): `ml/src/preprocessing.py`

### Persistence

- [Database sessions](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/db/database.py): `backend/app/db/database.py`
- [Transaction model](https://github.com/espoirdev22/smart-fraud-detection-platform/blob/main/backend/app/db/models.py): `backend/app/db/models.py`
- **SQL database**

### Other components

- **Analyst**

## Connections

- Analyst → Transaction form: enters transaction (evidence: `frontend/src/components/TransactionForm.jsx`)
- Transaction form → API client: submits prediction (evidence: `frontend/src/components/TransactionForm.jsx`)
- API client → Prediction endpoint: POST /predict (evidence: `frontend/src/services/api.js`)
- API client → Transaction history: GET transactions (evidence: `frontend/src/services/api.js`)
- API client → Statistics endpoint: GET statistics (evidence: `frontend/src/services/api.js`)
- FastAPI entry → Prediction endpoint: registers route (evidence: `backend/app/main.py`)
- FastAPI entry → Transaction history: registers route (evidence: `backend/app/main.py`)
- FastAPI entry → Statistics endpoint: registers route (evidence: `backend/app/main.py`)
- Prediction endpoint → API schemas: validates payload (evidence: `backend/app/routers/predict.py`)
- Prediction endpoint → Model scoring: requests score (evidence: `backend/app/routers/predict.py`)
- Prediction endpoint → Runtime settings: reads threshold (evidence: `backend/app/routers/predict.py`)
- Model scoring → Runtime settings: reads model path (evidence: `backend/app/services/ml_service.py`)
- Model scoring → Feature preprocessing: matches features (evidence: `backend/app/services/ml_service.py`)
- Prediction endpoint → Database sessions: gets session (evidence: `backend/app/routers/predict.py`)
- Prediction endpoint → Transaction model: creates record (evidence: `backend/app/routers/predict.py`)
- Transaction history → Database sessions: gets session (evidence: `backend/app/routers/transactions.py`)
- Transaction history → Transaction model: queries records (evidence: `backend/app/routers/transactions.py`)
- Statistics endpoint → Database sessions: gets session (evidence: `backend/app/routers/statistics.py`)
- Statistics endpoint → Transaction model: counts records (evidence: `backend/app/routers/statistics.py`)
- Database sessions → SQL database: opens connection (evidence: `backend/app/db/database.py`)
- Transaction model → Database sessions: uses ORM base (evidence: `backend/app/db/models.py`)
- FastAPI entry → Database sessions: creates tables (evidence: `backend/app/main.py`)
- Dashboard app → Transaction form: renders (evidence: `frontend/src/App.jsx`)
- Dashboard app → Risk gauge: renders score (evidence: `frontend/src/App.jsx`)
- Dashboard app → Statistics chart: renders statistics (evidence: `frontend/src/App.jsx`)
- Dashboard app → Transaction table: renders history (evidence: `frontend/src/App.jsx`)
- Dashboard app → API client: loads dashboard data (evidence: `frontend/src/App.jsx`)
