# akin-genc0/tfpretty architecture

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

- Interactive diagram: https://gitdiagram.com/akin-genc0/tfpretty
- Repository: https://github.com/akin-genc0/tfpretty

## Overview

tfpretty is a terminal viewer for Terraform plans. The principal workflow starts with the user invoking `plan`; the command runs Terraform, parses its JSON output, and starts an interactive UI. The UI summarizes actions, shows attribute-level changes, and can display raw resource data or help. The graph preserves these documented screens and the sampled command, parser, and UI responsibilities. Some rendering details are represented by their exact source paths; unsampled implementation relationships are omitted.

Main entry points: [`cmd/plan.go`](https://github.com/akin-genc0/tfpretty/blob/develop/cmd/plan.go) (Plan command), [`internal/ui/view.go`](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/view.go) (View dispatcher), [`internal/terraform/types.go`](https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/types.go) (Plan data types), [`internal/terraform/runner.go`](https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/runner.go) (Plan runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_command["Command orchestration"]
  node_main["Program entry<br/>[main.go]"]
  node_root["Root command<br/>[root.go]"]
  node_plan_command["Plan command<br/>[plan.go]"]
end

subgraph group_processing["Plan processing"]
  node_runner["Plan runner<br/>[runner.go]"]
  node_plan_file["Temporary plan file"]
  node_parser["JSON parser<br/>[parser.go]"]
  node_plan_data["Plan data types<br/>[types.go]"]
end

subgraph group_interface["Interactive viewer"]
  node_ui_model["UI state and input<br/>[model.go]"]
  node_view_router["View dispatcher<br/>[view.go]"]
  node_plan_view["Plan summary<br/>[plan_view.go]"]
  node_detail_view["Resource details<br/>[detail_view.go]"]
  node_raw_view["Raw resource view<br/>[diff_view.go]"]
  node_help_view["Keyboard help<br/>[help_view.go]"]
  node_styles["UI styles<br/>[styles.go]"]
end

node_user(("User"))
node_terraform_cli["Terraform CLI"]

node_user -->|"runs"| node_main
node_main -->|"executes"| node_root
node_root -->|"registers"| node_plan_command
node_plan_command -->|"runs plan"| node_runner
node_runner -->|"runs commands"| node_terraform_cli
node_runner -->|"writes and removes"| node_plan_file
node_plan_command -->|"parses output"| node_parser
node_parser -->|"populates"| node_plan_data
node_plan_command -->|"initializes"| node_ui_model
node_ui_model -->|"holds plan"| node_plan_data
node_plan_command -->|"starts UI"| node_view_router
node_view_router -->|"renders plan"| node_plan_view
node_view_router -->|"renders details"| node_detail_view
node_view_router -->|"renders raw"| node_raw_view
node_view_router -->|"renders help"| node_help_view
node_plan_view -->|"uses styles"| node_styles
node_detail_view -->|"uses styles"| node_styles
node_raw_view -->|"uses styles"| node_styles
node_plan_view -->|"reads plan"| node_plan_data
node_detail_view -->|"reads changes"| node_plan_data
node_raw_view -->|"serializes resource"| node_plan_data

click node_main "https://github.com/akin-genc0/tfpretty/blob/develop/main.go"
click node_root "https://github.com/akin-genc0/tfpretty/blob/develop/cmd/root.go"
click node_plan_command "https://github.com/akin-genc0/tfpretty/blob/develop/cmd/plan.go"
click node_runner "https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/runner.go"
click node_parser "https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/parser.go"
click node_plan_data "https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/types.go"
click node_ui_model "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/model.go"
click node_view_router "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/view.go"
click node_plan_view "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/plan_view.go"
click node_detail_view "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/detail_view.go"
click node_raw_view "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/diff_view.go"
click node_help_view "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/help_view.go"
click node_styles "https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/styles.go"

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_main,node_root,node_plan_command,node_user toneBlue
class node_runner,node_plan_file,node_parser,node_plan_data toneAmber
class node_ui_model,node_view_router,node_plan_view,node_detail_view,node_raw_view,node_help_view,node_styles toneMint
class node_terraform_cli toneIndigo
```

## Components

### Command orchestration

- [Program entry](https://github.com/akin-genc0/tfpretty/blob/develop/main.go): `main.go`
- [Root command](https://github.com/akin-genc0/tfpretty/blob/develop/cmd/root.go): `cmd/root.go`
- [Plan command](https://github.com/akin-genc0/tfpretty/blob/develop/cmd/plan.go): `cmd/plan.go`

### Plan processing

- [Plan runner](https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/runner.go): `internal/terraform/runner.go`
- **Temporary plan file**
- [JSON parser](https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/parser.go): `internal/terraform/parser.go`
- [Plan data types](https://github.com/akin-genc0/tfpretty/blob/develop/internal/terraform/types.go): `internal/terraform/types.go`

### Interactive viewer

- [UI state and input](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/model.go): `internal/ui/model.go`
- [View dispatcher](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/view.go): `internal/ui/view.go`
- [Plan summary](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/plan_view.go): `internal/ui/plan_view.go`
- [Resource details](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/detail_view.go): `internal/ui/detail_view.go`
- [Raw resource view](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/diff_view.go): `internal/ui/diff_view.go`
- [Keyboard help](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/help_view.go): `internal/ui/help_view.go`
- [UI styles](https://github.com/akin-genc0/tfpretty/blob/develop/internal/ui/styles.go): `internal/ui/styles.go`

### Other components

- **User**
- **Terraform CLI**

## Connections

- User → Program entry: runs (evidence: `README.md`)
- Program entry → Root command: executes (evidence: `main.go`)
- Root command → Plan command: registers (evidence: `cmd/plan.go`)
- Plan command → Plan runner: runs plan (evidence: `cmd/plan.go`)
- Plan runner → Terraform CLI: runs commands (evidence: `internal/terraform/runner.go`)
- Plan runner → Temporary plan file: writes and removes (evidence: `internal/terraform/runner.go`)
- Plan command → JSON parser: parses output (evidence: `cmd/plan.go`)
- JSON parser → Plan data types: populates (evidence: `internal/terraform/parser.go`)
- Plan command → UI state and input: initializes (evidence: `cmd/plan.go`)
- UI state and input → Plan data types: holds plan (evidence: `internal/ui/model.go`)
- Plan command → View dispatcher: starts UI (evidence: `cmd/plan.go`)
- View dispatcher → Plan summary: renders plan (evidence: `internal/ui/view.go`)
- View dispatcher → Resource details: renders details (evidence: `internal/ui/view.go`)
- View dispatcher → Raw resource view: renders raw (evidence: `internal/ui/view.go`)
- View dispatcher → Keyboard help: renders help (evidence: `internal/ui/view.go`)
- Plan summary → UI styles: uses styles (evidence: `internal/ui/plan_view.go`)
- Resource details → UI styles: uses styles (evidence: `internal/ui/detail_view.go`)
- Raw resource view → UI styles: uses styles (evidence: `internal/ui/diff_view.go`)
- Plan summary → Plan data types: reads plan (evidence: `internal/ui/plan_view.go`)
- Resource details → Plan data types: reads changes (evidence: `internal/ui/detail_view.go`)
- Raw resource view → Plan data types: serializes resource (evidence: `internal/ui/diff_view.go`)
