# wagoodman/dive architecture

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

- Interactive diagram: https://gitdiagram.com/wagoodman/dive
- Repository: https://github.com/wagoodman/dive

## Overview

Dive is a CLI for inspecting Docker/OCI images, exploring layer contents and estimating wasted space. The main path resolves an image from a selected source, analyzes its layers, then presents the result in an interactive terminal UI or emits JSON / a CI pass-fail evaluation. A separate build command supports build-then-analyze workflows. The graph includes the documented source and analysis capabilities; several provider and view details are unsampled, so links without direct excerpt or index evidence are omitted.

Main entry points: [`cmd/dive/cli/internal/command/run.go`](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/run.go) (CLI commands), [`cmd/dive/cli/internal/ui/tui/app/app.go`](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/app/app.go) (Interactive TUI), [`internal/source/source.go`](https://github.com/wagoodman/dive/blob/main/internal/source/source.go) (Image sources), [`dive/analysis.go`](https://github.com/wagoodman/dive/blob/main/dive/analysis.go) (Layer analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI workflows"]
  node_cli["CLI commands<br/>[run.go]"]
  node_build["Build command<br/>[build.go]"]
  node_eventbus["Event bus<br/>[bus.go]"]
end

subgraph group_image["Image analysis"]
  node_sources["Image sources<br/>[source.go]"]
  node_engines["Image engines"]
  node_analysis["Layer analysis<br/>[analysis.go]"]
  node_layerdata["Layer trees<br/>[layertree.go]"]
end

subgraph group_terminal["Terminal exploration"]
  node_progress["Progress UI<br/>[progress_ui.go]"]
  node_handler["Image event handler<br/>[handler.go]"]
  node_tui["Interactive TUI<br/>[app.go]"]
  node_controller["View controller<br/>[controller.go]"]
  node_layer_views["Layer views<br/>[layer.go]"]
  node_filetree_view["File tree view<br/>[filetree.go]"]
  node_filetree_model["File tree model<br/>[filetree.go]"]
  node_filetree_data["File tree data<br/>[file_tree.go]"]
  node_layout["Terminal layout<br/>[manager.go]"]
end

subgraph group_outputs["Automation outputs"]
  node_ci["CI evaluation<br/>[evaluator.go]"]
  node_json["JSON export<br/>[export.go]"]
end

node_user(("CLI user"))

node_user -->|"invokes"| node_cli
node_user -->|"builds and analyzes"| node_build
node_cli -->|"loads image"| node_sources
node_sources -.->|"resolves image"| node_engines
node_cli -->|"analyzes image"| node_analysis
node_analysis -->|"uses layer trees"| node_layerdata
node_cli -.->|"evaluates rules"| node_ci
node_cli -.->|"exports analysis"| node_json
node_cli -->|"publishes task events"| node_eventbus
node_progress -->|"dispatches events"| node_handler
node_handler -->|"handles image events"| node_eventbus
node_tui -->|"configures layout"| node_layout
node_tui -->|"creates controller"| node_controller
node_controller -->|"updates views"| node_layer_views
node_filetree_view -->|"uses model"| node_filetree_model
node_filetree_model -->|"uses tree data"| node_filetree_data

click node_cli "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/run.go"
click node_build "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/build.go"
click node_sources "https://github.com/wagoodman/dive/blob/main/internal/source/source.go"
click node_analysis "https://github.com/wagoodman/dive/blob/main/dive/analysis.go"
click node_layerdata "https://github.com/wagoodman/dive/blob/main/internal/layertree/layertree.go"
click node_eventbus "https://github.com/wagoodman/dive/blob/main/internal/bus/bus.go"
click node_progress "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/progress_ui.go"
click node_handler "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/handler/handler.go"
click node_tui "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/app/app.go"
click node_controller "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/app/controller.go"
click node_layer_views "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/view/layer.go"
click node_filetree_view "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/view/filetree.go"
click node_filetree_model "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/viewmodel/filetree.go"
click node_filetree_data "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/filetree/file_tree.go"
click node_layout "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/layout/manager.go"
click node_ci "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/ci/evaluator.go"
click node_json "https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/export/export.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_cli,node_build,node_eventbus,node_user toneBlue
class node_sources,node_engines,node_analysis,node_layerdata toneAmber
class node_progress,node_handler,node_tui,node_controller,node_layer_views,node_filetree_view,node_filetree_model,node_filetree_data,node_layout toneMint
class node_ci,node_json toneRose
```

## Components

### CLI workflows

- [CLI commands](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/run.go): `cmd/dive/cli/internal/command/run.go`
- [Build command](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/build.go): `cmd/dive/cli/internal/command/build.go`
- [Event bus](https://github.com/wagoodman/dive/blob/main/internal/bus/bus.go): `internal/bus/bus.go`

### Image analysis

- [Image sources](https://github.com/wagoodman/dive/blob/main/internal/source/source.go): `internal/source/source.go`
- **Image engines**
- [Layer analysis](https://github.com/wagoodman/dive/blob/main/dive/analysis.go): `dive/analysis.go`
- [Layer trees](https://github.com/wagoodman/dive/blob/main/internal/layertree/layertree.go): `internal/layertree/layertree.go`

### Terminal exploration

- [Progress UI](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/progress_ui.go): `cmd/dive/cli/internal/ui/progress_ui.go`
- [Image event handler](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/handler/handler.go): `cmd/dive/cli/internal/ui/handler/handler.go`
- [Interactive TUI](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/app/app.go): `cmd/dive/cli/internal/ui/tui/app/app.go`
- [View controller](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/app/controller.go): `cmd/dive/cli/internal/ui/tui/app/controller.go`
- [Layer views](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/view/layer.go): `cmd/dive/cli/internal/ui/tui/view/layer.go`
- [File tree view](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/view/filetree.go): `cmd/dive/cli/internal/ui/tui/view/filetree.go`
- [File tree model](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/viewmodel/filetree.go): `cmd/dive/cli/internal/ui/tui/viewmodel/filetree.go`
- [File tree data](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/filetree/file_tree.go): `cmd/dive/cli/internal/ui/tui/filetree/file_tree.go`
- [Terminal layout](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/ui/tui/layout/manager.go): `cmd/dive/cli/internal/ui/tui/layout/manager.go`

### Automation outputs

- [CI evaluation](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/ci/evaluator.go): `cmd/dive/cli/internal/command/ci/evaluator.go`
- [JSON export](https://github.com/wagoodman/dive/blob/main/cmd/dive/cli/internal/command/export/export.go): `cmd/dive/cli/internal/command/export/export.go`

### Other components

- **CLI user**

## Connections

- CLI user → CLI commands: invokes
- CLI user → Build command: builds and analyzes
- CLI commands → Image sources: loads image (evidence: `cmd/dive/cli/internal/command/run.go`)
- Image sources → Image engines: resolves image
- CLI commands → Layer analysis: analyzes image (evidence: `cmd/dive/cli/internal/command/run.go`)
- Layer analysis → Layer trees: uses layer trees (evidence: `dive/analysis.go`)
- CLI commands → CI evaluation: evaluates rules
- CLI commands → JSON export: exports analysis
- CLI commands → Event bus: publishes task events (evidence: `cmd/dive/cli/internal/command/run.go`)
- Progress UI → Image event handler: dispatches events (evidence: `cmd/dive/cli/internal/ui/progress_ui.go`)
- Image event handler → Event bus: handles image events (evidence: `cmd/dive/cli/internal/ui/handler/handler.go`)
- Interactive TUI → Terminal layout: configures layout (evidence: `cmd/dive/cli/internal/ui/tui/app/app.go`)
- Interactive TUI → View controller: creates controller (evidence: `cmd/dive/cli/internal/ui/tui/app/app.go`)
- View controller → Layer views: updates views (evidence: `cmd/dive/cli/internal/ui/tui/app/controller.go`)
- File tree view → File tree model: uses model (evidence: `cmd/dive/cli/internal/ui/tui/view/filetree.go`)
- File tree model → File tree data: uses tree data (evidence: `cmd/dive/cli/internal/ui/tui/viewmodel/filetree.go`)
