# fmorsbach/simplefedml architecture

> Architecture diagram of the GitHub repository fmorsbach/simplefedml, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fmorsbach/simplefedml
- Repository: https://github.com/fmorsbach/simplefedml

## Overview

##### Project type and purpose
- This is a simple federated machine-learning (FedML) demo built in Python.
- It consists of a central server (Flask-based HTTP “federation coordinator”) and multiple clients that train local models and submit updates.

##### File structure
- Root: .gitignore, README.md
- client/
– ReferenceModel.py  (defines the TensorFlow model architecture)
– main.py            (client main loop: fetch global model, train locally, send updates)
- server/
– Model.py                   (model definition or helper)
– CentralFederation.py       (core aggregation logic: average weights)
– HTTPCentralFederation.py   (Flask app exposing REST endpoints for clients)

##### README for additional insights
- Implements naive model averaging using TensorFlow
- Communication over HTTP via a Flask server

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Clients"
        direction TB
        ClientRef["ReferenceModel.py"]:::client
        ClientTrain["Client Trainer (main.py)"]:::client
    end

    subgraph "Server"
        direction TB
        subgraph "Networking"
            HTTPAPI["Flask HTTP API\n(HTTPCentralFederation.py)"]:::server
        end
        subgraph "Aggregation"
            ModelDef["Model.py\n(model helper)"]:::server
            Aggregator["CentralFederation\n(aggregation engine)"]:::server
            ModelStore[(Global Model Store)]:::store
        end
    end

    subgraph "Project Root"
        README["README.md"]:::docs
        GitIgnore[".gitignore"]:::docs
    end

    ClientTrain -->|"HTTP GET /get_model"| HTTPAPI
    HTTPAPI -->|"returns global weights"| ClientRef
    ClientRef -->|"provides model to trainer"| ClientTrain
    ClientTrain -->|"HTTP POST /submit_update"| HTTPAPI
    HTTPAPI -->|"forwards updates"| Aggregator
    Aggregator -->|"loads model via Model.py"| ModelDef
    Aggregator -->|"updates weights"| ModelStore
    ModelStore -->|"serves weights"| HTTPAPI

    click ClientRef "https://github.com/fmorsbach/simplefedml/blob/master/client/ReferenceModel.py"
    click ClientTrain "https://github.com/fmorsbach/simplefedml/blob/master/client/main.py"
    click ModelDef "https://github.com/fmorsbach/simplefedml/blob/master/server/Model.py"
    click Aggregator "https://github.com/fmorsbach/simplefedml/blob/master/server/CentralFederation.py"
    click HTTPAPI "https://github.com/fmorsbach/simplefedml/blob/master/server/HTTPCentralFederation.py"
    click README "https://github.com/fmorsbach/simplefedml/blob/master/README.md"
    click GitIgnore "https://github.com/fmorsbach/simplefedml/blob/master/.gitignore"

    classDef client fill:#b7e4c7,stroke:#2d6a4f,color:#0f5132;
    classDef server fill:#bee5eb,stroke:#1b4965,color:#0c2d48;
    classDef store fill:#ffd8a8,stroke:#e85d04,color:#663c00;
    classDef docs fill:#e2e3e5,stroke:#495057,color:#212529;
```
