# foadtalsi/tf-predeploy-firewall architecture

> Architecture diagram of the GitHub repository foadtalsi/tf-predeploy-firewall, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/foadtalsi/tf-predeploy-firewall
- Repository: https://github.com/foadtalsi/tf-predeploy-firewall

## Overview

TF Pre-Deploy Firewall is a local-first Terraform change scanner. Its workflow is CLI selection of repository changes, HCL parsing and rule evaluation (optionally informed by provider schemas, plan JSON, and AWS reads), then findings, threshold verdict, and rendered or code-host-published reports. The graph preserves documented checks and integrations even where their implementation was not sampled; those branches are shown only where README or indexed references support the relationship.

Main entry points: [`src/tfpdf/cli/pipeline.py`](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/pipeline.py) (Scan pipeline), [`src/tfpdf/cli/forges.py`](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/forges.py) (Forge publishing), [`src/tfpdf/rules/engine.py`](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/rules/engine.py) (Rule engine), [`src/tfpdf/licensing/client.py`](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/licensing/client.py) (Hosted licensing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Scan orchestration"]
  node_cli["CLI entry<br/>[main.py]"]
  node_pipeline["Scan pipeline<br/>[pipeline.py]"]
  node_forgepublish["Forge publishing<br/>[forges.py]"]
end

subgraph group_parse["Terraform inputs"]
  node_gitdiff["Git changes<br/>[git.py]"]
  node_localdiff["Local changes<br/>[local.py]"]
  node_hclparser["HCL parser<br/>[parser.py]"]
  node_hclast["HCL AST and evaluation<br/>[ast.py]"]
  node_terraformparser["Terraform model<br/>[hcl.py]"]
  node_terragrunt["Terragrunt inputs<br/>[terragrunt.py]"]
  node_tfvars["Variable inputs<br/>[tfvars.py]"]
  node_plan["Plan JSON<br/>[planjson.py]"]
end

subgraph group_analysis["Rules and knowledge"]
  node_engine["Rule engine<br/>[engine.py]"]
  node_changedattrs["Change risks<br/>[changedattrs.py]"]
  node_rulepacks["Rule packs<br/>[rules.py]"]
  node_schema["Provider schemas<br/>[loader.py]"]
end

subgraph group_outputs["Findings and reports"]
  node_findings["Findings<br/>[finding.py]"]
  node_reporting["Report renderers<br/>[markdown.py]"]
  node_sarif["SARIF output<br/>[sarif.py]"]
  node_review["Review suggestions<br/>[review.py]"]
  node_baseline[("Accepted risks<br/>[baseline.py]")]
end

subgraph group_integrations["External services"]
  node_awsread["AWS read checks<br/>[cloudread.py]"]
  node_license["Hosted licensing<br/>[client.py]"]
  node_httpjson["HTTP JSON client<br/>[_httpjson.py]"]
  node_forge(("GitHub / GitLab"))
end

node_user(("Engineer / CI"))
node_aws(("AWS"))
node_cloudservice(("Hosted service"))

node_user -->|"starts scan"| node_cli
node_cli -->|"runs scan"| node_pipeline
node_pipeline -->|"selects changes"| node_gitdiff
node_pipeline -.->|"selects changes"| node_localdiff
node_pipeline -->|"scans Terraform"| node_terraformparser
node_pipeline -.->|"checks files"| node_terragrunt
node_pipeline -.->|"checks variables"| node_tfvars
node_pipeline -->|"loads plan"| node_plan
node_terraformparser -->|"parses HCL"| node_hclparser
node_hclparser -->|"builds AST"| node_hclast
node_pipeline -->|"loads rules"| node_rulepacks
node_pipeline -->|"loads schemas"| node_schema
node_pipeline -->|"runs analysis"| node_engine
node_engine -->|"checks changes"| node_changedattrs
node_engine -->|"emits findings"| node_findings
node_pipeline -->|"collects results"| node_findings
node_pipeline -->|"filters accepted"| node_baseline
node_pipeline -->|"checks cloud state"| node_awsread
node_awsread -.->|"reads resources"| node_aws
node_pipeline -.->|"requests features"| node_license
node_license -->|"uses client"| node_httpjson
node_license -.->|"calls hosted API"| node_cloudservice
node_pipeline -->|"renders report"| node_reporting
node_pipeline -.->|"renders SARIF"| node_sarif
node_reporting -.->|"formats findings"| node_findings
node_pipeline -->|"publishes results"| node_forgepublish
node_forgepublish -->|"renders suggestions"| node_review
node_forgepublish -.->|"posts comments"| node_forge

click node_cli "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/main.py"
click node_pipeline "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/pipeline.py"
click node_forgepublish "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/forges.py"
click node_gitdiff "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/diff/git.py"
click node_localdiff "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/diff/local.py"
click node_hclparser "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/hcl/parser.py"
click node_hclast "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/hcl/ast.py"
click node_terraformparser "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/parser/hcl.py"
click node_terragrunt "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/terragrunt.py"
click node_tfvars "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/tfvars.py"
click node_plan "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/planjson.py"
click node_engine "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/rules/engine.py"
click node_changedattrs "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/rules/changedattrs.py"
click node_rulepacks "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/ruledef/rules.py"
click node_schema "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/schema/loader.py"
click node_findings "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/finding.py"
click node_reporting "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/markdown.py"
click node_sarif "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/sarif.py"
click node_review "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/review.py"
click node_baseline "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/baseline.py"
click node_awsread "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cloudread.py"
click node_license "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/licensing/client.py"
click node_httpjson "https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/_httpjson.py"

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_cli,node_pipeline,node_forgepublish toneBlue
class node_gitdiff,node_localdiff,node_hclparser,node_hclast,node_terraformparser,node_terragrunt,node_tfvars,node_plan toneAmber
class node_engine,node_changedattrs,node_rulepacks,node_schema toneMint
class node_findings,node_reporting,node_sarif,node_review,node_baseline toneRose
class node_awsread,node_license,node_httpjson,node_forge,node_user,node_aws,node_cloudservice toneIndigo
```

## Components

### Scan orchestration

- [CLI entry](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/main.py): `src/tfpdf/cli/main.py`
- [Scan pipeline](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/pipeline.py): `src/tfpdf/cli/pipeline.py`
- [Forge publishing](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cli/forges.py): `src/tfpdf/cli/forges.py`

### Terraform inputs

- [Git changes](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/diff/git.py): `src/tfpdf/diff/git.py`
- [Local changes](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/diff/local.py): `src/tfpdf/diff/local.py`
- [HCL parser](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/hcl/parser.py): `src/tfpdf/hcl/parser.py`
- [HCL AST and evaluation](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/hcl/ast.py): `src/tfpdf/hcl/ast.py`
- [Terraform model](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/parser/hcl.py): `src/tfpdf/parser/hcl.py`
- [Terragrunt inputs](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/terragrunt.py): `src/tfpdf/terragrunt.py`
- [Variable inputs](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/tfvars.py): `src/tfpdf/tfvars.py`
- [Plan JSON](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/planjson.py): `src/tfpdf/planjson.py`

### Rules and knowledge

- [Rule engine](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/rules/engine.py): `src/tfpdf/rules/engine.py`
- [Change risks](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/rules/changedattrs.py): `src/tfpdf/rules/changedattrs.py`
- [Rule packs](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/ruledef/rules.py): `src/tfpdf/ruledef/rules.py`
- [Provider schemas](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/schema/loader.py): `src/tfpdf/schema/loader.py`

### Findings and reports

- [Findings](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/finding.py): `src/tfpdf/report/finding.py`
- [Report renderers](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/markdown.py): `src/tfpdf/report/markdown.py`
- [SARIF output](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/sarif.py): `src/tfpdf/report/sarif.py`
- [Review suggestions](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/report/review.py): `src/tfpdf/report/review.py`
- [Accepted risks](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/baseline.py): `src/tfpdf/baseline.py`

### External services

- [AWS read checks](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/cloudread.py): `src/tfpdf/cloudread.py`
- [Hosted licensing](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/licensing/client.py): `src/tfpdf/licensing/client.py`
- [HTTP JSON client](https://github.com/foadtalsi/tf-predeploy-firewall/blob/main/src/tfpdf/_httpjson.py): `src/tfpdf/_httpjson.py`
- **GitHub / GitLab**

### Other components

- **Engineer / CI**
- **AWS**
- **Hosted service**

## Connections

- Engineer / CI → CLI entry: starts scan (evidence: `README.md`)
- CLI entry → Scan pipeline: runs scan (evidence: `src/tfpdf/cli/main.py`)
- Scan pipeline → Git changes: selects changes (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → Local changes: selects changes (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → Terraform model: scans Terraform (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → Terragrunt inputs: checks files (evidence: `README.md`)
- Scan pipeline → Variable inputs: checks variables (evidence: `README.md`)
- Scan pipeline → Plan JSON: loads plan (evidence: `src/tfpdf/cli/pipeline.py`)
- Terraform model → HCL parser: parses HCL (evidence: `src/tfpdf/parser/hcl.py`)
- HCL parser → HCL AST and evaluation: builds AST (evidence: `src/tfpdf/hcl/parser.py`)
- Scan pipeline → Rule packs: loads rules (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → Provider schemas: loads schemas (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → Rule engine: runs analysis (evidence: `src/tfpdf/cli/pipeline.py`)
- Rule engine → Change risks: checks changes (evidence: `src/tfpdf/rules/engine.py`)
- Rule engine → Findings: emits findings (evidence: `src/tfpdf/rules/engine.py`)
- Scan pipeline → Findings: collects results (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → Accepted risks: filters accepted (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → AWS read checks: checks cloud state (evidence: `src/tfpdf/cli/pipeline.py`)
- AWS read checks → AWS: reads resources (evidence: `README.md`)
- Scan pipeline → Hosted licensing: requests features (evidence: `src/tfpdf/cli/pipeline.py`)
- Hosted licensing → HTTP JSON client: uses client (evidence: `src/tfpdf/licensing/client.py`)
- Hosted licensing → Hosted service: calls hosted API (evidence: `README.md`)
- Scan pipeline → Report renderers: renders report (evidence: `src/tfpdf/cli/pipeline.py`)
- Scan pipeline → SARIF output: renders SARIF (evidence: `README.md`)
- Report renderers → Findings: formats findings (evidence: `src/tfpdf/report/__init__.py`)
- Scan pipeline → Forge publishing: publishes results (evidence: `src/tfpdf/cli/pipeline.py`)
- Forge publishing → Review suggestions: renders suggestions (evidence: `src/tfpdf/cli/forges.py`)
- Forge publishing → GitHub / GitLab: posts comments (evidence: `README.md`)
