# pantheontech/lighty architecture

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

- Interactive diagram: https://gitdiagram.com/pantheontech/lighty
- Repository: https://github.com/pantheontech/lighty

## Overview

##### Project Type and Purpose
- lighty.io is an SDK/framework (not a monolithic app) for building Java-SE SDN controllers. It adapts core OpenDaylight components (MD-SAL, YANG Tools, clustering) to run in plain Java SE and provides a plugin architecture for SouthBound and NorthBound protocols, pluggable dependency-injection (Guice/Spring), example applications, YANG model artifacts, and resource assemblies.

##### Key Parts of the File Structure
- Top-level Maven aggregator (`pom.xml`) that pulls in:
· lighty-core (controller, clustering, codecs, DI extensions)
· lighty-modules (SouthBound plugins: NETCONF, gNMI; NorthBound plugins: RESTCONF, OpenAPI; AAA)
· lighty-examples (sample applications using the framework)
· lighty-models (YANG modules)
· lighty-applications (ready-to-run controller apps packaged with Docker/Helm)
· lighty-resources (configuration assemblies and startup scripts)
· tests and CI workflows

a. Java SE Runtime Layer
- Represents the plain-Java environment (JDK 21).
b. Core Controller (lighty-core)
- MD-SAL services: Datastores (config/operational), RPC framework, Notifications
- YANG Tools integration
- Clustering service (Akka/Kubernetes handler)
- Codec utilities (JSON/XML converters)
c. Dependency-Injection Layer
- Guice module loader or Spring context loader (choose one per app).
- Responsible for wiring Core + Modules.
d. Module Container
- AbstractLightyModule registry, lifecycle (start/stop/restart modules).
e. SouthBound Protocol Plugins (lighty-modules/netconf-sb, lighty-modules/gnmi-sb)
- NETCONF SB: establishes sessions to devices, call-home plugin, NMDA support
- gNMI SB: gNMI session manager, request builders, GNOI invokers (file, system, cert storage)
f. NorthBound Protocol Plugins (lighty-modules/restconf-nb-community, lighty-modules/openapi)
- RESTCONF community API with YANG-driven resources
- OpenAPI (REST + Swagger) endpoints
g. AAA Module
- Authentication/authorization service exposing HTTP endpoint on Jetty
h. Jetty Server Abstraction (lighty-modules/jetty-server)
- HTTP/2 & HTTPS server builder, security configuration
i. Applications (lighty-applications)
- Aggregator projects that bundle the Core + selected Modules + DI choice + resource configs
- Packaged into Docker images and Helm charts
j. External Systems
- SouthBound: real network devices speaking NETCONF or gNMI
- NorthBound: clients (CLI, Postman, external orchestrators) calling RESTCONF or OpenAPI
k. Examples and Tests
- Demonstrate usage and provide integration test suites

##### Component Interactions and Data Flow
- On startup, the application’s `main()` boots the DI layer (Guice or Spring).
- DI initializes the Core Controller services and Module Container.
- Module Container invokes each Module’s `onModuleStart()`, registering RPCs, listeners, datastore initializers.
- SB Plugins create and manage sessions to devices, push data into the operational datastore, trigger notifications.
- NB Plugins serve configuration and operational data from datastores via RESTCONF endpoints (Jetty), and handle RPCs (e.g., RPCs to initiate gNMI operations).
- AAA Module intercepts northbound requests for authentication/authorization.
- Clustering handler replicates datastores/notifications among controller instances if deployed in Kubernetes.
- Applications supply configuration files (YANG init data), resource assemblies, and start-up scripts.

##### Architectural Patterns and Principles
- Plugin Architecture: Modules conform to a LightyModule API and are loosely coupled
- Layered Architecture: Java SE → Core Services → DI Layer → Module Container → Protocol Plugins → Applications
- Dependency Injection: Guice or Spring choice isolates wiring logic
- Aggregator Pattern: Maven aggregator projects bundle only needed modules for a controller flavor
- YANG-driven Data Modeling: All north-/south-bound interactions use YANG schemas

## Diagram (Mermaid)

```mermaid
graph TD

    subgraph "Java SE Runtime Layer"
        JDK["JDK 21"]:::runtime
    end

    subgraph "Core Services"
        CoreController["Core Controller\n(lighty-controller)"]:::core
        DataStores["MD-SAL Datastore\n(config/oper)"]:::core
        RPC["RPC Framework\n(YANG Tools RPC)"]:::core
        Notifications["Notifications Service"]:::core
        YANGTools["YANG Tools Integration"]:::core
        ClusteringService["Clustering Service\n(Akka/K8s)"]:::core
        CodecUtilities["Codec Utilities\n(JSON/XML)"]:::core
    end

    subgraph "Dependency-Injection Layer"
        GuiceInjector["Guice Injector"]:::di
        SpringContext["Spring Context"]:::di
    end

    subgraph "Module Container"
        ModuleContainer["Module Container\n(AbstractLightyModule)"]:::di
    end

    subgraph "Modules"
        subgraph "SouthBound Plugins"
            NETCONF["NETCONF SB"]:::sb
            gNMI["gNMI SB"]:::sb
        end
        subgraph "Shared Modules"
            AAA["AAA Module"]:::shared
            JettyServer["Jetty Server"]:::shared
        end
        subgraph "NorthBound Plugins"
            RESTCONF["RESTCONF NB"]:::nb
            OpenAPI["OpenAPI NB"]:::nb
        end
    end

    subgraph "Applications & Packaging"
        ModulesConfig["ModulesConfig Utility"]:::app
        AppRCgNMI["rC-gNMI App"]:::app
        AppRNC["rN-C App"]:::app
        Resources["Resource Assemblies"]:::app
        StartScript["Startup Script"]:::app
        Docker["Docker Image"]:::app
        Helm["Helm Chart"]:::app
    end

    subgraph "External Systems"
        Devices["Network Devices"]:::external
        Clients["Northbound Clients"]:::external
    end

    JDK --> CoreController
    CoreController --> DataStores
    CoreController --> RPC
    CoreController --> Notifications
    CoreController --> YANGTools
    CoreController --> ClusteringService
    CoreController --> CodecUtilities

    GuiceInjector --> CoreController
    SpringContext --> CoreController

    GuiceInjector --> ModuleContainer
    SpringContext --> ModuleContainer

    ModuleContainer --> NETCONF
    ModuleContainer --> gNMI
    ModuleContainer --> AAA
    ModuleContainer --> JettyServer
    ModuleContainer --> RESTCONF
    ModuleContainer --> OpenAPI

    NETCONF --> DataStores
    gNMI --> DataStores
    Devices --> NETCONF
    Devices --> gNMI

    RESTCONF --> DataStores
    OpenAPI --> DataStores

    Clients --> RESTCONF
    Clients --> OpenAPI

    Clients --> AAA
    AAA --> RESTCONF
    AAA --> OpenAPI

    ModuleContainer --> ClusteringService
    ClusteringService --> DataStores

    AppRCgNMI --> ModulesConfig
    AppRCgNMI --> GuiceInjector
    AppRNC --> ModulesConfig
    AppRNC --> SpringContext

    AppRCgNMI --> Resources
    AppRCgNMI --> StartScript
    AppRNC --> Resources
    AppRNC --> StartScript

    AppRCgNMI --> Docker
    AppRCgNMI --> Helm
    AppRNC --> Docker
    AppRNC --> Helm

    click CoreController "https://github.com/pantheontech/lighty/tree/main/lighty-core/lighty-controller/src/main/java/io/lighty/core/controller"
    click ClusteringService "https://github.com/pantheontech/lighty/tree/main/lighty-core/lighty-clustering/src/main/java/io/lighty/core/cluster"
    click CodecUtilities "https://github.com/pantheontech/lighty/tree/main/lighty-core/lighty-codecs-util/src/main/java/io/lighty/codecs/util"
    click GuiceInjector "https://github.com/pantheontech/lighty/tree/main/lighty-core/lighty-controller-guice-di/src/main/java/io/lighty/core/controller/guice"
    click SpringContext "https://github.com/pantheontech/lighty/tree/main/lighty-core/lighty-controller-spring-di/src/main/java/io/lighty/core/controller/spring"
    click ModuleContainer "https://github.com/pantheontech/lighty/blob/main/lighty-core/lighty-controller/src/main/java/io/lighty/core/controller/api/AbstractLightyModule.java"
    click NETCONF "https://github.com/pantheontech/lighty/tree/main/lighty-modules/lighty-netconf-sb/src/main/java/io/lighty/modules/southbound/netconf"
    click gNMI "https://github.com/pantheontech/lighty/tree/main/lighty-modules/lighty-gnmi-sb/src/main/java/io/lighty/gnmi/southbound"
    click RESTCONF "https://github.com/pantheontech/lighty/tree/main/lighty-modules/lighty-restconf-nb-community/src/main/java/io/lighty/modules/northbound/restconf/community"
    click OpenAPI "https://github.com/pantheontech/lighty/blob/main/lighty-modules/lighty-openapi/src/main/java/io/lighty/openapi/OpenApiLighty.java"
    click AAA "https://github.com/pantheontech/lighty/blob/main/lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/main/java/io/lighty/aaa/AAALighty.java"
    click JettyServer "https://github.com/pantheontech/lighty/blob/main/lighty-modules/lighty-jetty-server/src/main/java/io/lighty/server/LightyServerBuilder.java"
    click ModulesConfig "https://github.com/pantheontech/lighty/blob/main/lighty-applications/lighty-app-modules-config/src/main/java/io/lighty/applications/util/ModulesConfig.java"
    click AppRCgNMI "https://github.com/pantheontech/lighty/tree/main/lighty-applications/lighty-rcgnmi-app-aggregator/lighty-rcgnmi-app-aggregator"
    click AppRNC "https://github.com/pantheontech/lighty/tree/main/lighty-applications/lighty-rnc-app-aggregator/lighty-rnc-app-aggregator"
    click Resources "https://github.com/pantheontech/lighty/tree/main/lighty-resources/controller-application-assembly/src/main/resources"
    click StartScript "https://github.com/pantheontech/lighty/blob/main/lighty-resources/start-script/src/main/resources/start-controller.sh"

    classDef runtime fill:#f0f0f0
    classDef core fill:#ADD8E6
    classDef di fill:#ffa500
    classDef sb fill:#98fb98
    classDef nb fill:#dda0dd
    classDef shared fill:#ffffe0
    classDef app fill:#a9a9a9
    classDef external fill:#ffffff,stroke-dasharray:5 5
```
