# sameernadaf21/survey-federated-learning architecture

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

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

## Overview

##### Project Type and Purpose
- This is a Python-based federated-learning framework/experimental tool (“sameernadaf21survey-federated-learning”).
- It orchestrates multiple client processes that each train a local ML model on private data, and a central server process that aggregates client updates into a global model.

##### File-Structure Analysis
- Top-level directories:
- client/
- server/
- conf/ (Hydra configuration)
- outputs/ and client/outputs/, server/outputs/ (Hydra run outputs)
- client/ contains:
- rem_client.py (client entrypoint)
- client_class.py (encapsulates client logic)
- dataset.py (local data loader)
- model.py (client-side model definition)
- server/ contains:
- server.py (server entrypoint)
- server_helper.py (aggregation utilities)
- dataset.py (if the server simulates a global dataset or validation set)
- model.py (global model definition or aggregator interface)
- conf/base.yaml: global Hydra config (hyperparameters, addresses, schedules).
- Hydra outputs folders: store logs, config snapshots, and artifacts (results.pkl).

##### Key Architectural Patterns and Components
a. Components:
1) Config Manager (Hydra)
2) Client Nodes (1…N)
– Client Class
– Local Dataset
– Local Model
– rem_client.py (invokes training, sends updates)
3) Server Node
– Aggregation Engine (server.py + server_helper.py)
– Global Model
– (Optional) Global/validation dataset
4) Storage/Logging subsystem
– Hydra outputs folders for client and server runs
b. Relationships & Interactions:
– Clients read Hydra configs → train local models → serialize parameter updates/logs → send to Server
– Server listens for client updates → aggregates (e.g., FedAvg) → updates global model → writes new model and logs
– (Optional) Server distributes the new global model back to clients for next round
– All components read/write to the outputs directory under Hydra’s control
c. Technologies & Frameworks:
– Python 3.x
– Hydra for configuration management
– ML framework (e.g., PyTorch or TensorFlow—see requirements.txt)
– Standard libraries for file I/O, logging, serialization (pickle)
d. Architectural Patterns:
– Federated-learning pattern (client-server aggregation)
– Hydra-driven experiment orchestration
– Modular code separation: data-loading, modeling, orchestration

a. Sketch a Config Manager block at the top (Hydra).
– Hydra for config
– Storage block (server/outputs)
d. In the Server block, annotate the aggregation step (“FedAvg” or similar) and link to the “model.py” artifact.
e. In each Client block, annotate the training loop (“dataset.py” → “model.py” → “update send”).

- Clear component labels (e.g., “Client Trainer”, “Server Aggregator”, “Hydra Config”)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Config Manager
    Hydra["Hydra Config Manager"]:::config
    click Hydra "https://github.com/sameernadaf21/survey-federated-learning/blob/main/conf/base.yaml"

    %% Client Layer
    subgraph "Client Pool"
        direction TB
        rem_client["rem_client.py"]:::compute
        click rem_client "https://github.com/sameernadaf21/survey-federated-learning/blob/main/client/rem_client.py"
        client_class["client_class.py"]:::compute
        click client_class "https://github.com/sameernadaf21/survey-federated-learning/blob/main/client/client_class.py"
        client_dataset["dataset.py"]:::compute
        click client_dataset "https://github.com/sameernadaf21/survey-federated-learning/blob/main/client/dataset.py"
        client_model["model.py"]:::compute
        click client_model "https://github.com/sameernadaf21/survey-federated-learning/blob/main/client/model.py"
        client_outputs[(Client Outputs)]:::storage
        click client_outputs "https://github.com/sameernadaf21/survey-federated-learning/tree/main/client/outputs/"
    end

    %% Server Layer
    subgraph "Server Aggregator"
        direction TB
        server_entry["server.py"]:::compute
        click server_entry "https://github.com/sameernadaf21/survey-federated-learning/blob/main/server/server.py"
        server_helper["server_helper.py"]:::compute
        click server_helper "https://github.com/sameernadaf21/survey-federated-learning/blob/main/server/server_helper.py"
        server_dataset["dataset.py"]:::compute
        click server_dataset "https://github.com/sameernadaf21/survey-federated-learning/blob/main/server/dataset.py"
        server_model["model.py"]:::compute
        click server_model "https://github.com/sameernadaf21/survey-federated-learning/blob/main/server/model.py"
        server_outputs[(Server Outputs)]:::storage
        click server_outputs "https://github.com/sameernadaf21/survey-federated-learning/tree/main/server/outputs/"
    end

    %% Shared Storage
    shared_outputs[(Shared Outputs)]:::storage
    click shared_outputs "https://github.com/sameernadaf21/survey-federated-learning/tree/main/outputs/"

    %% Interactions
    Hydra -->|"config.yaml"| rem_client
    Hydra -->|"config.yaml"| server_entry
    rem_client -->|"model weights"| server_entry
    server_entry -->|"new global model"| rem_client
    rem_client -->|"updates & logs"| client_outputs
    server_entry -->|"results.pkl, server.log"| server_outputs
    server_entry -->|"fallback artifacts"| shared_outputs

    %% Styles
    classDef compute fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef config fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef storage fill:#FFA500,stroke:#000,stroke-width:1px;
```
