# swayam0611/federated-learning architecture

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

- Interactive diagram: https://gitdiagram.com/swayam0611/federated-learning
- Repository: https://github.com/swayam0611/federated-learning

## Overview

This repository is a research simulation of federated cardiovascular-disease training under a label-flipping attack, with local- and server-evaluation variants. The main workflow configures a run, loads client partitions and shared scaling values, trains three Flower clients, activates label flipping for the selected client, and uses server-side error-history detection to reject suspicious updates or roll back to a trusted model. It logs evaluation results and can optionally export a summary to Google Sheets. The scripts are monolithic; component boundaries below represent responsibilities within them. Unshown wiring is omitted or marked unverified.

Main entry points: [`src_server_eval/simulation_attack.py`](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py) (Server-eval clients), [`src_local_eval/simulation_attack.py`](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py) (Local-eval clients), [`data/custom_splits/output_final`](https://github.com/swayam0611/federated-learning/tree/main/data/custom_splits/output_final) (Client partitions), [`metrics/local_eval`](https://github.com/swayam0611/federated-learning/tree/main/metrics/local_eval) (Local run log)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Run setup"]
  node_local_config["Local config<br/>[config.yaml]"]
  node_server_config["Server config<br/>[config.yaml]"]
  node_local_run["Local-eval runner"]
  node_server_run["Server-eval runner"]
end

subgraph group_training["Federated training"]
  node_partitions[("Client partitions")]
  node_scaler[("Shared scaler")]
  node_local_clients["Local-eval clients"]
  node_server_clients["Server-eval clients"]
  node_local_attack["Label flipping"]
  node_server_attack["Label flipping"]
end

subgraph group_detection["Detection and evaluation"]
  node_local_strategy["Local detection strategy"]
  node_server_strategy["Server detection strategy"]
  node_local_eval["Local evaluation"]
  node_server_eval["Server evaluation"]
end

subgraph group_outputs["Results and export"]
  node_local_log["Local run log"]
  node_server_log["Server run log"]
end

node_researcher(("Researcher"))
node_sheet[("Google Sheets")]

node_researcher -->|"starts run"| node_local_run
node_researcher -->|"starts run"| node_server_run
node_local_config -.->|"configures"| node_local_run
node_server_config -.->|"configures"| node_server_run
node_local_run -->|"starts simulation"| node_local_clients
node_server_run -.->|"starts simulation"| node_server_clients
node_partitions -->|"provides data"| node_local_clients
node_partitions -->|"provides data"| node_server_clients
node_scaler -->|"normalizes data"| node_server_clients
node_local_clients -->|"activates attack"| node_local_attack
node_server_clients -.->|"activates attack"| node_server_attack
node_local_clients -->|"sends updates"| node_local_strategy
node_server_clients -->|"sends updates"| node_server_strategy
node_local_strategy -->|"evaluates rounds"| node_local_eval
node_server_strategy -->|"evaluates rounds"| node_server_eval
node_local_strategy -->|"writes results"| node_local_log
node_server_strategy -->|"writes results"| node_server_log
node_local_log -->|"exports summary"| node_sheet
node_server_log -.->|"exports summary"| node_sheet

click node_local_config "https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/config.yaml"
click node_server_config "https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/config.yaml"
click node_local_run "https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py"
click node_server_run "https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py"
click node_partitions "https://github.com/swayam0611/federated-learning/tree/main/data/custom_splits/output_final"
click node_scaler "https://github.com/swayam0611/federated-learning/tree/main/shared"
click node_local_clients "https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py"
click node_server_clients "https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py"
click node_local_attack "https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py"
click node_server_attack "https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py"
click node_local_strategy "https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py"
click node_server_strategy "https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py"
click node_local_eval "https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py"
click node_server_eval "https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py"
click node_local_log "https://github.com/swayam0611/federated-learning/tree/main/metrics/local_eval"
click node_server_log "https://github.com/swayam0611/federated-learning/tree/main/metrics/server_eval"

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_local_config,node_server_config,node_local_run,node_server_run toneBlue
class node_partitions,node_scaler,node_local_clients,node_server_clients,node_local_attack,node_server_attack,node_sheet toneAmber
class node_local_strategy,node_server_strategy,node_local_eval,node_server_eval toneMint
class node_local_log,node_server_log toneRose
class node_researcher toneIndigo
```

## Components

### Run setup

- [Local config](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/config.yaml): `src_local_eval/config.yaml`
- [Server config](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/config.yaml): `src_server_eval/config.yaml`
- [Local-eval runner](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py): `src_local_eval/simulation_attack.py`
- [Server-eval runner](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py): `src_server_eval/simulation_attack.py`

### Federated training

- [Client partitions](https://github.com/swayam0611/federated-learning/tree/main/data/custom_splits/output_final): `data/custom_splits/output_final`
- [Shared scaler](https://github.com/swayam0611/federated-learning/tree/main/shared): `shared`
- [Local-eval clients](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py): `src_local_eval/simulation_attack.py`
- [Server-eval clients](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py): `src_server_eval/simulation_attack.py`
- [Label flipping](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py): `src_local_eval/simulation_attack.py`
- [Label flipping](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py): `src_server_eval/simulation_attack.py`

### Detection and evaluation

- [Local detection strategy](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py): `src_local_eval/simulation_attack.py`
- [Server detection strategy](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py): `src_server_eval/simulation_attack.py`
- [Local evaluation](https://github.com/swayam0611/federated-learning/blob/main/src_local_eval/simulation_attack.py): `src_local_eval/simulation_attack.py`
- [Server evaluation](https://github.com/swayam0611/federated-learning/blob/main/src_server_eval/simulation_attack.py): `src_server_eval/simulation_attack.py`

### Results and export

- [Local run log](https://github.com/swayam0611/federated-learning/tree/main/metrics/local_eval): `metrics/local_eval`
- [Server run log](https://github.com/swayam0611/federated-learning/tree/main/metrics/server_eval): `metrics/server_eval`

### Other components

- **Researcher**
- **Google Sheets**

## Connections

- Researcher → Local-eval runner: starts run (evidence: `readme.md`)
- Researcher → Server-eval runner: starts run (evidence: `readme.md`)
- Local config → Local-eval runner: configures
- Server config → Server-eval runner: configures
- Local-eval runner → Local-eval clients: starts simulation (evidence: `src_local_eval/simulation_attack.py`)
- Server-eval runner → Server-eval clients: starts simulation (evidence: `src_server_eval/simulation_attack.py`)
- Client partitions → Local-eval clients: provides data (evidence: `readme.md`)
- Client partitions → Server-eval clients: provides data (evidence: `src_server_eval/simulation_attack.py`)
- Shared scaler → Server-eval clients: normalizes data (evidence: `src_server_eval/simulation_attack.py`)
- Local-eval clients → Label flipping: activates attack (evidence: `src_local_eval/simulation_attack.py`)
- Server-eval clients → Label flipping: activates attack (evidence: `src_server_eval/simulation_attack.py`)
- Local-eval clients → Local detection strategy: sends updates (evidence: `readme.md`)
- Server-eval clients → Server detection strategy: sends updates (evidence: `readme.md`)
- Local detection strategy → Local evaluation: evaluates rounds (evidence: `src_local_eval/simulation_attack.py`)
- Server detection strategy → Server evaluation: evaluates rounds (evidence: `src_server_eval/simulation_attack.py`)
- Local detection strategy → Local run log: writes results (evidence: `src_local_eval/simulation_attack.py`)
- Server detection strategy → Server run log: writes results (evidence: `src_server_eval/simulation_attack.py`)
- Local run log → Google Sheets: exports summary
- Server run log → Google Sheets: exports summary
