# anasssebai/infra architecture

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

- Interactive diagram: https://gitdiagram.com/anasssebai/infra
- Repository: https://github.com/anasssebai/infra

## Overview

##### Project type and purpose
- This is an “Infrastructure as Code” project written in Terraform.
- The goal is to define and provision cloud resources declaratively, using .tf files, environment-specific variables, and a remote state backend.

##### File structure
- Top-level Terraform configuration files:
- main.tf (resource definitions)
- providers.tf (cloud provider declarations)
- versions.tf (Terraform required version and provider versions)
- variables.tf (input variable definitions)
- outputs.tf (exported outputs)
- locals.tf (computed values)
- backend.tf (remote state configuration)
- env/ directory with dev.tfvars and prod.tfvars for environment-specific inputs
- .terraform.lock.hcl for provider dependency locking

##### README
- Confirms this is a first Terraform infra project (“INFRA – first project Terraform”)

a. Main components
1. Developer Workstation (Terraform CLI)
2. Source Control (Git repository)
3. Remote State Backend (e.g., S3 bucket + DynamoDB lock)
4. Terraform Configuration Modules (main.tf, variables.tf, etc.)
5. Environment Variable Files (env/dev.tfvars, env/prod.tfvars)
6. Cloud Provider APIs (e.g., AWS)
7. Managed Cloud Resources (VPC, EC2, RDS, etc.)
b. Relationships and interactions
- Developer invokes Terraform CLI on local machine →
reads .tf files + .tfvars →
loads providers →
plans/apply to Cloud APIs →
provisions resources.
- Terraform CLI writes state to the remote backend →
locks via DynamoDB to prevent concurrent updates.
- Separate flows for dev and prod by selecting the corresponding .tfvars file.
c. Architectural patterns/design principles
- Declarative IaC: source of truth in version control.
- Remote state locking for safe concurrent operations.
- Environment-based parameterization.
- Separation of concerns between configuration (resources), variables, and state.
d. Relevant technologies/frameworks
- Terraform (CLI, modules)
- Git (version control)
- AWS S3 & DynamoDB (remote state + locks) – adjust to your actual backend
- AWS provider plugin

##### Diagramming recommendations
- Configuration flow (CLI → Provider API)
- State flow (CLI ↔ Remote Backend)
- Blue rectangles for on-prem/local developer tools

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "Local Dev Environment"
    TerraformCLI["Terraform CLI"]:::local
    subgraph "Git Repository"
      GitIgnore[".gitignore"]:::files
      Readme["README.md"]:::files
    end
    subgraph "Terraform Configuration"
      Main["main.tf"]:::files
      Providers["providers.tf"]:::files
      Versions["versions.tf"]:::files
      Variables["variables.tf"]:::files
      Locals["locals.tf"]:::files
      Outputs["outputs.tf"]:::files
      BackendCfg["backend.tf"]:::files
      Lockfile[".terraform.lock.hcl"]:::files
    end
    subgraph "Environment Variable Files"
      DevTF["env/dev.tfvars"]:::files
      ProdTF["env/prod.tfvars"]:::files
    end
  end

  subgraph "Remote State Backend"
    S3["S3 Bucket"]:::state
    DynamoDB["DynamoDB Table"]:::state
  end

  AWSAPI["AWS Provider API"]:::cloud

  subgraph "Managed Infrastructure"
    VPC["VPC"]:::resources
    EC2["EC2 Instances"]:::resources
    RDS["RDS Database"]:::resources
  end

  TerraformCLI -->|reads config| Main
  TerraformCLI -->|reads config| Providers
  TerraformCLI -->|reads config| Versions
  TerraformCLI -->|reads config| Variables
  TerraformCLI -->|reads config| Locals
  TerraformCLI -->|reads config| Outputs
  TerraformCLI -->|reads config| BackendCfg
  TerraformCLI -->|reads lockfile| Lockfile

  TerraformCLI -->|reads tfvars| DevTF
  TerraformCLI -->|reads tfvars| ProdTF

  TerraformCLI -->|state read/write| S3
  TerraformCLI -->|lock/unlock| DynamoDB

  TerraformCLI -->|plan/apply| AWSAPI

  AWSAPI -->|provision| VPC
  AWSAPI -->|provision| EC2
  AWSAPI -->|provision| RDS

  click TerraformCLI "https://github.com/anasssebai/infra/tree/main//"
  click GitIgnore "https://github.com/anasssebai/infra/blob/main/.gitignore"
  click Readme "https://github.com/anasssebai/infra/blob/main/README.md"
  click BackendCfg "https://github.com/anasssebai/infra/blob/main/backend.tf"
  click Providers "https://github.com/anasssebai/infra/blob/main/providers.tf"
  click Main "https://github.com/anasssebai/infra/blob/main/main.tf"
  click Variables "https://github.com/anasssebai/infra/blob/main/variables.tf"
  click Locals "https://github.com/anasssebai/infra/blob/main/locals.tf"
  click Outputs "https://github.com/anasssebai/infra/blob/main/outputs.tf"
  click Versions "https://github.com/anasssebai/infra/blob/main/versions.tf"
  click DevTF "https://github.com/anasssebai/infra/blob/main/env/dev.tfvars"
  click ProdTF "https://github.com/anasssebai/infra/blob/main/env/prod.tfvars"
  click Lockfile "https://github.com/anasssebai/infra/blob/main/.terraform.lock.hcl"

  classDef local fill:#D6E9F8,stroke:#2B7CE9;
  classDef state fill:#DFF5E8,stroke:#2C9E4B;
  classDef cloud fill:#FDEBD0,stroke:#E67E22;
  classDef resources fill:#ECECEC,stroke:#AAAAAA;
  classDef files fill:#F0F0F0,stroke:#CCCCCC;
```
