# skydive-project/skydive architecture

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

- Interactive diagram: https://gitdiagram.com/skydive-project/skydive
- Repository: https://github.com/skydive-project/skydive

## Overview

- Agents: Represented by the “agent” directory and related probe and flow modules. These agents deploy on hosts and use multiple probes (BPF, eBPF, dpdk, pcap, ovs) to capture network topology and flows.
- Analyzer: Shown as a central server responsible for aggregating data from multiple agents (see “analyzer” directory, “api/server”, “cmd/analyzer”, etc.). This component handles storage, analysis, and query processing.
- API Layer & REST/Websocket Interfaces: Represent the API clients, servers, and Gremlin query endpoints (directories such as “api/client”, “api/server”, “graffiti”, “gremlin”, “cmd/client”). This layer exposes the REST API and provides a command-line client as well as a Web UI.
- Data Storage: Although not implemented entirely inside the codebase, the README mentions that topology and flow data is stored in an Elasticsearch database. Represent this external dependency separately.
- SDN/Cloud Integrations: Illustrate connectors for platforms like OpenStack, Docker, Kubernetes, OpenContrail, etc. (hinted at in the README and directories like “contrib/ansible”, “contrib/docker”, “contrib/kubernetes”). They extend the system with drivers to enrich the topology and flows.
- UI: The Web UI (served from the analyzer and using the static assets under “statics/ui” and “statics/ui_v2”) provides the front-end visualization.

##### Architectural Patterns and Design Principles
- Distributed System: Clearly separate roles between data collection (agents) and central processing/analysis (analyzer).
- Modular Design: Emphasize the use of “probes” and “drivers” (found in flow/probes, topology/probes, etc.) that allow extensible monitoring.
- API-Driven Communication: The system makes heavy use of RESTful endpoints, Websockets, and a unified query language (Gremlin) which should be reflected by dedicated API components.
- Plugin / Integration Extensibility: Mark the areas where additional SDN drivers or third-party integrations (e.g., via contributed Helm charts, Docker Compose configurations, or Ansible roles) plug into the main system.

##### Specific Elements to Highlight
– Data collection from physical or virtual hosts (agents) to analyzer;
– API calls and data queries from clients (UI/CLI) to the analyzer;
– Synchronization or data persistence from the analyzer to external storage.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Skydive Agents Subgraph
    subgraph "Skydive Agents"
        a1["Skydive Agent Core\n(agent/agent.go)"] 
        a2["Flow Probes\n(agent/flow_probes.go)"]
        a3["Topology Probes\n(agent/topology_probes.go)"]
    end

    %% Skydive Analyzer Subgraph
    subgraph "Skydive Analyzer"
        b1["Analyzer Server\n(analyzer/server.go)"]
        b2["Analyzer CLI\n(cmd/analyzer/analyzer.go)"]
    end

    %% API Layer & Query Engine Subgraph
    subgraph "API Layer & Query Engine"
        c1["API Server\n(api/server)"]
        c2["API Client\n(api/client/client.go)"]
        c3["Command-line Client\n(cmd/client)"]
        c4["Graffiti\n(gremlin endpoints)"]
    end

    %% User Interface Subgraph
    subgraph "User Interface"
        d1["Web UI v1\n(statics/ui)"]
        d2["Web UI v2\n(statics/ui_v2)"]
    end

    %% SDN/Cloud Integrations Subgraph
    subgraph "SDN/Cloud Integrations"
        e1["Ansible\n(contrib/ansible)"]
        e2["Docker\n(contrib/docker)"]
        e3["Kubernetes\n(contrib/kubernetes)"]
    end

    %% Data Storage (External Dependency)
    f["Elasticsearch Storage\n(flow/storage/elasticsearch)"]

    %% Connections
    a1 -->|"data_push"| b1

    b1 -->|"api_comm"| c1
    c1 -->|"api_comm"| b1

    c1 -->|"UI_interaction"| d1
    d1 -->|"UI_interaction"| c1

    b1 -->|"stores"| f

    e1 -->|"feeds_context"| b1
    e2 -->|"feeds_context"| b1
    e3 -->|"feeds_context"| b1

    %% Click Events for Skydive Agents
    click a1 "https://github.com/skydive-project/skydive/blob/master/agent/agent.go"
    click a2 "https://github.com/skydive-project/skydive/blob/master/agent/flow_probes.go"
    click a3 "https://github.com/skydive-project/skydive/blob/master/agent/topology_probes.go"

    %% Click Events for Skydive Analyzer
    click b1 "https://github.com/skydive-project/skydive/blob/master/analyzer/server.go"
    click b2 "https://github.com/skydive-project/skydive/blob/master/cmd/analyzer/analyzer.go"

    %% Click Events for API Layer & Query Engine
    click c1 "https://github.com/skydive-project/skydive/tree/master/api/server"
    click c2 "https://github.com/skydive-project/skydive/blob/master/api/client/client.go"
    click c3 "https://github.com/skydive-project/skydive/tree/master/cmd/client"
    click c4 "https://github.com/skydive-project/skydive/tree/master/graffiti"

    %% Click Events for User Interface
    click d1 "https://github.com/skydive-project/skydive/tree/master/statics/ui"
    click d2 "https://github.com/skydive-project/skydive/tree/master/statics/ui_v2"

    %% Click Events for SDN/Cloud Integrations
    click e1 "https://github.com/skydive-project/skydive/tree/master/contrib/ansible"
    click e2 "https://github.com/skydive-project/skydive/tree/master/contrib/docker"
    click e3 "https://github.com/skydive-project/skydive/tree/master/contrib/kubernetes"

    %% Click Event for Data Storage
    click f "https://github.com/skydive-project/skydive/tree/master/flow/storage/elasticsearch"

    %% Styles
    classDef collection fill:#AED581,stroke:#33691E,stroke-width:2px;
    classDef processing fill:#64B5F6,stroke:#1565C0,stroke-width:2px;
    classDef ui fill:#CE93D8,stroke:#8E24AA,stroke-width:2px;
    classDef external fill:#FFCC80,stroke:#F57C00,stroke-width:2px;
    classDef integration fill:#FFF59D,stroke:#FBC02D,stroke-width:2px;

    class a1,a2,a3 collection;
    class b1,b2 processing;
    class c1,c2,c3,c4 processing;
    class d1,d2 ui;
    class f external;
    class e1,e2,e3 integration;
```
