# onsi/ginkgo architecture

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

- Interactive diagram: https://gitdiagram.com/onsi/ginkgo
- Repository: https://github.com/onsi/ginkgo

## Overview

Ginkgo is a Go BDD testing framework and companion CLI. A user defines specs through the DSL, then invokes the CLI or Go testing entry point to discover, filter, compile, and execute suites; results are reported in human-readable or machine-readable formats. The CLI also supports bootstrapping, code generation, outlining, labels, profiling, and watch mode. The graph preserves these documented capabilities, while its detailed execution and parallel-coordination links rely on sampled source. Other subsystem relationships are documented at a capability level in the README, not traced through unsampled implementations.

Main entry points: [`ginkgo/command/program.go`](https://github.com/onsi/ginkgo/blob/master/ginkgo/command/program.go) (CLI Dispatcher), [`internal/suite.go`](https://github.com/onsi/ginkgo/blob/master/internal/suite.go) (Suite Runtime), [`ginkgo/internal/run.go`](https://github.com/onsi/ginkgo/blob/master/ginkgo/internal/run.go) (Suite Runner), [`internal/parallel_support/server_handler.go`](https://github.com/onsi/ginkgo/blob/master/internal/parallel_support/server_handler.go) (Parallel Coordination)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_specs["Spec Authoring"]
  node_ginkgo_dsl["Ginkgo DSL<br/>[core_dsl.go]"]
  node_table_dsl["Table DSL<br/>[table_dsl.go]"]
  node_decorators["Spec Decorators<br/>[decorators_dsl.go]"]
end

subgraph group_runtime["Suite Runtime"]
  node_suite_runtime["Suite Runtime<br/>[suite.go]"]
  node_spec_tree["Spec Tree<br/>[tree.go]"]
  node_spec_context["Spec Context<br/>[spec_context.go]"]
  node_config_filters["Config and Filters<br/>[label_filter.go]"]
end

subgraph group_results["Reporting"]
  node_reporter["Default Reporter"]
  node_report_formats["Report Formats<br/>[junit_report.go]"]
  node_custom_reporting["Custom Reporting<br/>[reporter.go]"]
  node_formatter["Output Formatting<br/>[formatter.go]"]
end

subgraph group_cli["CLI Workflows"]
  node_run_command["Run Command<br/>[run_command.go]"]
  node_cli_dispatch["CLI Dispatcher<br/>[program.go]"]
  node_cli_entry["CLI Entry<br/>[main.go]"]
  node_suite_runner["Suite Runner<br/>[run.go]"]
  node_generators["Bootstrap and Generate"]
  node_outline["Suite Outline<br/>[ginkgo.go]"]
  node_labels_cmd["Label Commands<br/>[labels_command.go]"]
  node_watch["Watch Mode<br/>[watch_command.go]"]
end

subgraph group_support["Runtime Support"]
  node_interrupts["Interrupt Handling"]
  node_parallel["Parallel Coordination<br/>[server_handler.go]"]
end

node_author(("Go Developer"))
node_go_testing(("Go testing"))

node_author -->|"writes specs"| node_ginkgo_dsl
node_author -->|"defines tables"| node_table_dsl
node_author -->|"adds decorators"| node_decorators
node_ginkgo_dsl -.->|"registers specs"| node_suite_runtime
node_table_dsl -.->|"builds specs"| node_ginkgo_dsl
node_decorators -.->|"sets metadata"| node_config_filters
node_go_testing -->|"hosts suite"| node_suite_runtime
node_suite_runtime -.->|"organizes nodes"| node_spec_tree
node_suite_runtime -->|"provides context"| node_spec_context
node_suite_runtime -->|"filters specs"| node_config_filters
node_author -->|"runs suites"| node_run_command
node_cli_entry -->|"starts dispatch"| node_cli_dispatch
node_cli_dispatch -->|"routes default"| node_run_command
node_run_command -->|"runs suites"| node_suite_runner
node_suite_runner -->|"coordinates workers"| node_parallel
node_suite_runner -->|"creates reporter"| node_reporter
node_suite_runtime -->|"sends suite events"| node_parallel
node_parallel -->|"aggregates reports"| node_custom_reporting
node_interrupts -->|"checks abort state"| node_parallel
node_reporter -->|"formats output"| node_formatter
node_reporter -->|"emits reports"| node_report_formats
node_author -->|"builds reporters"| node_custom_reporting
node_cli_dispatch -->|"routes commands"| node_generators
node_cli_dispatch -->|"routes commands"| node_outline
node_cli_dispatch -->|"routes commands"| node_labels_cmd
node_cli_dispatch -->|"routes commands"| node_watch
node_watch -->|"reruns suites"| node_suite_runner
node_author -->|"inspects suites"| node_outline
node_author -->|"filters by labels"| node_labels_cmd
node_author -->|"reruns on change"| node_watch
node_suite_runner -->|"writes profiles"| node_report_formats

click node_ginkgo_dsl "https://github.com/onsi/ginkgo/blob/master/core_dsl.go"
click node_table_dsl "https://github.com/onsi/ginkgo/blob/master/table_dsl.go"
click node_decorators "https://github.com/onsi/ginkgo/blob/master/dsl/decorators/decorators_dsl.go"
click node_suite_runtime "https://github.com/onsi/ginkgo/blob/master/internal/suite.go"
click node_spec_tree "https://github.com/onsi/ginkgo/blob/master/internal/tree.go"
click node_spec_context "https://github.com/onsi/ginkgo/blob/master/internal/spec_context.go"
click node_config_filters "https://github.com/onsi/ginkgo/blob/master/types/label_filter.go"
click node_run_command "https://github.com/onsi/ginkgo/blob/master/ginkgo/run/run_command.go"
click node_cli_dispatch "https://github.com/onsi/ginkgo/blob/master/ginkgo/command/program.go"
click node_cli_entry "https://github.com/onsi/ginkgo/blob/master/ginkgo/main.go"
click node_suite_runner "https://github.com/onsi/ginkgo/blob/master/ginkgo/internal/run.go"
click node_generators "https://github.com/onsi/ginkgo/blob/master/ginkgo/generators/generate_command.go"
click node_outline "https://github.com/onsi/ginkgo/blob/master/ginkgo/outline/ginkgo.go"
click node_labels_cmd "https://github.com/onsi/ginkgo/blob/master/ginkgo/labels/labels_command.go"
click node_watch "https://github.com/onsi/ginkgo/blob/master/ginkgo/watch/watch_command.go"
click node_interrupts "https://github.com/onsi/ginkgo/blob/master/internal/interrupt_handler/interrupt_handler.go"
click node_parallel "https://github.com/onsi/ginkgo/blob/master/internal/parallel_support/server_handler.go"
click node_reporter "https://github.com/onsi/ginkgo/blob/master/reporters/default_reporter.go"
click node_report_formats "https://github.com/onsi/ginkgo/blob/master/reporters/junit_report.go"
click node_custom_reporting "https://github.com/onsi/ginkgo/blob/master/reporters/reporter.go"
click node_formatter "https://github.com/onsi/ginkgo/blob/master/formatter/formatter.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_ginkgo_dsl,node_table_dsl,node_decorators toneBlue
class node_suite_runtime,node_spec_tree,node_spec_context,node_config_filters toneAmber
class node_reporter,node_report_formats,node_custom_reporting,node_formatter toneMint
class node_run_command,node_cli_dispatch,node_cli_entry,node_suite_runner,node_generators,node_outline,node_labels_cmd,node_watch toneRose
class node_interrupts,node_parallel,node_author,node_go_testing toneIndigo
```

## Components

### Spec Authoring

- [Ginkgo DSL](https://github.com/onsi/ginkgo/blob/master/core_dsl.go): `core_dsl.go`
- [Table DSL](https://github.com/onsi/ginkgo/blob/master/table_dsl.go): `table_dsl.go`
- [Spec Decorators](https://github.com/onsi/ginkgo/blob/master/dsl/decorators/decorators_dsl.go): `dsl/decorators/decorators_dsl.go`

### Suite Runtime

- [Suite Runtime](https://github.com/onsi/ginkgo/blob/master/internal/suite.go): `internal/suite.go`
- [Spec Tree](https://github.com/onsi/ginkgo/blob/master/internal/tree.go): `internal/tree.go`
- [Spec Context](https://github.com/onsi/ginkgo/blob/master/internal/spec_context.go): `internal/spec_context.go`
- [Config and Filters](https://github.com/onsi/ginkgo/blob/master/types/label_filter.go): `types/label_filter.go`

### Reporting

- [Default Reporter](https://github.com/onsi/ginkgo/blob/master/reporters/default_reporter.go): `reporters/default_reporter.go`
- [Report Formats](https://github.com/onsi/ginkgo/blob/master/reporters/junit_report.go): `reporters/junit_report.go`
- [Custom Reporting](https://github.com/onsi/ginkgo/blob/master/reporters/reporter.go): `reporters/reporter.go`
- [Output Formatting](https://github.com/onsi/ginkgo/blob/master/formatter/formatter.go): `formatter/formatter.go`

### CLI Workflows

- [Run Command](https://github.com/onsi/ginkgo/blob/master/ginkgo/run/run_command.go): `ginkgo/run/run_command.go`
- [CLI Dispatcher](https://github.com/onsi/ginkgo/blob/master/ginkgo/command/program.go): `ginkgo/command/program.go`
- [CLI Entry](https://github.com/onsi/ginkgo/blob/master/ginkgo/main.go): `ginkgo/main.go`
- [Suite Runner](https://github.com/onsi/ginkgo/blob/master/ginkgo/internal/run.go): `ginkgo/internal/run.go`
- [Bootstrap and Generate](https://github.com/onsi/ginkgo/blob/master/ginkgo/generators/generate_command.go): `ginkgo/generators/generate_command.go`
- [Suite Outline](https://github.com/onsi/ginkgo/blob/master/ginkgo/outline/ginkgo.go): `ginkgo/outline/ginkgo.go`
- [Label Commands](https://github.com/onsi/ginkgo/blob/master/ginkgo/labels/labels_command.go): `ginkgo/labels/labels_command.go`
- [Watch Mode](https://github.com/onsi/ginkgo/blob/master/ginkgo/watch/watch_command.go): `ginkgo/watch/watch_command.go`

### Runtime Support

- [Interrupt Handling](https://github.com/onsi/ginkgo/blob/master/internal/interrupt_handler/interrupt_handler.go): `internal/interrupt_handler/interrupt_handler.go`
- [Parallel Coordination](https://github.com/onsi/ginkgo/blob/master/internal/parallel_support/server_handler.go): `internal/parallel_support/server_handler.go`

### Other components

- **Go Developer**
- **Go testing**

## Connections

- Go Developer → Ginkgo DSL: writes specs (evidence: `README.md`)
- Go Developer → Table DSL: defines tables (evidence: `README.md`)
- Go Developer → Spec Decorators: adds decorators (evidence: `README.md`)
- Ginkgo DSL → Suite Runtime: registers specs
- Table DSL → Ginkgo DSL: builds specs
- Spec Decorators → Config and Filters: sets metadata
- Go testing → Suite Runtime: hosts suite (evidence: `README.md`)
- Suite Runtime → Spec Tree: organizes nodes
- Suite Runtime → Spec Context: provides context (evidence: `README.md`)
- Suite Runtime → Config and Filters: filters specs (evidence: `README.md`)
- Go Developer → Run Command: runs suites (evidence: `README.md`)
- CLI Entry → CLI Dispatcher: starts dispatch (evidence: `ginkgo/main.go`)
- CLI Dispatcher → Run Command: routes default (evidence: `ginkgo/command/program.go`)
- Run Command → Suite Runner: runs suites (evidence: `ginkgo/run/run_command.go`)
- Suite Runner → Parallel Coordination: coordinates workers (evidence: `ginkgo/internal/run.go`)
- Suite Runner → Default Reporter: creates reporter (evidence: `ginkgo/internal/run.go`)
- Suite Runtime → Parallel Coordination: sends suite events
- Parallel Coordination → Custom Reporting: aggregates reports (evidence: `internal/parallel_support/server_handler.go`)
- Interrupt Handling → Parallel Coordination: checks abort state (evidence: `internal/interrupt_handler/interrupt_handler.go`)
- Default Reporter → Output Formatting: formats output (evidence: `reporters/default_reporter.go`)
- Default Reporter → Report Formats: emits reports (evidence: `README.md`)
- Go Developer → Custom Reporting: builds reporters (evidence: `README.md`)
- CLI Dispatcher → Bootstrap and Generate: routes commands
- CLI Dispatcher → Suite Outline: routes commands
- CLI Dispatcher → Label Commands: routes commands
- CLI Dispatcher → Watch Mode: routes commands
- Watch Mode → Suite Runner: reruns suites (evidence: `ginkgo/watch/watch_command.go`)
- Go Developer → Suite Outline: inspects suites (evidence: `README.md`)
- Go Developer → Label Commands: filters by labels (evidence: `README.md`)
- Go Developer → Watch Mode: reruns on change (evidence: `README.md`)
- Suite Runner → Report Formats: writes profiles (evidence: `README.md`)
