# brennoo/terraform-provider-hrui architecture

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

- Interactive diagram: https://gitdiagram.com/brennoo/terraform-provider-hrui
- Repository: https://github.com/brennoo/terraform-provider-hrui

## Overview

##### Key Components

a) Provider Configuration
**┌─ Provider Configuration ─┐**
- URL                   │
- Username             │
- Password             │
- ┘

b) Resource Management System
**┌─ Resource Manager ──────┐**
- ┌─ Resources ─────────┐│
- Port Settings      ││
- VLAN              ││
- QoS               ││
- MAC               ││
- ┘││
- ┘

c) Data Source System
**┌─ Data Sources ─────────┐**
- System Info          │
- Port Statistics      │
- MAC Table           │
- ┘

d) SDK Layer
**┌─ SDK Layer ───────────┐**
- HTTP Client         │
- HTML Parsing        │
- Form Submission     │
- ┘

##### Flow Directions

- Configuration flow from Terraform to the provider
- CRUD operations flow through the resource system
- Data retrieval flow through the data sources
- Communication flow between SDK and switch web UI

##### Component Relationships

Clear relationships between:
- Provider configuration and SDK client initialization
- Resource implementations and their corresponding SDK functions
- Data sources and their SDK query methods

##### Technical Details

- goquery integration points
- HTTP client configuration
- Resource state management
- Validation and error handling paths

**┌─ Terraform ──────────────────────────────────────┐**

- ┌─ Provider Configuration ─┐                    │
- (hrui)              │                    │
- ┬──────────┘                    │
- ▼                               │
- ┌─ Provider Core ────────────────────────┐     │
- ┌─ Resources ─┐    ┌─ Data Sources ─┐ │     │
- VLAN        │    │ System Info    │ │     │
- QoS         │    │ Statistics     │ │     │
- Port Config │    │ MAC Table      │ │     │
- ┘    └───────────────┘ │     │
- ┬────────────────────┘     │
- ▼                          │
- ┌─ SDK Layer ────────────────────────────┐   │
- HTTP Client | HTML Parser | Form Handler│   │
- ┬────────────────────────┘   │
- ┘
- ▼
**┌─ HRUI Switch Web Interface ─┐**
- (External System)           │
- ┘

Remember to:
- Use consistent styling
- Brief annotations for complex interactions
- Document any assumptions or limitations

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph TerraformLayer[Terraform Integration Layer]
        PC[Provider Configuration]
        PS[Provider Schema]
        CH[Configuration Handler]
    end

    subgraph CoreLayer[Core Provider Layer]
        subgraph Resources[Resource Management]
            PS1[Port Settings]
            VLAN[VLAN Management]
            QOS[QoS Management]
            MAC[MAC Management]
        end

        subgraph DataSources[Data Source System]
            SI[System Information]
            PST[Port Statistics]
            MT[MAC Table]
        end
    end

    subgraph SDKLayer[SDK Communication Layer]
        HC[HTTP Client]
        HP[HTML Parsing]
        FS[Form Submission]
        CS[Core SDK]
        UT[Utilities]
    end

    SWITCH[HRUI Switch Web Interface]:::external

    %% Connections
    PC --> CH
    CH --> PS
    PS --> Resources
    PS --> DataSources
    Resources --> CS
    DataSources --> CS
    CS --> HC
    CS --> HP
    CS --> FS
    CS --> UT
    HC --> SWITCH
    HP --> SWITCH
    FS --> SWITCH

    %% Click Events
    click PC "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/provider/provider.go"
    click PS "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/provider/schema.go"
    click CH "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/provider/configure.go"
    click PS1 "https://github.com/brennoo/terraform-provider-hrui/tree/main/internal/resources/port_settings"
    click VLAN "https://github.com/brennoo/terraform-provider-hrui/tree/main/internal/resources/vlan_8021q"
    click QOS "https://github.com/brennoo/terraform-provider-hrui/tree/main/internal/resources/qos_port_queue"
    click MAC "https://github.com/brennoo/terraform-provider-hrui/tree/main/internal/resources/mac_static"
    click SI "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/resources/system_info/data_source.go"
    click PST "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/resources/port_statistics/data_source.go"
    click MT "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/resources/mac_table/data_source.go"
    click HC "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/sdk/client.go"
    click HP "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/sdk/parsing.go"
    click FS "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/sdk/client.go"
    click CS "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/sdk/sdk.go"
    click UT "https://github.com/brennoo/terraform-provider-hrui/blob/main/internal/sdk/utils.go"

    %% Styling
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef terraform fill:#1565C0,color:#fff
    classDef core fill:#2E7D32,color:#fff
    classDef sdk fill:#EF6C00,color:#fff

    class TerraformLayer terraform
    class CoreLayer core
    class SDKLayer sdk
    class Resources core
    class DataSources core

    %% Legend
    subgraph Legend
        L1[Terraform Components]:::terraform
        L2[Core Components]:::core
        L3[SDK Components]:::sdk
        L4[External Systems]:::external
    end
```
