# rohith-racharla/terrasync architecture

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

- Interactive diagram: https://gitdiagram.com/rohith-racharla/terrasync
- Repository: https://github.com/rohith-racharla/terrasync

## Overview

Terrasync is a Terraform drift-detection and human-approved remediation system, with Terraform-managed AWS infrastructure for dev, staging, and prod. Its main workflow discovers environments, plans them in parallel, reports detected drift, then runs a gated remediation and post-check. The repository also documents PR planning, security scanning, and cost estimation. Relationships below are based on README statements; no source excerpts were available to verify implementation details.

Main entry points: [`terraform/environments/dev/main.tf`](https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/dev/main.tf) (Dev Environment), [`terraform/environments/staging/main.tf`](https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/staging/main.tf) (Staging Environment), [`terraform/environments/prod/main.tf`](https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/prod/main.tf) (Prod Environment), [`.github/workflows/drift-detection.yml`](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml) (Parallel Drift Plans)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operations["Drift Operations"]
  node_discovery["Environment Discovery"]
  node_scan["Parallel Drift Plans"]
  node_notify["Drift Notifications"]
  node_approval["Human Approval"]
  node_safety["Safety Gate"]
  node_preflight["Preflight Plan"]
  node_remediation["Apply or Refresh"]
  node_postcheck["Post-Remediation Check"]
  node_audit["Audit and Issue Closure"]
end

subgraph group_checks["Pull Request Checks"]
  node_prchecks["Selective PR Plans"]
  node_security["Security Scanning"]
  node_cost["Cost Estimation"]
end

subgraph group_infrastructure["Terraform Infrastructure"]
  node_bootstrap["State and OIDC Bootstrap<br/>[main.tf]"]
  node_dev["Dev Environment<br/>[main.tf]"]
  node_staging["Staging Environment<br/>[main.tf]"]
  node_prod["Prod Environment<br/>[main.tf]"]
  node_eks["EKS Module<br/>[main.tf]"]
  node_vpc["VPC Module<br/>[main.tf]"]
  node_iam["IAM Module<br/>[main.tf]"]
  node_ecr["ECR Module<br/>[main.tf]"]
end

subgraph group_services["External Services"]
  node_aws["AWS"]
  node_state[("S3 State and Locking")]
  node_github["GitHub"]
  node_slack["Slack"]
end

node_schedule(("Schedule or Dispatch"))
node_pullrequest(("Pull Request"))

node_schedule -->|"triggers"| node_discovery
node_discovery -->|"selects environments"| node_scan
node_scan -->|"plans"| node_dev
node_scan -->|"plans"| node_staging
node_scan -->|"plans"| node_prod
node_scan -->|"reports drift"| node_notify
node_notify -->|"opens issue"| node_github
node_notify -->|"sends message"| node_slack
node_github -->|"initiates remediation"| node_approval
node_approval -->|"requires confirmation"| node_safety
node_safety -->|"permits run"| node_preflight
node_preflight -->|"gates action"| node_remediation
node_remediation -->|"reruns drift check"| node_postcheck
node_postcheck -->|"records result"| node_audit
node_audit -->|"closes issue"| node_github
node_pullrequest -->|"triggers"| node_prchecks
node_prchecks -->|"plans changed environments"| node_dev
node_prchecks -->|"plans changed environments"| node_staging
node_prchecks -->|"plans changed environments"| node_prod
node_prchecks -->|"runs scans"| node_security
node_security -->|"posts results"| node_pullrequest
node_prchecks -->|"estimates costs"| node_cost
node_cost -->|"posts estimates"| node_pullrequest
node_dev -->|"deploys"| node_eks
node_dev -->|"deploys"| node_vpc
node_dev -->|"deploys"| node_iam
node_dev -->|"deploys"| node_ecr
node_staging -->|"deploys"| node_eks
node_staging -->|"deploys"| node_vpc
node_staging -->|"deploys"| node_iam
node_staging -->|"deploys"| node_ecr
node_prod -->|"deploys"| node_eks
node_prod -->|"deploys"| node_vpc
node_prod -->|"deploys"| node_iam
node_prod -->|"deploys"| node_ecr
node_bootstrap -->|"creates remote state"| node_state
node_bootstrap -->|"configures OIDC"| node_aws
node_scan -->|"uses federated identity"| node_aws
node_remediation -->|"uses federated identity"| node_aws
node_dev -->|"stores state"| node_state
node_staging -->|"stores state"| node_state
node_prod -->|"stores state"| node_state

click node_discovery "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml"
click node_scan "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml"
click node_notify "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml"
click node_approval "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml"
click node_safety "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml"
click node_preflight "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml"
click node_remediation "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml"
click node_postcheck "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml"
click node_audit "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml"
click node_prchecks "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/terraform-pr-check.yml"
click node_security "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/terraform-pr-check.yml"
click node_cost "https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/terraform-pr-check.yml"
click node_bootstrap "https://github.com/rohith-racharla/terrasync/blob/main/terraform/bootstrap/main.tf"
click node_dev "https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/dev/main.tf"
click node_staging "https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/staging/main.tf"
click node_prod "https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/prod/main.tf"
click node_eks "https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/eks/main.tf"
click node_vpc "https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/vpc/main.tf"
click node_iam "https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/iam/main.tf"
click node_ecr "https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/ecr/main.tf"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_discovery,node_scan,node_notify,node_approval,node_safety,node_preflight,node_remediation,node_postcheck,node_audit toneBlue
class node_prchecks,node_security,node_cost toneAmber
class node_bootstrap,node_dev,node_staging,node_prod,node_eks,node_vpc,node_iam,node_ecr,node_pullrequest toneMint
class node_aws,node_state,node_github,node_slack toneRose
class node_schedule toneIndigo
```

## Components

### Drift Operations

- [Environment Discovery](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml): `.github/workflows/drift-detection.yml`
- [Parallel Drift Plans](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml): `.github/workflows/drift-detection.yml`
- [Drift Notifications](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-detection.yml): `.github/workflows/drift-detection.yml`
- [Human Approval](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml): `.github/workflows/drift-remediation.yaml`
- [Safety Gate](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml): `.github/workflows/drift-remediation.yaml`
- [Preflight Plan](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml): `.github/workflows/drift-remediation.yaml`
- [Apply or Refresh](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml): `.github/workflows/drift-remediation.yaml`
- [Post-Remediation Check](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml): `.github/workflows/drift-remediation.yaml`
- [Audit and Issue Closure](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/drift-remediation.yaml): `.github/workflows/drift-remediation.yaml`

### Pull Request Checks

- [Selective PR Plans](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/terraform-pr-check.yml): `.github/workflows/terraform-pr-check.yml`
- [Security Scanning](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/terraform-pr-check.yml): `.github/workflows/terraform-pr-check.yml`
- [Cost Estimation](https://github.com/rohith-racharla/terrasync/blob/main/.github/workflows/terraform-pr-check.yml): `.github/workflows/terraform-pr-check.yml`

### Terraform Infrastructure

- [State and OIDC Bootstrap](https://github.com/rohith-racharla/terrasync/blob/main/terraform/bootstrap/main.tf): `terraform/bootstrap/main.tf`
- [Dev Environment](https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/dev/main.tf): `terraform/environments/dev/main.tf`
- [Staging Environment](https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/staging/main.tf): `terraform/environments/staging/main.tf`
- [Prod Environment](https://github.com/rohith-racharla/terrasync/blob/main/terraform/environments/prod/main.tf): `terraform/environments/prod/main.tf`
- [EKS Module](https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/eks/main.tf): `terraform/modules/eks/main.tf`
- [VPC Module](https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/vpc/main.tf): `terraform/modules/vpc/main.tf`
- [IAM Module](https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/iam/main.tf): `terraform/modules/iam/main.tf`
- [ECR Module](https://github.com/rohith-racharla/terrasync/blob/main/terraform/modules/ecr/main.tf): `terraform/modules/ecr/main.tf`

### External Services

- **AWS**
- **S3 State and Locking**
- **GitHub**
- **Slack**

### Other components

- **Schedule or Dispatch**
- **Pull Request**

## Connections

- Schedule or Dispatch → Environment Discovery: triggers (evidence: `README.md`)
- Environment Discovery → Parallel Drift Plans: selects environments (evidence: `README.md`)
- Parallel Drift Plans → Dev Environment: plans (evidence: `README.md`)
- Parallel Drift Plans → Staging Environment: plans (evidence: `README.md`)
- Parallel Drift Plans → Prod Environment: plans (evidence: `README.md`)
- Parallel Drift Plans → Drift Notifications: reports drift (evidence: `README.md`)
- Drift Notifications → GitHub: opens issue (evidence: `README.md`)
- Drift Notifications → Slack: sends message (evidence: `README.md`)
- GitHub → Human Approval: initiates remediation (evidence: `README.md`)
- Human Approval → Safety Gate: requires confirmation (evidence: `README.md`)
- Safety Gate → Preflight Plan: permits run (evidence: `README.md`)
- Preflight Plan → Apply or Refresh: gates action (evidence: `README.md`)
- Apply or Refresh → Post-Remediation Check: reruns drift check (evidence: `README.md`)
- Post-Remediation Check → Audit and Issue Closure: records result (evidence: `README.md`)
- Audit and Issue Closure → GitHub: closes issue (evidence: `README.md`)
- Pull Request → Selective PR Plans: triggers (evidence: `README.md`)
- Selective PR Plans → Dev Environment: plans changed environments (evidence: `README.md`)
- Selective PR Plans → Staging Environment: plans changed environments (evidence: `README.md`)
- Selective PR Plans → Prod Environment: plans changed environments (evidence: `README.md`)
- Selective PR Plans → Security Scanning: runs scans (evidence: `README.md`)
- Security Scanning → Pull Request: posts results (evidence: `README.md`)
- Selective PR Plans → Cost Estimation: estimates costs (evidence: `README.md`)
- Cost Estimation → Pull Request: posts estimates (evidence: `README.md`)
- Dev Environment → EKS Module: deploys (evidence: `README.md`)
- Dev Environment → VPC Module: deploys (evidence: `README.md`)
- Dev Environment → IAM Module: deploys (evidence: `README.md`)
- Dev Environment → ECR Module: deploys (evidence: `README.md`)
- Staging Environment → EKS Module: deploys (evidence: `README.md`)
- Staging Environment → VPC Module: deploys (evidence: `README.md`)
- Staging Environment → IAM Module: deploys (evidence: `README.md`)
- Staging Environment → ECR Module: deploys (evidence: `README.md`)
- Prod Environment → EKS Module: deploys (evidence: `README.md`)
- Prod Environment → VPC Module: deploys (evidence: `README.md`)
- Prod Environment → IAM Module: deploys (evidence: `README.md`)
- Prod Environment → ECR Module: deploys (evidence: `README.md`)
- State and OIDC Bootstrap → S3 State and Locking: creates remote state (evidence: `README.md`)
- State and OIDC Bootstrap → AWS: configures OIDC (evidence: `README.md`)
- Parallel Drift Plans → AWS: uses federated identity (evidence: `README.md`)
- Apply or Refresh → AWS: uses federated identity (evidence: `README.md`)
- Dev Environment → S3 State and Locking: stores state (evidence: `README.md`)
- Staging Environment → S3 State and Locking: stores state (evidence: `README.md`)
- Prod Environment → S3 State and Locking: stores state (evidence: `README.md`)
