# argoproj-labs/terraform-provider-argocd architecture

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

- Interactive diagram: https://gitdiagram.com/argoproj-labs/terraform-provider-argocd
- Repository: https://github.com/argoproj-labs/terraform-provider-argocd

## Overview

##### Main Components

a) Provider Core Layer
- Main provider interface (`argocd/provider.go`)
- To resource handlers and schema definitions

b) Resource Management Layer
- Resource handlers (files starting with `resource_argocd_*`)
- Include:
- Applications
- Projects
- Clusters
- Repositories
- Tokens
- Certificates

c) Schema Definition Layer
- Schema files (`schema_*.go`)
- How they define the structure for each resource type

d) Internal Components
- Supporting internal packages:
- Diagnostics
- Features
- Provider implementations
- Validators
- Utils

e) External Integration Points
- ArgoCD API Server connection
- Terraform Registry interface
- Git repositories (for ArgoCD applications)

##### Specific Implementation Details

**┌─────────────────────────┐**
- Component Name          │
- ┤
- Key Files            │
- Main Responsibilities│
- ┘

##### Important Architectural Patterns to Highlight

- Resource Handler Pattern: Show how each resource type (application, project, etc.) has its own handler
- Schema-Resource Relationship: Demonstrate how schemas define resource structures
- Validation Flow: Show how validators are applied to resource configurations
- State Management: Illustrate how the provider manages resource state

##### Additional Elements

- Version compatibility information
- Configuration flow from Terraform to ArgoCD
- Authentication and authorization paths

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Provider Core"
        PC[Provider Core]:::core
        PI[Provider Implementation]:::core
    end

    subgraph "Resource Management"
        RA[Applications]:::resource
        RP[Projects]:::resource
        RC[Clusters]:::resource
        RR[Repositories]:::resource
        RT[Tokens]:::resource
        RCert[Certificates]:::resource
    end

    subgraph "Schema Definitions"
        SA[Application Schema]:::schema
        SP[Project Schema]:::schema
        SC[Cluster Schema]:::schema
        SR[Repository Schema]:::schema
        SL[Label Selector Schema]:::schema
        SM[Metadata Schema]:::schema
    end

    subgraph "Internal Components"
        ID[Diagnostics]:::internal
        IF[Features]:::internal
        IV[Validators]:::internal
        IU[Utils]:::internal
    end

    subgraph "Structure Components"
        StA[Application Structure]:::structure
        StP[Project Structure]:::structure
        StC[Cluster Structure]:::structure
        StR[Repository Structure]:::structure
        StM[Metadata Structure]:::structure
    end

    subgraph "External Systems"
        ArgoCD[ArgoCD API Server]:::external
        TF[Terraform Registry]:::external
        Git[Git Repositories]:::external
    end

    %% Core Connections
    PC --> PI
    PC --> RA & RP & RC & RR & RT & RCert

    %% Resource to Schema Connections
    RA --> SA
    RP --> SP
    RC --> SC
    RR --> SR
    RT --> SL
    RCert --> SM

    %% Structure Connections
    SA --> StA
    SP --> StP
    SC --> StC
    SR --> StR
    SM --> StM

    %% Internal Component Usage
    PC --> ID & IF & IV & IU
    RA & RP & RC & RR & RT & RCert --> IV
    RA & RP & RC & RR & RT & RCert --> IU

    %% External System Connections
    PC -.-> TF
    RA & RP & RC & RR & RT & RCert -.-> ArgoCD
    RA -.-> Git

    %% Click Events
    click PC "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/provider.go"
    click PI "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/internal/provider/provider.go"
    click RA "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/resource_argocd_application.go"
    click RP "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/resource_argocd_project.go"
    click RC "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/resource_argocd_cluster.go"
    click RR "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/resource_argocd_repository.go"
    click RT "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/resource_argocd_account_token.go"
    click RCert "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/resource_argocd_repository_certificate.go"
    click SA "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/schema_application.go"
    click SP "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/schema_project.go"
    click SC "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/schema_cluster.go"
    click SR "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/schema_repository.go"
    click SL "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/schema_label_selector.go"
    click SM "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/schema_metadata.go"
    click ID "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/internal/diagnostics/diagnostics.go"
    click IF "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/internal/features/features.go"
    click IV "https://github.com/argoproj-labs/terraform-provider-argocd/tree/main/internal/validators"
    click IU "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/internal/utils/utils.go"
    click StA "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/structure_application.go"
    click StP "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/structure_project.go"
    click StC "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/structure_cluster.go"
    click StR "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/structure_repository.go"
    click StM "https://github.com/argoproj-labs/terraform-provider-argocd/blob/main/argocd/structure_metadata.go"

    classDef core fill:#2374ab,stroke:#000,stroke-width:2px,color:#fff
    classDef resource fill:#57a773,stroke:#000,stroke-width:2px,color:#fff
    classDef schema fill:#ffc857,stroke:#000,stroke-width:2px,color:#000
    classDef internal fill:#95a5a6,stroke:#000,stroke-width:2px,color:#fff
    classDef structure fill:#8b5fbf,stroke:#000,stroke-width:2px,color:#fff
    classDef external fill:#e74c3c,stroke:#000,stroke-width:2px,color:#fff
```
