# zopdev/opentofu-modules architecture

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

- Interactive diagram: https://gitdiagram.com/zopdev/opentofu-modules
- Repository: https://github.com/zopdev/opentofu-modules

## Overview

##### Main Components
- Core Terraform Module Repository: Encompasses all configuration modules.
- Modules by Functionality:
- Account-Setup: Sets up prerequisites such as VPCs, subnets, and related network resources needed for Kubernetes cluster creation.
- Artifact: Manages artifacts necessary for cloud deployments.
- Bash-Codes: Contains scripts to establish hosted zones, manage remote state, and automate secret management.
- Cassandra (WIP): Provisioning for deploying Cassandra clusters.
- GitHub: Automates the management (repos, teams, secrets) on GitHub.
- Kubernetes (k8s): The central module for configuring Kubernetes clusters across AWS, GCP, and Azure. This module includes sub-modules for specific cloud provider setups (e.g., EKS on AWS, AKS on Azure, and GKE on GCP) and related namespace, ingress, and network/security configurations.
- Kafka: Sets up Kafka clusters for AWS and Azure.
- Observability: Implements observability tools (Loki, Tempo, Cortex) using configurations per cloud provider.
- Redis: Manages redis clusters for caching on AWS (ElastiCache), Azure, and GCP as well as local testing.
- SQL: Provisions databases (MySQL, PostgreSQL) with templates and configurations for each cloud provider.
- Additional modules such as “zop-helm” and “zop-system” extend the deployment to further helm and system-level resource management.
- Cloud Provider Abstraction: Almost every module is subdivided into provider-specific configurations (aws, azure, gcp), reflecting the project's multi-account, multi-cloud approach.

##### Relationships and Interactions
- The “Account-Setup” module is a foundational component on which other modules depend. For example, before provisioning a Kubernetes cluster (k8s) or a SQL database, the necessary cloud network and VPC configurations must be in place.
- “Bash-Codes” and “Remote-State” modules support configuration management, secret handling, and remote state management across many other modules.
- The “GitHub” module handles integration with version control and automates team/repo creation, usually a supporting but standalone component.
- “Artifact”, “Kafka”, “Observability”, “Redis”, and “SQL” modules work independently to provision infrastructure, but they often serve as underlying services for larger deployments (like Kubernetes workloads).

##### Architectural Patterns and Design Principles
- Modular Design: Each functional area (e.g., network setup, compute, storage) is encapsulated in its own module following Terraform best practices.
- Provider-Specific Abstraction: Each module typically subdivides into aws, azure, and gcp directories to isolate provider-specific configuration.
- Reusability and Extensibility: The modules include default configurations (var.tf, versions.tf) and templates for extending functionalities (e.g., helm charts and templated resources).
- Integration & Automation: Integrated secret management and automated remote state set-ups emphasize a “no human secrets” approach and continuous delivery.

##### Relevant Technologies and Frameworks
- Terraform and its modules/layout (main.tf, variables, outputs, versions).
- Shell scripting (in bash-codes) for provisioning supporting automation tools.
- Cloud-specific services (AWS EKS/MSK, Azure AKS, GCP GKE, etc.) as indicated by the file structure.
- Kubernetes configurations (various k8s submodules for clusters, namespaces, nginx, etc.) with helm templating.

##### Final Recommendations
- Multi-cloud strategy by clearly showing the branches for each cloud provider.

Happy Diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    Core["Core Terraform Module Repository"]:::core

    subgraph "Foundational Modules"
        ASetup["Account-Setup"]:::module
        Bash["Bash-Codes"]:::support
        Remote["Remote-State"]:::support
        Hosted["Hosted Zones"]:::support
    end

    subgraph "Infrastructure Modules"
        Artifact["Artifact"]:::module
        K8s["Kubernetes (k8s)"]:::module
        Kafka["Kafka"]:::module
        Observ["Observability"]:::module
        Redis["Redis"]:::module
        SQL["SQL"]:::module
        Cassandra["Cassandra (WIP)"]:::module
    end

    subgraph "Extensions"
        ZHelm["zop-helm"]:::additional
        ZSystem["zop-system"]:::additional
    end

    Git["GitHub"]:::support

    %% Connections from Core Repository to modules
    Core --> ASetup
    Core --> Bash
    Core --> Remote
    Core --> Hosted
    Core --> Artifact
    Core --> K8s
    Core --> Kafka
    Core --> Observ
    Core --> Redis
    Core --> SQL
    Core --> Cassandra
    Core --> Git

    %% Dependency Relationships
    ASetup -->|"depends_on"| K8s
    ASetup -->|"depends_on"| SQL
    ASetup -->|"depends_on"| Redis

    Bash --> Remote
    Bash --> Hosted

    Remote -->|"supports"| K8s
    Remote -->|"supports"| SQL

    Observ -->|"monitors"| K8s

    K8s --> ZHelm
    K8s --> ZSystem

    %% Click Events
    click Core "https://github.com/zopdev/opentofu-modules/blob/main/Project Root and README.md"
    click ASetup "https://github.com/zopdev/opentofu-modules/tree/main/account-setup/"
    click Bash "https://github.com/zopdev/opentofu-modules/tree/main/bash-codes/"
    click Remote "https://github.com/zopdev/opentofu-modules/tree/main/remote-state/"
    click Hosted "https://github.com/zopdev/opentofu-modules/tree/main/hosted-zones/"
    click Artifact "https://github.com/zopdev/opentofu-modules/tree/main/artifact/"
    click K8s "https://github.com/zopdev/opentofu-modules/tree/main/k8s/"
    click Kafka "https://github.com/zopdev/opentofu-modules/tree/main/kafka/"
    click Observ "https://github.com/zopdev/opentofu-modules/tree/main/observability/"
    click Redis "https://github.com/zopdev/opentofu-modules/tree/main/redis/"
    click SQL "https://github.com/zopdev/opentofu-modules/tree/main/sql/"
    click Cassandra "https://github.com/zopdev/opentofu-modules/tree/main/cassandra/"
    click Git "https://github.com/zopdev/opentofu-modules/tree/main/github/"
    click ZHelm "https://github.com/zopdev/opentofu-modules/tree/main/zop-helm/"
    click ZSystem "https://github.com/zopdev/opentofu-modules/tree/main/zop-system/"

    %% Styles
    classDef core fill:#f4cccc,stroke:#c27ba0,stroke-width:2px;
    classDef module fill:#c9daf8,stroke:#6d9eeb,stroke-width:2px;
    classDef support fill:#d9ead3,stroke:#6aa84f,stroke-width:2px;
    classDef additional fill:#ead1dc,stroke:#e06666,stroke-width:2px;
```
