# imdigitalashish/decentralized-mesh-model-training architecture

> Architecture diagram of the GitHub repository imdigitalashish/decentralized-mesh-model-training, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/imdigitalashish/decentralized-mesh-model-training
- Repository: https://github.com/imdigitalashish/decentralized-mesh-model-training

## Overview

##### Project type and purpose
- This is a full-stack, decentralized mesh model training system.
- The goal is to coordinate many worker nodes in a peer-to-peer or master/worker mesh, distributing ML training tasks, and provide a web UI for monitoring/control.

##### File structure
Top level:
– README.md
– backend/
– frontend/
Backend folder:
– master_server.py, worker_node.py, model.py, utils.py
– templates/main.html for server-side views
– experiment/ subfolder containing Go and Python experiments (main.go, main.py, worker.py, master.py)
Frontend folder:
– Next.js app (src/app) in TypeScript with globals.css, layout.tsx, page.tsx
– config files (package.json, tsconfig.json, eslint, postcss)

##### README
- No textual architecture description beyond that image link.

##### Detail
- Python script or Go binary as a micro-component if it has distinct responsibilities.
- Template rendering as part of the API layer.
- Mesh links if worker nodes talk to each other directly.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        direction TB
        UI["Next.js UI"]:::frontend
        Layout["layout.tsx"]:::frontend
        Page["page.tsx"]:::frontend
        Globals["globals.css"]:::frontend
        UI -->|uses| Layout
        UI -->|renders| Page
        UI -->|styles| Globals
    end

    %% Backend Layer
    subgraph "Backend Layer"
        direction TB
        APILayer["Master Server / API Layer"]:::backend
        WorkerNode["Worker Node (Python)"]:::backend
        ModelModule["Model Module"]:::backend
        Utils["Utilities"]:::backend
        Templates["HTML Templates"]:::backend
        APILayer -->|assigns tasks| WorkerNode
        WorkerNode -->|executes training| ModelModule
        ModelModule -->|calls utils| Utils
        APILayer -->|renders| Templates
    end

    %% Mesh Communication
    subgraph "Master/Worker Mesh"
        direction TB
        MeshMaster["Master Coordinator"]:::backend
        MeshWorkers["Worker Nodes (mesh)"]:::backend
        MeshMaster ---|task distribution| MeshWorkers
        MeshWorkers ---|parameter averaging| MeshWorkers
        APILayer -->|delegates to| MeshMaster
    end

    %% Experiment Prototypes
    subgraph "Experiment Services" 
        direction TB
        ExpFolder["Experiment Folder"]:::experiment
        GoMaster["Go Master Service"]:::experiment
        GoMod["go.mod & go.sum"]:::experiment
        PyMaster["Python Master Prototype"]:::experiment
        PyWorker["Python Worker Prototype"]:::experiment
        ExpFolder --> GoMod
        ExpFolder --> GoMaster
        ExpFolder --> PyMaster
        ExpFolder --> PyWorker
    end

    %% Frontend to Backend
    UI -->|HTTP/REST or WebSocket| APILayer

    %% Legend
    subgraph "Legend"
        direction TB
        A["Frontend Components"]:::frontend
        B["Backend Components"]:::backend
        C["Experiment Prototypes"]:::experiment
    end

    %% Click Events
    click UI "https://github.com/imdigitalashish/decentralized-mesh-model-training/tree/master/frontend/src/app"
    click Layout "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/frontend/src/app/layout.tsx"
    click Page "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/frontend/src/app/page.tsx"
    click Globals "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/frontend/src/app/globals.css"
    click APILayer "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/master_server.py"
    click WorkerNode "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/worker_node.py"
    click ModelModule "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/model.py"
    click Utils "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/utils.py"
    click Templates "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/templates/main.html"
    click MeshMaster "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/master_server.py"
    click ExpFolder "https://github.com/imdigitalashish/decentralized-mesh-model-training/tree/master/backend/experiment"
    click GoMaster "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/experiment/main.go"
    click GoMod "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/experiment/go.mod"
    click PyMaster "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/experiment/main.py"
    click PyWorker "https://github.com/imdigitalashish/decentralized-mesh-model-training/blob/master/backend/experiment/worker.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
    classDef backend fill:#D6F5D6,stroke:#28A745,color:#155724;
    classDef experiment fill:#FFE5B4,stroke:#FF8C00,stroke-dasharray: 5 5,color:#8B4513;
    classDef default stroke:#333,stroke-width:1px;
```
