# vpatel95/go-netconf architecture

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

- Interactive diagram: https://gitdiagram.com/vpatel95/go-netconf
- Repository: https://github.com/vpatel95/go-netconf

## Overview

##### Project type and purpose
- This is a Go-based library (not a full-stack app) that implements a NETCONF client per RFC6241/6242.
- Purpose: provide a programmable API for executing NETCONF RPCs over SSH (with pluggable transports) against network devices.

##### File structure
- Top-level files: README.md, LICENSE, .gitignore, .travis.yml, go.mod, go.sum.
- examples/: sample programs showing how to use the library (juniper, ssh1, ssh2).
- netconf/: core library code:
- rpc.go, rpc_test.go – defines RPC building blocks and tests.
- session.go – session management, message framing, sequencing.
- transport.go, transport_junos.go, transport_ssh.go – abstract transport interface and concrete implementations.
- transport_*.go + transport_*.go tests – verify transport behaviors.

##### README for additional insights
- Features list: SSH transport, pluggable RPCs, XML-library independent.
- Examples directory pointed out.
- Intended for Go 1.9+, pre-alpha with evolving API.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Example Applications"
        ExJ["Juniper Example"]:::examples
        ExS1["SSH1 Example"]:::examples
        ExS2["SSH2 Example"]:::examples
    end

    subgraph "go-netconf Library"
        subgraph "API Layer"
            API["netconf/rpc.go"]:::library
        end
        subgraph "Session Layer"
            Session["netconf/session.go"]:::library
        end
        subgraph "Transport Layer"
            TransportI["netconf/transport.go"]:::library
            SSHImpl["netconf/transport_ssh.go"]:::library
            JunosExt["netconf/transport_junos.go"]:::library
        end
    end

    subgraph "Tests"
        RPCtest["netconf/rpc_test.go"]:::test
        TransTest["netconf/transport_test.go"]:::test
        SSHTest["netconf/transport_ssh_test.go"]:::test
    end

    subgraph "External Dependencies"
        XML["XML Parser (encoding/xml)"]:::external
        SSHlib["SSH Library (golang.org/x/crypto/ssh)"]:::external
    end

    Device["Network Device (NETCONF Server)"]:::device

    %% Call and data flows
    ExJ -->|"invoke RPC builder"| API
    ExS1 -->|"invoke RPC builder"| API
    ExS2 -->|"invoke RPC builder"| API
    API -->|"build RPC"| Session
    Session -->|"use transport interface"| TransportI
    TransportI -->|"calls SSH Impl"| SSHImpl
    TransportI -->|"calls Junos Ext"| JunosExt
    SSHImpl -->|"uses SSH lib"| SSHlib
    JunosExt -->|"uses SSH lib"| SSHlib
    SSHlib -->|"connect"| Device
    Device -->|"NETCONF XML response"| SSHlib
    SSHlib -->|"raw data"| SSHImpl
    SSHImpl -->|"raw data"| TransportI
    TransportI -->|"raw data"| Session
    Session -->|"parsed RPC reply"| API
    API -->|"RPC response"| ExJ
    API -->|"RPC response"| ExS1
    API -->|"RPC response"| ExS2
    Session -->|"XML parsing"| XML

    %% Click Events
    click ExJ "https://github.com/vpatel95/go-netconf/blob/master/examples/juniper/get_system_information.go"
    click ExS1 "https://github.com/vpatel95/go-netconf/blob/master/examples/ssh1/ssh1.go"
    click ExS2 "https://github.com/vpatel95/go-netconf/blob/master/examples/ssh2/ssh2.go"
    click API "https://github.com/vpatel95/go-netconf/blob/master/netconf/rpc.go"
    click RPCtest "https://github.com/vpatel95/go-netconf/blob/master/netconf/rpc_test.go"
    click Session "https://github.com/vpatel95/go-netconf/blob/master/netconf/session.go"
    click TransportI "https://github.com/vpatel95/go-netconf/blob/master/netconf/transport.go"
    click SSHImpl "https://github.com/vpatel95/go-netconf/blob/master/netconf/transport_ssh.go"
    click JunosExt "https://github.com/vpatel95/go-netconf/blob/master/netconf/transport_junos.go"
    click TransTest "https://github.com/vpatel95/go-netconf/blob/master/netconf/transport_test.go"
    click SSHTest "https://github.com/vpatel95/go-netconf/blob/master/netconf/transport_ssh_test.go"
    click README "https://github.com/vpatel95/go-netconf/blob/master/README.md"
    click LICENSE "https://github.com/vpatel95/go-netconf/tree/master/LICENSE"
    click Travis "https://github.com/vpatel95/go-netconf/blob/master/.travis.yml"
    click Gitignore "https://github.com/vpatel95/go-netconf/blob/master/.gitignore"
    click GoMod "https://github.com/vpatel95/go-netconf/blob/master/go.mod"
    click GoSum "https://github.com/vpatel95/go-netconf/blob/master/go.sum"

    %% Styles
    classDef library fill:#cce5ff,stroke:#0000ff;
    classDef examples fill:#d4edda,stroke:#28a745;
    classDef external fill:#fff3cd,stroke:#ffc107;
    classDef device fill:#e2e3e5,stroke:#6c757d;
    classDef test fill:#f8d7da,stroke:#dc3545;
```
