# superkkt/cherry architecture

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

- Interactive diagram: https://gitdiagram.com/superkkt/cherry
- Repository: https://github.com/superkkt/cherry

## Overview

- • OpenFlow Protocol Handler: Represent the modules in the “openflow” directory. Clearly separate out components handling versions 1.0 (located in openflow/of10) and 1.3 (in openflow/of13), along with shared components (e.g., openflow/action.go, openflow/message.go).
- • API Layer: The “api” directory (with its subdirectories like “core” and “ui”) handles REST API endpoints and may also expose the controller’s functionality to external systems.
- • Northbound Applications: Modules in the “northbound” directory contain several application components (e.g., DHCP, discovery, L2Switch, ProxyARP, VirtualIP, and monitoring apps). Display these as plug-in modules that interact with the core.
- • Network Components: The “network” directory encapsulates controllers for network sessions, topology, and device management. This module further integrates with the OpenFlow and protocol layers.
- • Protocol Utilities: The “protocol” directory holds helpers for ARP, DHCP, TCP/UDP, etc., used across the system.
- • Supporting Services: Other packages such as “database” (for MySQL integrations), “election” for leader election and clustering support, “graph” for network topology representation, as well as LDAP, logging (“log”), and version management.
- • Command-Line Tools: Components under the “cmd” directory (with their individual configuration files such as cherry.yaml and walnut.yaml) serve as the entry points or tools to initialize and run the controller.

##### Relationships and interactions
- Communication across the openflow protocol handlers and how they receive and send messages to the switch hardware.
- That northbound applications leverage the protocol utilities and the network component’s services to manage or monitor data.
- Demonstrate that command-line utilities (from the “cmd” directory) act as the entry point to initialize the controller, which in turn sets up the necessary modules and interfaces with the database.

##### Architectural patterns and design principles
- Modular and pluggable design: Cherry’s structure (e.g., northbound applications as independent submodules) supports a plugin-based architecture.
- Separation of concerns: Clear division between protocol handling, API management, northbound logic, core network operations, and supporting services (like database operations or LDAP).

##### Relevant technologies
- Go language is the primary development platform.
- MySQL (or MariaDB) serves as the backend database.
- Docker is an option for containerization (as indicated by the Dockerfile and installation instructions).
- Mention REST/HTTP for the API communications.
- OpenFlow protocols (versions 1.0 and 1.3) are central to the network operations.

##### Final checklist
- Primary components are clearly represented.
- Maintain clear labels and directional indicators for data/control flow.
- Be as detailed as possible to capture all modules from core OpenFlow handling to the northbound applications and external interfaces.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Command-Line Tools
    CLITools["CLI Tools"]:::cli

    %% API Layer
    subgraph "API Layer"
        APICore["API Core"]:::api
        APIUI["API UI"]:::api
    end

    %% Northbound Applications
    subgraph "Northbound Applications"
        NBManager["Northbound Manager"]:::northbound
        NBApps["Northbound Apps"]:::northbound
    end

    %% Network Components
    NetworkManager["Network Manager"]:::network

    %% Protocol Utilities
    ProtocolUtils["Protocol Utilities"]:::protocol

    %% OpenFlow Protocol Handler
    subgraph "OpenFlow Protocol Handler"
        OShared["OpenFlow Shared"]:::openflow
        OF10["OpenFlow 1.0"]:::openflow
        OF13["OpenFlow 1.3"]:::openflow
    end

    %% Supporting Services
    subgraph "Supporting Services"
        DB["Database"]:::support
        ElectionNode["Election"]:::support
        GraphNode["Graph"]:::support
        LDAPNode["LDAP"]:::support
        LogNode["Logging"]:::support
        VersionNode["Version"]:::support
    end

    %% Relationships and data flows
    CLITools -->|"init"| APICore
    APICore -->|"serves"| APIUI
    APICore -->|"commands"| NBManager
    NBManager -->|"manages"| NBApps
    NBApps -->|"utilizes"| ProtocolUtils
    NBApps -->|"controls"| NetworkManager
    NetworkManager -->|"of_commands"| OShared
    NetworkManager -->|"of_commands"| OF10
    NetworkManager -->|"of_commands"| OF13

    %% Supporting services interactions
    CLITools -->|"setup"| DB
    NetworkManager -->|"stores"| DB
    APICore -->|"auth"| LDAPNode
    APICore -->|"logs"| LogNode
    NetworkManager -->|"election"| ElectionNode
    NetworkManager -->|"topology"| GraphNode
    CLITools -->|"version"| VersionNode

    %% Click Events
    click OShared "https://github.com/superkkt/cherry/tree/master/openflow"
    click OF10 "https://github.com/superkkt/cherry/tree/master/openflow/of10"
    click OF13 "https://github.com/superkkt/cherry/tree/master/openflow/of13"
    click APICore "https://github.com/superkkt/cherry/tree/master/api/core"
    click APIUI "https://github.com/superkkt/cherry/tree/master/api/ui"
    click NBApps "https://github.com/superkkt/cherry/tree/master/northbound/app"
    click NBManager "https://github.com/superkkt/cherry/blob/master/northbound/manager.go"
    click NetworkManager "https://github.com/superkkt/cherry/tree/master/network"
    click ProtocolUtils "https://github.com/superkkt/cherry/tree/master/protocol"
    click DB "https://github.com/superkkt/cherry/tree/master/database"
    click ElectionNode "https://github.com/superkkt/cherry/blob/master/election/election.go"
    click GraphNode "https://github.com/superkkt/cherry/blob/master/graph/graph.go"
    click LDAPNode "https://github.com/superkkt/cherry/tree/master/ldap"
    click LogNode "https://github.com/superkkt/cherry/blob/master/log/syslog.go"
    click VersionNode "https://github.com/superkkt/cherry/blob/master/version.go"
    click CLITools "https://github.com/superkkt/cherry/tree/master/cmd"

    %% Styles
    classDef openflow fill:#D5E8D4,stroke:#82B366,stroke-width:2px;
    classDef api fill:#CFE2F3,stroke:#6C8EBF,stroke-width:2px;
    classDef northbound fill:#FCE5CD,stroke:#F1C232,stroke-width:2px;
    classDef network fill:#FFF2CC,stroke:#FFD966,stroke-width:2px;
    classDef protocol fill:#EAD1DC,stroke:#B97A57,stroke-width:2px;
    classDef support fill:#D9EAD3,stroke:#6AA84F,stroke-width:2px;
    classDef cli fill:#E4DFDA,stroke:#999999,stroke-width:2px;
```
