# vmware/terraform-provider-nsxt architecture

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

- Interactive diagram: https://gitdiagram.com/vmware/terraform-provider-nsxt
- Repository: https://github.com/vmware/terraform-provider-nsxt

## Overview

- Terraform CLI & Provider Interface – This is how Terraform (when you run terraform init/apply) communicates with the provider.
- Provider Plugin Core – The heart of the provider (main.go and the provider configuration code) that accepts commands from Terraform.
- API Client & Resource Modules – The internal Go packages such as the “api” directory, “nsxt” directory, and various domain/resource-specific files (e.g., security policies, tiers, DHCP configurations, etc.). These modules encapsulate the logic to call VMware NSX APIs.
- NSX Management/External API – Representing the external VMware NSX product that the provider communicates with.
- CI/CD & Testing Pipeline – Elements like .github workflows, Travis, and various build and test scripts indicate that there is a robust automation layer which validates the provider. Although not part of runtime architecture, include it to understand the development lifecycle.

- Optionally, add a branch or auxiliary section for CI/CD tools and automated testing (GitHub Actions, Travis, etc.) to indicate that changes in the provider code trigger automated validations.

##### Architectural Patterns/Design Principles
- Plugin Architecture: Emphasize the separation between Terraform core and the provider.
- Modularization: The project’s file tree shows granular packages grouped by functionality (e.g., “api/infra”, “nsxt”, “tools”, “docs”). This indicates clear modular boundaries between resource definitions, utilities, and documentation.
- Dependency Management: Notice files like “go.mod,” “go.sum,” and continuous integration scripts; include a note on how the provider leverages Go modules and CI workflows (build, linting, tests) for modular, high-quality development.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Terraform Operations"
        TFC["Terraform CLI & Provider Interface"]:::cli
    end

    subgraph "Provider Core"
        PP["Provider Plugin Core"]:::provider
    end

    subgraph "API Resource Modules"
        API["API Client Modules (api directory)"]:::api
        NSXT["NSX Resource Modules (nsxt directory)"]:::api
    end

    subgraph "External Systems"
        NSX_API["VMware NSX Management API"]:::external
    end

    subgraph "CI/CD & Testing"
        GITHUB[".github"]:::cicd
        TRAVIS[".travis.yml"]:::cicd
        WORKFLOW[".github/workflows"]:::cicd
    end

    TFC -->|"TerraformCalls"| PP
    PP -->|"CRUDoperations"| API
    PP -->|"CRUDoperations"| NSXT
    API -->|"APICalls"| NSX_API
    NSXT -->|"APICalls"| NSX_API
    GITHUB ---|"Triggers"| PP
    TRAVIS ---|"Triggers"| PP
    WORKFLOW ---|"Triggers"| PP

    click TFC "https://github.com/vmware/terraform-provider-nsxt/blob/master/main.go"
    click PP "https://github.com/vmware/terraform-provider-nsxt/blob/master/nsxt/provider.go"
    click API "https://github.com/vmware/terraform-provider-nsxt/tree/master/api"
    click NSXT "https://github.com/vmware/terraform-provider-nsxt/tree/master/nsxt"
    click GITHUB "https://github.com/vmware/terraform-provider-nsxt/blob/master/.github"
    click TRAVIS "https://github.com/vmware/terraform-provider-nsxt/blob/master/.travis.yml"
    click WORKFLOW "https://github.com/vmware/terraform-provider-nsxt/tree/master/.github/workflows"

    classDef cli fill:#ffcccc,stroke:#990000,stroke-width:2px;
    classDef provider fill:#cce5ff,stroke:#003366,stroke-width:2px;
    classDef api fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef external fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef cicd fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
```
