# pjsalty/terraform-provider-truenas architecture

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

- Interactive diagram: https://gitdiagram.com/pjsalty/terraform-provider-truenas
- Repository: https://github.com/pjsalty/terraform-provider-truenas

## Overview

This is a Terraform provider for managing TrueNAS SCALE. A Terraform configuration enters through the provider, which configures a shared authenticated WebSocket client; resource and data-source implementations use that client to manage or read TrueNAS state and return it to Terraform. The graph preserves the major resource domains and sampled concrete operations. Many domain-specific resource/client calls were not excerpted, so their links are left unasserted; subsystem coverage follows the repository tree and README.

Main entry points: [`internal/resources`](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources) (Managed resources), [`internal/provider/provider.go`](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/provider/provider.go) (Provider setup), [`internal/wsclient/app.go`](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/app.go) (App RPC methods), [`main.go`](https://github.com/pjsalty/terraform-provider-truenas/blob/main/main.go) (Provider process)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Provider entry"]
  node_provider["Provider setup<br/>[provider.go]"]
  node_plugin["Provider process<br/>[main.go]"]
end

subgraph group_terraform["Terraform operations"]
  node_resource_lifecycle["Managed resources"]
  node_datasource_reads["Data sources"]
  node_app_resource["App lifecycle<br/>[app.go]"]
  node_directory_resource["Directory services"]
  node_service_resource["Service control<br/>[service.go]"]
  node_alert_resource["Alert services<br/>[alert_service.go]"]
  node_app_datasource["App lookup<br/>[app.go]"]
  node_apps_datasource["App listing<br/>[apps.go]"]
end

subgraph group_client["WebSocket client"]
  node_app_client["App RPC methods<br/>[app.go]"]
  node_directory_client["Directory RPC methods"]
  node_service_client["Service RPC methods<br/>[service.go]"]
  node_ws_transport["RPC transport<br/>[wsclient.go]"]
end

subgraph group_domains["TrueNAS domains"]
  node_storage["Storage resources"]
  node_sharing["File sharing"]
  node_network["Network configuration"]
  node_virtualization["Apps and virtualization"]
  node_identity_security["Identity and security"]
  node_system_tasks["System and tasks"]
end

node_operator(("Terraform configuration"))
node_server[("TrueNAS SCALE")]

node_operator -->|"runs provider"| node_plugin
node_plugin -->|"serves"| node_provider
node_provider -->|"registers resources"| node_resource_lifecycle
node_provider -->|"registers sources"| node_datasource_reads
node_provider -->|"configures client"| node_ws_transport
node_app_resource -->|"calls app RPCs"| node_app_client
node_directory_resource -->|"calls config RPCs"| node_directory_client
node_service_resource -->|"calls service RPCs"| node_service_client
node_app_datasource -->|"reads app"| node_app_client
node_apps_datasource -->|"lists apps"| node_app_client
node_app_client -->|"JSON-RPC calls"| node_server
node_directory_client -.->|"JSON-RPC calls"| node_server
node_service_client -.->|"JSON-RPC calls"| node_server
node_ws_transport -->|"WebSocket connection"| node_server
node_resource_lifecycle -.->|"covers"| node_storage
node_resource_lifecycle -.->|"covers"| node_sharing
node_resource_lifecycle -.->|"covers"| node_network
node_resource_lifecycle -.->|"covers"| node_virtualization
node_resource_lifecycle -.->|"covers"| node_identity_security
node_resource_lifecycle -.->|"covers"| node_system_tasks

click node_provider "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/provider/provider.go"
click node_plugin "https://github.com/pjsalty/terraform-provider-truenas/blob/main/main.go"
click node_resource_lifecycle "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"
click node_datasource_reads "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/datasources"
click node_app_resource "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/app.go"
click node_directory_resource "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/directoryservices.go"
click node_service_resource "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/service.go"
click node_alert_resource "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/alert_service.go"
click node_app_datasource "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/datasources/app.go"
click node_apps_datasource "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/datasources/apps.go"
click node_app_client "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/app.go"
click node_directory_client "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/directoryservices.go"
click node_service_client "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/service.go"
click node_ws_transport "https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/wsclient.go"
click node_storage "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"
click node_sharing "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"
click node_network "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"
click node_virtualization "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"
click node_identity_security "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"
click node_system_tasks "https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_provider,node_plugin toneBlue
class node_resource_lifecycle,node_datasource_reads,node_app_resource,node_directory_resource,node_service_resource,node_alert_resource,node_app_datasource,node_apps_datasource,node_server toneAmber
class node_app_client,node_directory_client,node_service_client,node_ws_transport toneMint
class node_storage,node_sharing,node_network,node_virtualization,node_identity_security,node_system_tasks toneRose
class node_operator toneIndigo
```

## Components

### Provider entry

- [Provider setup](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/provider/provider.go): `internal/provider/provider.go`
- [Provider process](https://github.com/pjsalty/terraform-provider-truenas/blob/main/main.go): `main.go`

### Terraform operations

- [Managed resources](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`
- [Data sources](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/datasources): `internal/datasources`
- [App lifecycle](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/app.go): `internal/resources/app.go`
- [Directory services](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/directoryservices.go): `internal/resources/directoryservices.go`
- [Service control](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/service.go): `internal/resources/service.go`
- [Alert services](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/resources/alert_service.go): `internal/resources/alert_service.go`
- [App lookup](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/datasources/app.go): `internal/datasources/app.go`
- [App listing](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/datasources/apps.go): `internal/datasources/apps.go`

### WebSocket client

- [App RPC methods](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/app.go): `internal/wsclient/app.go`
- [Directory RPC methods](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/directoryservices.go): `internal/wsclient/directoryservices.go`
- [Service RPC methods](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/service.go): `internal/wsclient/service.go`
- [RPC transport](https://github.com/pjsalty/terraform-provider-truenas/blob/main/internal/wsclient/wsclient.go): `internal/wsclient/wsclient.go`

### TrueNAS domains

- [Storage resources](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`
- [File sharing](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`
- [Network configuration](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`
- [Apps and virtualization](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`
- [Identity and security](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`
- [System and tasks](https://github.com/pjsalty/terraform-provider-truenas/tree/main/internal/resources): `internal/resources`

### Other components

- **Terraform configuration**
- **TrueNAS SCALE**

## Connections

- Terraform configuration → Provider process: runs provider (evidence: `main.go`)
- Provider process → Provider setup: serves (evidence: `main.go`)
- Provider setup → Managed resources: registers resources (evidence: `internal/provider/provider.go`)
- Provider setup → Data sources: registers sources (evidence: `internal/provider/provider.go`)
- Provider setup → RPC transport: configures client (evidence: `internal/provider/provider.go`)
- App lifecycle → App RPC methods: calls app RPCs (evidence: `internal/resources/app.go`)
- Directory services → Directory RPC methods: calls config RPCs (evidence: `internal/resources/directoryservices.go`)
- Service control → Service RPC methods: calls service RPCs (evidence: `internal/resources/service.go`)
- App lookup → App RPC methods: reads app (evidence: `internal/datasources/app.go`)
- App listing → App RPC methods: lists apps (evidence: `internal/datasources/apps.go`)
- App RPC methods → TrueNAS SCALE: JSON-RPC calls (evidence: `internal/wsclient/app.go`)
- Directory RPC methods → TrueNAS SCALE: JSON-RPC calls
- Service RPC methods → TrueNAS SCALE: JSON-RPC calls
- RPC transport → TrueNAS SCALE: WebSocket connection (evidence: `README.md`)
- Managed resources → Storage resources: covers
- Managed resources → File sharing: covers
- Managed resources → Network configuration: covers
- Managed resources → Apps and virtualization: covers
- Managed resources → Identity and security: covers
- Managed resources → System and tasks: covers
