# sameulah/slperf architecture

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

- Interactive diagram: https://gitdiagram.com/sameulah/slperf
- Repository: https://github.com/sameulah/slperf

## Overview

- Configuration & Parsing:
– Highlight the config.yaml file and the parsing modules (in the Parse, JSON, and YAML directories) that evaluate user settings. Mention the factory design pattern (parseFactory) used to load configurations.
- Data Handling:
– Mark the data directory and the dataset-related modules under SLFrame/core/dataset. Include the dataset factory, partition components (basePartition, partitionFactory, and partitionUtils), and dataset controllers that are specialized for different datasets (e.g., mnistController, cifar10Controller).
- Communication Layer:
– Identify the communication modules under SLFrame/core/communication and the MPI-specific files (mpi_com_manager, mpi_receive_thread, mpi_send_thread). Emphasize that these handle the low-level message passing and observer patterns.
- Model Management:
– Represent the model directory components including various architectures (Alex_model.py, DenseNet.py, cnn.py, etc.) and their corresponding factories. This portion represents how training models are defined and instantiated for both clients and servers.
- Process Management:
– Include the process directory with baseClient, baseServer, and their respective managers. This is the orchestration layer that initializes and runs the training loops, models, and communication paths.
- Variants / Paradigms:
– Highlight the variants folder that contains multiple subdirectories (such as SplitFed, TaskAgnostic, Asynchronous, vanilla, etc.). Each variant includes its own client, client_manager, message_define, server, and server_manager. Emphasize that these modules extend the base process to support different federated learning paradigms.
- Logging:
– Represent the logging modules (Log, abstractLog, baseLog) as well as output log files which are crucial for tracing and debugging the distributed training processes.

##### Relationships and data flow between components
- How the client and server models (defined under the model directory) are separately instantiated within the main function. Also, show how these models are passed to the respective client and server processes, which are managed by their corresponding base classes in the process directory.

##### Important architectural patterns and design principles
- Factory Patterns: Emphasize how the system uses factory modules (parseFactory, datasetFactory, modelFactory, variantsFactory) to create specific objects based on the user configuration.
- Modularity & Separation of Concerns: Clearly separate the concerns of configuration, data management, communication, model definition, and process orchestration.
- Distributed System Principles: Note the use of MPI and messaging that enable multi-process coordination in a federated learning setup.
- Extensibility: The variants folder shows a pluggable architecture – each variant (e.g., SplitFed, TaskAgnostic, asyVanilla, etc.) encapsulates its own client/server logic, making it easy to extend.

##### Additional notes
- To capture the hierarchical nature of the project – from high-level system orchestration down to detailed functions within each module.
- If desired, add notes on dependency: for instance, the configuration drives both dataset selection and model instantiation, and all components ultimately rely on the MPI-based communication backbone for distributed learning.

## Diagram (Mermaid)

```mermaid
flowchart TD 
    subgraph "Configuration & Parsing"
        CP1["config.yaml"]:::config
        CP2["abstractParse"]:::config
        CP3["baseParse"]:::config
        CP4["jsonParse"]:::config
        CP5["yamlParse"]:::config
        CP6["parseFactory"]:::config
    end

    subgraph "Data Handling"
        D1["abstractDataset"]:::data
        D2["baseDataset"]:::data
        D3["datasetFactory"]:::data
        D4["basePartition"]:::data
        D5["partitionFactory"]:::data
        D6["partitionUtils"]:::data
        D7["mnistController"]:::data
        D8["cifar10Controller"]:::data
        D9["Data Storage"]:::data
    end

    subgraph "Communication Layer"
        C1["base_com_manager"]:::comm
        C2["message"]:::comm
        C3["msg_manager"]:::comm
        C4["observer"]:::comm
        C5["mpi_com_manager"]:::comm
        C6["mpi_receive_thread"]:::comm
        C7["mpi_send_thread"]:::comm
    end

    subgraph "Model Management"
        M1["Model Definitions"]:::model
        M2["modelFactory"]:::model
        M3["model_factory"]:::model
    end

    subgraph "Process Management"
        P1["Client Process"]:::proc
        P2["Client Manager"]:::proc
        P3["Server Process"]:::proc
        P4["Server Manager"]:::proc
    end

    subgraph "Variants / Paradigms"
        V1["variantsFactory"]:::variant
        V2["Variant: Client"]:::variant
        V3["Variant: Client Manager"]:::variant
        V4["Variant: Message Define"]:::variant
        V5["Variant: Server"]:::variant
        V6["Variant: Server Manager"]:::variant
    end

    subgraph "Logging"
        L1["Log"]:::log
        L2["abstractLog"]:::log
        L3["baseLog"]:::log
    end

    %% Connections between components
    CP1 --> CP6
    CP6 -->|"loadConfig"| D3
    CP6 -->|"selectVariant"| V1
    D3 --> D7
    D3 --> D8
    D3 -->|"prepareDataset"| D1
    D1 --> D2
    D5 --> D4
    C5 --> C6
    C5 --> C7
    M2 --> M1
    M3 --> M1
    M1 -->|"initializeModel"| P1
    M1 -->|"initializeModel"| P3
    P1 --> P2
    P3 --> P4
    P1 -->|"sendMessage"| C1
    P3 -->|"sendMessage"| C1
    V1 --> V2
    V1 --> V3
    V1 --> V4
    V1 --> V5
    V1 --> V6
    %% Logging connections (for monitoring)
    P1 -.-> L1
    C1 -.-> L1

    %% Legend (for color-code)
    subgraph "Legend"
        LG1["Configuration = Blue"]
        LG2["Data Handling = Green"]
        LG3["Communication = Orange"]
        LG4["Model Management = Red"]
        LG5["Process Management = Purple"]
        LG6["Variants = Yellow"]
        LG7["Logging = Teal"]
    end
    style LG1 fill:#a7d3f5,stroke:#333,stroke-width:1px;
    style LG2 fill:#c7f5a7,stroke:#333,stroke-width:1px;
    style LG3 fill:#f5d1a7,stroke:#333,stroke-width:1px;
    style LG4 fill:#f5a7a7,stroke:#333,stroke-width:1px;
    style LG5 fill:#d3a7f5,stroke:#333,stroke-width:1px;
    style LG6 fill:#f5f5a7,stroke:#333,stroke-width:1px;
    style LG7 fill:#a7f5d3,stroke:#333,stroke-width:1px;

    %% Click Events
    click CP1 "https://github.com/sameulah/slperf/blob/master/SLFrame/config.yaml"
    click CP2 "https://github.com/sameulah/slperf/blob/master/SLFrame/Parse/abstractParse.py"
    click CP3 "https://github.com/sameulah/slperf/blob/master/SLFrame/Parse/baseParse.py"
    click CP4 "https://github.com/sameulah/slperf/blob/master/SLFrame/Parse/JSON/jsonParse.py"
    click CP5 "https://github.com/sameulah/slperf/blob/master/SLFrame/Parse/YAML/yamlParse.py"
    click CP6 "https://github.com/sameulah/slperf/blob/master/SLFrame/Parse/parseFactory.py"
    click D1 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/abstractDataset.py"
    click D2 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/baseDataset.py"
    click D3 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/datasetFactory.py"
    click D4 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/partition/basePartition.py"
    click D5 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/partition/partitionFactory.py"
    click D6 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/partition/partitionUtils.py"
    click D7 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/controller/mnistController.py"
    click D8 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/dataset/controller/cifar10Controller.py"
    click D9 "https://github.com/sameulah/slperf/tree/master/SLFrame/data/"
    click C1 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/base_com_manager.py"
    click C2 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/message.py"
    click C3 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/msg_manager.py"
    click C4 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/observer.py"
    click C5 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/mpi/mpi_com_mananger.py"
    click C6 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/mpi/mpi_receive_thread.py"
    click C7 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/communication/mpi/mpi_send_thread.py"
    click M2 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/model/modelFactory.py"
    click M3 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/model/model_factory.py"
    click P1 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/process/baseClient.py"
    click P2 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/process/baseClientManager.py"
    click P3 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/process/baseServer.py"
    click P4 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/process/baseServerManageger.py"
    click V1 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/variants/variantsFactory.py"
    click L1 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/log/Log.py"
    click L2 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/log/abstractLog.py"
    click L3 "https://github.com/sameulah/slperf/blob/master/SLFrame/core/log/baseLog.py"

    %% Style Definitions
    classDef config fill:#a7d3f5,stroke:#333,stroke-width:2px;
    classDef data fill:#c7f5a7,stroke:#333,stroke-width:2px;
    classDef comm fill:#f5d1a7,stroke:#333,stroke-width:2px;
    classDef model fill:#f5a7a7,stroke:#333,stroke-width:2px;
    classDef proc fill:#d3a7f5,stroke:#333,stroke-width:2px;
    classDef variant fill:#f5f5a7,stroke:#333,stroke-width:2px;
    classDef log fill:#a7f5d3,stroke:#333,stroke-width:2px;
```
