# kubeedge/sedna architecture

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

- Interactive diagram: https://gitdiagram.com/kubeedge/sedna
- Repository: https://github.com/kubeedge/sedna

## Overview

Based on our analysis of both the complete file tree and the README file, Sedna is an edge-cloud synergy framework designed to empower AI applications with distributed training and inference capabilities (joint inference, incremental learning, federated learning, lifelong learning). It leverages KubeEdge’s capabilities to orchestrate applications across cloud and edge nodes. Given the many directories (cmd, pkg, lib, components, examples, docs, build, etc.) and multiple configuration artifacts (CRDs, helm charts, Dockerfiles, etc.), the system is clearly a large-scale, cloud-native project written in Go and leveraging Kubernetes for orchestration.

##### Main Components
- LocalController – runs on edge nodes. Found under pkg/localcontroller, it handles local process control, model and dataset synchronization, and communicates with GlobalManager.
- Worker – individual processes (or containerized microservices) that perform the training and inference tasks. They are instantiated on both edge and cloud and communicate with the managers. The cmd directories (cmd/sedna-gm and cmd/sedna-lc) and parts of the pkg indicate how these workers are triggered.
- Lib – the exposed library (located in lib/sedna) providing APIs for integrating existing training or inference scripts with Sedna’s edge-cloud mechanisms.
- Kubernetes Custom Resources (CRDs), Helm Charts, and CRD samples – these are visible under build/, pkg/apis, and build/helm which show how Sedna extends Kubernetes with its own resource definitions for handling dataset, model, and various job types.
- Dashboard/Observability components – found in components/dashboard, which include exporters, Grafana setup, and Prometheus configurations for monitoring various metrics.
- Data Sources and External Connectors – see lib/sedna/datasources (for Kafka, OBS, etc.) that handle data ingestion.
- Other supporting components – such as the global websocket messaging layer (in pkg/globalmanager/messagelayer), various algorithm implementations under lib/sedna/algorithms, and integration with popular AI frameworks (TensorFlow, PyTorch, PaddlePaddle, MindSpore).

##### Relationships and Interactions
- Cloud and Edge Separation: Illustrate the “Cloud” with GlobalManager and supporting centralized components (configuration, orchestration, message routing) and the “Edge” with LocalController and Worker nodes.
– GlobalManager sending configurations and job orchestration commands to LocalControllers.
– LocalControllers coordinating with Workers to execute training/inference tasks.
– Data flow from Workers back to GlobalManager for aggregating model updates and synchronizing results.
– CRD-based interactions where Kubernetes manages Sedna’s custom AI job types.
– Messaging and real-time sync via websocket channels (pkg/globalmanager/messagelayer).

##### Architectural Patterns and Technologies
- Microservices: Different components (GlobalManager, LocalController, Worker) are isolated and interact via clear API boundaries.
- Containerization and Orchestration: Use of Dockerfiles, helm charts, and Kubernetes CRDs indicates a cloud-native design.
- Extensibility: The lib and algorithms directories suggest a plug-in approach where new AI features or integrations can be added.
- Observability: Inclusion of dashboards (Grafana, Prometheus, Loki) to monitor system health and performance.

##### Capturing Essential Architectural Elements
- Do not shy away from detailing the interactions between the API layer provided by pkg/apis and how sedna extends Kubernetes.
- It’s helpful to also note where example usage (in the examples directory) fits into the picture, showing that Sedna supports real-world AI application deployment.
- A section on how the library (lib/sedna) and the algorithm implementations plug into the broader ecosystem, enabling different learning strategies.

##### Final Advice

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Cloud Control Plane"
        GM["GlobalManager"]:::cloud
        GMWL["Websocket Messaging Layer"]:::cloud
        CRD["Kubernetes CRDs"]:::cloud
        HELM["Helm Charts"]:::cloud
        DASH["Dashboard/Observability"]:::cloud
        WCloud["Worker (Cloud)"]:::cloud
    end

    subgraph "Edge Nodes"
        LC["LocalController"]:::edge
        WEdge["Worker (Edge)"]:::edge
    end

    subgraph "Integration & Libraries"
        LIB["Lib (APIs, Algorithms)"]:::library
        DS["Data Sources & External Connectors"]:::library
    end

    KUBEEDGE["KubeEdge"]:::external

    %% Connections between Cloud and Edge components
    GM -->|"configuration_commands"| LC
    LC -->|"execute_tasks"| WEdge
    WEdge -->|"model_updates"| GM
    GM -->|"orchestration"| WCloud
    GM -->|"sync_messages"| GMWL
    GMWL -->|"sync"| GM
    WCloud -->|"report_metrics"| DASH
    GM -->|"report_metrics"| DASH

    %% Kubernetes orchestration related flows
    GM -->|"orchestrates"| CRD
    CRD -->|"event_feedback"| GM
    GM -->|"deploys_charts"| HELM
    HELM -->|"chart_updates"| GM

    %% KubeEdge connectivity
    KUBEEDGE -->|"connectivity"| LC
    KUBEEDGE -->|"connectivity"| GM

    %% Integration and extensibility flows
    LIB -->|"integrates_AI"| GM
    LIB -->|"integrates_AI"| WEdge
    LIB -->|"integrates_AI"| WCloud
    DS -->|"data_ingestion"| LIB
    DS -->|"data_ingestion"| WEdge
    DS -->|"data_ingestion"| WCloud

    %% Click Events
    click GM "https://github.com/kubeedge/sedna/tree/main/pkg/globalmanager"
    click GMWL "https://github.com/kubeedge/sedna/tree/main/pkg/globalmanager/messagelayer"
    click LC "https://github.com/kubeedge/sedna/tree/main/pkg/localcontroller"
    click WCloud "https://github.com/kubeedge/sedna/tree/main/cmd/sedna-gm"
    click WEdge "https://github.com/kubeedge/sedna/tree/main/cmd/sedna-lc"
    click LIB "https://github.com/kubeedge/sedna/tree/main/lib/sedna"
    click CRD "https://github.com/kubeedge/sedna/tree/main/build/crds"
    click HELM "https://github.com/kubeedge/sedna/tree/main/build/helm/sedna"
    click DASH "https://github.com/kubeedge/sedna/tree/main/components/dashboard"
    click DS "https://github.com/kubeedge/sedna/tree/main/lib/sedna/datasources"

    %% Styles
    classDef cloud fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef edge fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef library fill:#D5F5E3,stroke:#1E8449,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
