# wombelix/terraform-provider-sourcehut architecture

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

- Interactive diagram: https://gitdiagram.com/wombelix/terraform-provider-sourcehut
- Repository: https://github.com/wombelix/terraform-provider-sourcehut

## Overview

##### Main Components

a) Provider Core
- Configuration handling and authentication flow
- Provider_test.go component for testing infrastructure

b) Resource Handlers (Left Side)
- Resource handlers:
- resource_repo.go (Repository management)
- resource_ssh_key.go (SSH key management)
- resource_pgp_key.go (PGP key management)
- Their relationship to the provider core

c) Data Source Handlers (Right Side)
- Data source handlers:
- data_source_blob.go
- data_source_paste.go
- data_source_repo.go
- data_source_user.go
- Them to the provider core

d) External Interactions (Top)
- sourcehut API connection
- Terraform/OpenTofu Plugin SDK interface
- Authentication mechanism

##### Relationship Flows

- Terraform/OpenTofu   |
- Plugin System      |

- ↕

- Provider Core       |
- (provider.go)        |

- ↙               ↘

- Resource  |    |  Data    |
- Handlers  |    | Sources  |

- ↓               ↓

- sourcehut API      |

##### Implementation Details

- Rectangles: Main components
- Hexagons: External services
- Diamonds: Decision points

- Component types
- Special symbols

##### Additional Elements

- Version information
- Build/CI integration points
- Configuration flow
- Document error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Systems
    subgraph External["External Systems"]
        direction TB
        TF[Terraform/OpenTofu Plugin System]:::external
        API[sourcehut API]:::external
    end

    %% Provider Core
    subgraph Core["Provider Core"]
        direction TB
        MAIN[Main Entry]:::core
        PROV[Provider Handler]:::core
        TEST[Provider Tests]:::core
    end

    %% Resource Handlers
    subgraph Resources["Resource Handlers"]
        direction TB
        REPO[Repository Manager]:::resource
        SSH[SSH Key Manager]:::resource
        PGP[PGP Key Manager]:::resource
    end

    %% Data Source Handlers
    subgraph DataSources["Data Source Handlers"]
        direction TB
        BLOB[Blob Handler]:::datasource
        PASTE[Paste Handler]:::datasource
        DREPO[Repository Data]:::datasource
        USER[User Data]:::datasource
    end

    %% Documentation
    subgraph Docs["Documentation"]
        direction TB
        PDOC[Provider Docs]:::docs
        RDOC[Resource Docs]:::docs
        DDOC[Data Source Docs]:::docs
    end

    %% Build Configuration
    subgraph Build["Build & Configuration"]
        direction TB
        MAKE[Makefile]:::build
        RELEASE[Goreleaser]:::build
        MANIFEST[Registry Manifest]:::build
        WORKFLOW[Release Workflow]:::build
    end

    %% Relationships
    TF <--> MAIN
    MAIN --> PROV
    PROV <--> API
    
    PROV --> Resources
    PROV --> DataSources
    
    Resources --> API
    DataSources --> API
    
    TEST -.-> PROV

    %% Click Events
    click MAIN "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/main.go"
    click PROV "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/provider.go"
    click TEST "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/provider_test.go"
    click REPO "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/resource_repo.go"
    click SSH "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/resource_ssh_key.go"
    click PGP "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/resource_pgp_key.go"
    click BLOB "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/data_source_blob.go"
    click PASTE "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/data_source_paste.go"
    click DREPO "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/data_source_repo.go"
    click USER "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/data_source_user.go"
    click PDOC "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/docs/index.md"
    click RDOC "https://github.com/wombelix/terraform-provider-sourcehut/tree/main/docs/resources"
    click DDOC "https://github.com/wombelix/terraform-provider-sourcehut/tree/main/docs/data-sources"
    click RELEASE "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/.goreleaser.yml"
    click WORKFLOW "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/.github/workflows/release.yml"
    click MANIFEST "https://github.com/wombelix/terraform-provider-sourcehut/blob/main/terraform-registry-manifest.json"
    click MAKE "https://github.com/wombelix/terraform-provider-sourcehut/tree/main/Makefile"

    %% Styles
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef core fill:#blue,stroke:#333,stroke-width:2px
    classDef resource fill:#green,stroke:#333,stroke-width:2px
    classDef datasource fill:#yellow,stroke:#333,stroke-width:2px
    classDef docs fill:#purple,stroke:#333,stroke-width:2px
    classDef build fill:#orange,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        direction TB
        L1[External Systems]:::external
        L2[Core Components]:::core
        L3[Resource Handlers]:::resource
        L4[Data Sources]:::datasource
        L5[Documentation]:::docs
        L6[Build Config]:::build
    end
```
