# tanishk-dot/federated-fraud-detection architecture

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

- Interactive diagram: https://gitdiagram.com/tanishk-dot/federated-fraud-detection
- Repository: https://github.com/tanishk-dot/federated-fraud-detection

## Overview

Federated Fraud Detection trains a shared temporal-graph fraud model across simulated banks while keeping raw transactions local, with optional client-level differential privacy and encrypted aggregation. The user-facing workflow runs from the React dashboard through its API client to FastAPI for inference, data testing, training, and simulation; offline training is also exposed through the training runner. Data is loaded or encoded into transaction sequences, scored by the model, and evaluated or displayed. The README documents additional comparison and privacy-utility capabilities. Some backend routes and training internals were only partially sampled, so uncertain connections are omitted.

Main entry points: [`run_training.py`](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/run_training.py) (Training orchestrator), [`src/models/temporal_graph_transformer.py`](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/temporal_graph_transformer.py) (Temporal graph model), [`backend/main.py`](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/backend/main.py) (FastAPI service), [`src/federated/client.py`](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/client.py) (Bank client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web dashboard"]
  node_app["Dashboard routes<br/>[App.tsx]"]
  node_pages["Workflow pages"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and inference"]
  node_backend["FastAPI service<br/>[main.py]"]
  node_results["Metrics and results<br/>[main.py]"]
end

subgraph group_ml["Model and data"]
  node_feature["Feature encoding"]
  node_dataset[("Federated datasets<br/>[dataset.py]")]
  node_model["Temporal graph model"]
  node_temporal["Temporal encoder"]
  node_graph["Graph encoder<br/>[graph_encoder.py]"]
  node_fusion["Cross-modal fusion<br/>[fusion.py]"]
  node_contrastive["Contrastive head"]
end

subgraph group_federated["Federated training"]
  node_runner["Training orchestrator<br/>[run_training.py]"]
  node_client["Bank client<br/>[client.py]"]
  node_dp["DP utilities<br/>[dp_utils.py]"]
  node_accounting["Privacy accounting<br/>[dp_accounting.py]"]
  node_encryption["Homomorphic encryption"]
  node_proxy["Proxy server<br/>[proxy_server.py]"]
end

node_user(("Dashboard user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_pages
node_pages -->|"requests"| node_api_client
node_api_client -->|"calls HTTP API"| node_backend
node_backend -->|"encodes transactions"| node_feature
node_backend -->|"runs inference"| node_model
node_backend -->|"starts training"| node_runner
node_backend -->|"serves results"| node_results
node_runner -->|"trains model"| node_model
node_runner -->|"aggregates encrypted updates"| node_encryption
node_runner -->|"uses proxy"| node_proxy
node_runner -->|"tracks privacy"| node_accounting
node_client -->|"trains locally"| node_model
node_client -->|"loads client data"| node_dataset
node_client -->|"uses DP"| node_dp
node_dataset -.->|"supplies training data"| node_runner
node_model -->|"uses encoder"| node_temporal
node_model -->|"uses encoder"| node_graph
node_model -->|"fuses modalities"| node_fusion
node_model -->|"scores anomalies"| node_contrastive
node_proxy -->|"uses encryption"| node_encryption
node_runner -.->|"coordinates clients"| node_client

click node_app "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/frontend/src/App.tsx"
click node_pages "https://github.com/tanishk-dot/federated-fraud-detection/tree/main/frontend/src/pages"
click node_api_client "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/frontend/src/api.ts"
click node_backend "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/backend/main.py"
click node_feature "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/data/feature_engineering.py"
click node_dataset "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/data/dataset.py"
click node_model "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/temporal_graph_transformer.py"
click node_temporal "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/temporal_transformer.py"
click node_graph "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/graph_encoder.py"
click node_fusion "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/fusion.py"
click node_contrastive "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/contrastive_head.py"
click node_runner "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/run_training.py"
click node_client "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/client.py"
click node_dp "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/dp_utils.py"
click node_accounting "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/dp_accounting.py"
click node_encryption "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/homomorphic_encryption.py"
click node_proxy "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/proxy_server.py"
click node_results "https://github.com/tanishk-dot/federated-fraud-detection/blob/main/backend/main.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_pages,node_api_client,node_user toneBlue
class node_backend,node_results toneAmber
class node_feature,node_dataset,node_model,node_temporal,node_graph,node_fusion,node_contrastive toneMint
class node_runner,node_client,node_dp,node_accounting,node_encryption,node_proxy toneRose
```

## Components

### Web dashboard

- [Dashboard routes](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Workflow pages](https://github.com/tanishk-dot/federated-fraud-detection/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### API and inference

- [FastAPI service](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/backend/main.py): `backend/main.py`
- [Metrics and results](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/backend/main.py): `backend/main.py`

### Model and data

- [Feature encoding](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/data/feature_engineering.py): `src/data/feature_engineering.py`
- [Federated datasets](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/data/dataset.py): `src/data/dataset.py`
- [Temporal graph model](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/temporal_graph_transformer.py): `src/models/temporal_graph_transformer.py`
- [Temporal encoder](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/temporal_transformer.py): `src/models/temporal_transformer.py`
- [Graph encoder](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/graph_encoder.py): `src/models/graph_encoder.py`
- [Cross-modal fusion](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/fusion.py): `src/models/fusion.py`
- [Contrastive head](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/models/contrastive_head.py): `src/models/contrastive_head.py`

### Federated training

- [Training orchestrator](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/run_training.py): `run_training.py`
- [Bank client](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/client.py): `src/federated/client.py`
- [DP utilities](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/dp_utils.py): `src/federated/dp_utils.py`
- [Privacy accounting](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/dp_accounting.py): `src/federated/dp_accounting.py`
- [Homomorphic encryption](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/homomorphic_encryption.py): `src/federated/homomorphic_encryption.py`
- [Proxy server](https://github.com/tanishk-dot/federated-fraud-detection/blob/main/src/federated/proxy_server.py): `src/federated/proxy_server.py`

### Other components

- **Dashboard user**

## Connections

- Dashboard user → Dashboard routes: uses (evidence: `frontend/src/App.tsx`)
- Dashboard routes → Workflow pages: routes to (evidence: `frontend/src/App.tsx`)
- Workflow pages → API client: requests (evidence: `frontend/src/pages/Overview.tsx`)
- API client → FastAPI service: calls HTTP API (evidence: `frontend/src/api.ts`)
- FastAPI service → Feature encoding: encodes transactions (evidence: `backend/main.py`)
- FastAPI service → Temporal graph model: runs inference (evidence: `backend/main.py`)
- FastAPI service → Training orchestrator: starts training (evidence: `backend/main.py`)
- FastAPI service → Metrics and results: serves results (evidence: `backend/main.py`)
- Training orchestrator → Temporal graph model: trains model (evidence: `run_training.py`)
- Training orchestrator → Homomorphic encryption: aggregates encrypted updates (evidence: `run_training.py`)
- Training orchestrator → Proxy server: uses proxy (evidence: `run_training.py`)
- Training orchestrator → Privacy accounting: tracks privacy (evidence: `run_training.py`)
- Bank client → Temporal graph model: trains locally (evidence: `src/federated/client.py`)
- Bank client → Federated datasets: loads client data (evidence: `src/federated/client.py`)
- Bank client → DP utilities: uses DP (evidence: `src/federated/client.py`)
- Federated datasets → Training orchestrator: supplies training data (evidence: `README.md`)
- Temporal graph model → Temporal encoder: uses encoder (evidence: `src/models/temporal_graph_transformer.py`)
- Temporal graph model → Graph encoder: uses encoder (evidence: `src/models/temporal_graph_transformer.py`)
- Temporal graph model → Cross-modal fusion: fuses modalities (evidence: `src/models/temporal_graph_transformer.py`)
- Temporal graph model → Contrastive head: scores anomalies (evidence: `src/models/temporal_graph_transformer.py`)
- Proxy server → Homomorphic encryption: uses encryption (evidence: `src/federated/proxy_server.py`)
- Training orchestrator → Bank client: coordinates clients
