# htcd-subham/terraform-examples architecture

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

- Interactive diagram: https://gitdiagram.com/htcd-subham/terraform-examples
- Repository: https://github.com/htcd-subham/terraform-examples

## Overview

##### Main Components
- Repository Core: Represent the repository itself as the central container labeled “Qovery Terraform Examples.”
- Terraform Files: Within each example, the key entry points are the main.tf (which defines the provider configurations and resource declarations) and variables.tf (which encapsulates input parameters). These should be indicated as subcomponents within each example module.
- External Dependencies: Since many examples deploy to cloud infrastructures that involve services like AWS, Cloudflare, PostgreSQL, Redis, GitHub, or even specific applications like Strapi or Medusa, mark these as external service nodes. Also, include the Qovery Terraform provider as a critical integration point that orchestrates the deployments.

##### Relationships/Interactions
- That each "main.tf" file serves as the configuration to drive resource provisioning through the Qovery provider—so show a link from the Terraform module to the Qovery provider and then to the underlying cloud service(s).
- That variables.tf provides the configuration settings needed for customization across different environments (e.g., Production, Staging, Dev in some examples).

##### Architectural Patterns
- Modularization: The structure is organized so that each deployment scenario is isolated into its own folder, each following Terraform’s modular and declarative model.
- Infrastructure-as-Code (IaC) Paradigm: The design follows IaC best practices, clearly representing infrastructure definitions as code that gets versioned and stored in this repository.
- Reusability: The templates are built to be adaptable. They provide a solid baseline that can be customized through variable inputs, which is a common design principle when using Terraform.

##### Relevant Technologies/Frameworks
- Terraform: Represented as the primary engine to orchestrate deployments.
- Qovery Terraform Provider: Acts as the intermediary between Terraform code and Qovery’s API for cloud deployments.
- Specific Services: For example, PostgreSQL and Redis for the Medusa example, API endpoints for the GitHub App example, etc.

##### Detailed Capture
- Don’t shy away from including each example as an individual block. Since the repository’s purpose is to provide a suite of examples, demonstrating how each case connects to both Qovery’s Terraform provider and various external services is key.
- Optionally, group similar deployment types together (e.g., applications vs. background jobs) to provide higher-level clarity.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Repo("Qovery Terraform Examples (Repository)"):::repository

    subgraph "Terraform Modules"
        direction TB
        DeployCronJob["Deploy a Cron Job Module"]:::module
        DeployLifecycleJob["Deploy a Lifecycle Job Module"]:::module
        DeployCloudflare["Deploy an Application with Cloudflare DNS and CDN Module"]:::module
        Deploy3Environments["Deploy an Application within 3 Environments Module"]:::module
        DeployGitHubAWS["Deploy GitHub App on AWS with HTTPS Module"]:::module
        DeployMedusa["Deploy Medusa with PostgreSQL and Redis on AWS Module"]:::module
        DeployOrderedServices["Deploy Services with a Specific Order Module"]:::module
        DeployStrapi["Deploy Strapi with PostgreSQL on AWS Module"]:::module
    end

    %% Connect Repository to Modules
    Repo --> DeployCronJob
    Repo --> DeployLifecycleJob
    Repo --> DeployCloudflare
    Repo --> Deploy3Environments
    Repo --> DeployGitHubAWS
    Repo --> DeployMedusa
    Repo --> DeployOrderedServices
    Repo --> DeployStrapi

    %% Module subcomponents: main.tf and variables.tf
    DeployCronJob --> DeployCronJob_main["main.tf"]:::tfFile
    DeployCronJob --> DeployCronJob_vars["variables.tf"]:::tfFile

    DeployLifecycleJob --> DeployLifecycleJob_main["main.tf"]:::tfFile
    DeployLifecycleJob --> DeployLifecycleJob_vars["variables.tf"]:::tfFile

    DeployCloudflare --> DeployCloudflare_main["main.tf"]:::tfFile
    DeployCloudflare --> DeployCloudflare_vars["variables.tf"]:::tfFile

    Deploy3Environments --> Deploy3Environments_main["main.tf"]:::tfFile
    Deploy3Environments --> Deploy3Environments_vars["variables.tf"]:::tfFile

    DeployGitHubAWS --> DeployGitHubAWS_main["main.tf"]:::tfFile
    DeployGitHubAWS --> DeployGitHubAWS_vars["variables.tf"]:::tfFile

    DeployMedusa --> DeployMedusa_main["main.tf"]:::tfFile
    DeployMedusa --> DeployMedusa_vars["variables.tf"]:::tfFile

    DeployOrderedServices --> DeployOrderedServices_main["main.tf"]:::tfFile
    DeployOrderedServices --> DeployOrderedServices_vars["variables.tf"]:::tfFile

    DeployStrapi --> DeployStrapi_main["main.tf"]:::tfFile
    DeployStrapi --> DeployStrapi_vars["variables.tf"]:::tfFile

    %% Central Qovery Terraform Provider node
    QoveryProvider["Qovery Terraform Provider"]:::provider

    %% Each module's main.tf provisions through Qovery Provider
    DeployCronJob_main -->|"provisioning"| QoveryProvider
    DeployLifecycleJob_main -->|"provisioning"| QoveryProvider
    DeployCloudflare_main -->|"provisioning"| QoveryProvider
    Deploy3Environments_main -->|"provisioning"| QoveryProvider
    DeployGitHubAWS_main -->|"provisioning"| QoveryProvider
    DeployMedusa_main -->|"provisioning"| QoveryProvider
    DeployOrderedServices_main -->|"provisioning"| QoveryProvider
    DeployStrapi_main -->|"provisioning"| QoveryProvider

    %% External Cloud Service nodes
    AWS["AWS"]:::external
    Cloudflare["Cloudflare"]:::external
    GitHub["GitHub"]:::external
    PostgreSQL["PostgreSQL"]:::external
    Redis["Redis"]:::external

    %% Qovery Provider broadly deploys to external services
    QoveryProvider -->|"deploys"| AWS
    QoveryProvider -->|"deploys"| Cloudflare
    QoveryProvider -->|"deploys"| GitHub
    QoveryProvider -->|"deploys"| PostgreSQL
    QoveryProvider -->|"deploys"| Redis

    %% Module-specific external dependencies (dashed arrows)
    DeployCronJob_main ---|"uses"| AWS
    DeployLifecycleJob_main ---|"uses"| AWS
    DeployCloudflare_main ---|"uses"| Cloudflare
    Deploy3Environments_main ---|"uses"| AWS
    DeployGitHubAWS_main ---|"uses"| AWS
    DeployGitHubAWS_main ---|"uses"| GitHub
    DeployMedusa_main ---|"uses"| AWS
    DeployMedusa_main ---|"uses"| PostgreSQL
    DeployMedusa_main ---|"uses"| Redis
    DeployOrderedServices_main ---|"uses"| AWS
    DeployStrapi_main ---|"uses"| AWS
    DeployStrapi_main ---|"uses"| PostgreSQL

    %% Click Events
    click Repo "https://github.com/htcd-subham/terraform-examples/blob/main/README.md"
    click DeployCronJob "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-a-cron-job"
    click DeployLifecycleJob "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-a-lifecycle-job"
    click DeployCloudflare "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-an-application-with-cloudflare-dns-and-cdn"
    click Deploy3Environments "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-an-application-within-3-environments"
    click DeployGitHubAWS "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-github-app-on-aws-with-https"
    click DeployMedusa "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-medusa-with-postgresql-and-redis-on-aws"
    click DeployOrderedServices "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-services-with-a-specific-order"
    click DeployStrapi "https://github.com/htcd-subham/terraform-examples/tree/main/examples/deploy-strapi-with-postgresql-on-aws"

    %% Styles
    classDef repository fill:#FFD700,stroke:#8B8000,stroke-width:2px;
    classDef module fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef tfFile fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef provider fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
    classDef external fill:#D3D3D3,stroke:#696969,stroke-width:2px;
```
