# roxanneluo/federated-learning architecture

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

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

## Overview

This repository is a prototype for federated MNIST training. A client connects to the Flask-SocketIO server, receives model configuration, prepares a local non-IID dataset, trains on server-requested rounds, and returns weights and metrics; the server aggregates updates and can request final evaluation. The dashboard and stats endpoint expose training progress. Elastic averaging and multi-client launching are present as experimental extensions; the README’s multi-server gossip and client-only peer-to-peer approaches are stated as exploration goals, not implemented workflows. Evidence is limited to the excerpts and README.

Main entry points: [`fl_server.py`](https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py) (Socket server), [`fl_client.py`](https://github.com/roxanneluo/federated-learning/blob/master/fl_client.py) (Federated client), [`ea_client.py`](https://github.com/roxanneluo/federated-learning/blob/master/ea_client.py) (Elastic client), [`templates/dashboard.html`](https://github.com/roxanneluo/federated-learning/blob/master/templates/dashboard.html) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_coordination["Server coordination"]
  node_flserver["Socket server<br/>[fl_server.py]"]
  node_globalmodel["Global model<br/>[fl_server.py]"]
  node_aggregation["Weight aggregation<br/>[fl_server.py]"]
  node_metrics[("Training metrics<br/>[fl_server.py]")]
  node_dashboard["Dashboard<br/>[dashboard.html]"]
end

subgraph group_client["Client training"]
  node_client["Federated client<br/>[fl_client.py]"]
  node_localmodel["Local model<br/>[fl_client.py]"]
end

subgraph group_data["Data and models"]
  node_dataset["MNIST partitions<br/>[datasource.py]"]
  node_mnistmodel["MNIST CNN<br/>[fl_server.py]"]
end

subgraph group_experiments["Experiments"]
  node_clientlauncher["Multi-client launcher<br/>[multi_client.py]"]
  node_elasticclient["Elastic client<br/>[ea_client.py]"]
  node_elasticprotocol["Elastic sync hooks<br/>[ea_client.py]"]
  node_weighthelper["Weighted server helper<br/>[server.py]"]
end

node_operator(("Operator"))

node_operator -->|"opens service"| node_flserver
node_operator -->|"views progress"| node_dashboard
node_flserver -->|"initializes"| node_globalmodel
node_globalmodel -->|"builds"| node_mnistmodel
node_flserver -->|"sends configuration"| node_client
node_client -->|"sends updates"| node_flserver
node_client -->|"requests partitions"| node_dataset
node_client -->|"creates and trains"| node_localmodel
node_flserver -->|"aggregates received updates"| node_aggregation
node_aggregation -->|"updates weights"| node_globalmodel
node_flserver -->|"records metrics"| node_metrics
node_flserver -->|"serves view"| node_dashboard
node_clientlauncher -->|"starts processes"| node_client
node_elasticclient -->|"extends client"| node_client
node_elasticclient -->|"uses sync hooks"| node_elasticprotocol
node_weighthelper -.->|"alternative averaging"| node_aggregation
node_flserver -->|"serves stats"| node_metrics

click node_flserver "https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py"
click node_globalmodel "https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py"
click node_aggregation "https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py"
click node_metrics "https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py"
click node_dashboard "https://github.com/roxanneluo/federated-learning/blob/master/templates/dashboard.html"
click node_client "https://github.com/roxanneluo/federated-learning/blob/master/fl_client.py"
click node_localmodel "https://github.com/roxanneluo/federated-learning/blob/master/fl_client.py"
click node_dataset "https://github.com/roxanneluo/federated-learning/blob/master/datasource.py"
click node_mnistmodel "https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py"
click node_clientlauncher "https://github.com/roxanneluo/federated-learning/blob/master/multi_client.py"
click node_elasticclient "https://github.com/roxanneluo/federated-learning/blob/master/ea_client.py"
click node_elasticprotocol "https://github.com/roxanneluo/federated-learning/blob/master/ea_client.py"
click node_weighthelper "https://github.com/roxanneluo/federated-learning/blob/master/server.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_flserver,node_globalmodel,node_aggregation,node_metrics,node_dashboard toneBlue
class node_client,node_localmodel toneAmber
class node_dataset,node_mnistmodel toneMint
class node_clientlauncher,node_elasticclient,node_elasticprotocol,node_weighthelper toneRose
class node_operator toneIndigo
```

## Components

### Server coordination

- [Socket server](https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py): `fl_server.py`
- [Global model](https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py): `fl_server.py`
- [Weight aggregation](https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py): `fl_server.py`
- [Training metrics](https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py): `fl_server.py`
- [Dashboard](https://github.com/roxanneluo/federated-learning/blob/master/templates/dashboard.html): `templates/dashboard.html`

### Client training

- [Federated client](https://github.com/roxanneluo/federated-learning/blob/master/fl_client.py): `fl_client.py`
- [Local model](https://github.com/roxanneluo/federated-learning/blob/master/fl_client.py): `fl_client.py`

### Data and models

- [MNIST partitions](https://github.com/roxanneluo/federated-learning/blob/master/datasource.py): `datasource.py`
- [MNIST CNN](https://github.com/roxanneluo/federated-learning/blob/master/fl_server.py): `fl_server.py`

### Experiments

- [Multi-client launcher](https://github.com/roxanneluo/federated-learning/blob/master/multi_client.py): `multi_client.py`
- [Elastic client](https://github.com/roxanneluo/federated-learning/blob/master/ea_client.py): `ea_client.py`
- [Elastic sync hooks](https://github.com/roxanneluo/federated-learning/blob/master/ea_client.py): `ea_client.py`
- [Weighted server helper](https://github.com/roxanneluo/federated-learning/blob/master/server.py): `server.py`

### Other components

- **Operator**

## Connections

- Operator → Socket server: opens service (evidence: `fl_server.py`)
- Operator → Dashboard: views progress
- Socket server → Global model: initializes (evidence: `fl_server.py`)
- Global model → MNIST CNN: builds (evidence: `fl_server.py`)
- Socket server → Federated client: sends configuration (evidence: `fl_server.py`)
- Federated client → Socket server: sends updates (evidence: `fl_client.py`)
- Federated client → MNIST partitions: requests partitions (evidence: `fl_client.py`)
- Federated client → Local model: creates and trains (evidence: `fl_client.py`)
- Socket server → Weight aggregation: aggregates received updates (evidence: `fl_server.py`)
- Weight aggregation → Global model: updates weights (evidence: `fl_server.py`)
- Socket server → Training metrics: records metrics (evidence: `fl_server.py`)
- Socket server → Dashboard: serves view (evidence: `fl_server.py`)
- Multi-client launcher → Federated client: starts processes (evidence: `multi_client.py`)
- Elastic client → Federated client: extends client (evidence: `ea_client.py`)
- Elastic client → Elastic sync hooks: uses sync hooks (evidence: `ea_client.py`)
- Weighted server helper → Weight aggregation: alternative averaging
- Socket server → Training metrics: serves stats (evidence: `fl_server.py`)
