# garnertb/nextjs-bundle-analysis-action architecture

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

- Interactive diagram: https://gitdiagram.com/garnertb/nextjs-bundle-analysis-action
- Repository: https://github.com/garnertb/nextjs-bundle-analysis-action

## Overview

This GitHub Action measures per-route client JavaScript from a Next.js build, compares the report with a trusted base-branch artifact, evaluates budgets, and publishes findings as a PR comment and job summary. The principal runtime is orchestrated by `src/main.ts`; `src/cli.ts` also exposes local measurement and report commands. The tree and excerpts establish the collector and baseline paths, but some delivery details are only partially sampled, so the graph omits uncertain internal wiring.

Main entry points: [`src/main.ts`](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/main.ts) (Action orchestrator), [`src/collectors/index.ts`](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/index.ts) (Report collection), [`src/github/artifact.ts`](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/artifact.ts) (Artifact transfer), [`src/report/compare.ts`](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/report/compare.ts) (Report comparison)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Action runtime"]
  node_main["Action orchestrator<br/>[main.ts]"]
  node_inputs["Input parsing<br/>[inputs.ts]"]
  node_build["Optional build<br/>[main.ts]"]
end

subgraph group_measure["Bundle measurement"]
  node_collector["Report collection<br/>[index.ts]"]
  node_environment["Version and bundler<br/>[environment.ts]"]
  node_appcollect["App Router routes<br/>[detect.ts]"]
  node_pagescollect["Pages Router routes<br/>[pages.ts]"]
  node_manifest["App manifest parsing<br/>[app-manifest.ts]"]
  node_turbopack["Turbopack support<br/>[app-turbopack.ts]"]
  node_routepath["Route normalization<br/>[route-path.ts]"]
  node_compression["Chunk size compression<br/>[compression.ts]"]
end

subgraph group_analysis["Comparison and budgets"]
  node_reportdata["Bundle report<br/>[types.ts]"]
  node_comparison["Report comparison<br/>[compare.ts]"]
  node_config["Threshold configuration<br/>[config.ts]"]
  node_budgets["Route budget rules<br/>[budgets-file.ts]"]
  node_evaluation["Threshold evaluation<br/>[evaluate.ts]"]
  node_render["Markdown reporting<br/>[render.ts]"]
end

subgraph group_delivery["GitHub delivery"]
  node_baseline["Baseline lookup<br/>[baseline.ts]"]
  node_artifact["Artifact transfer<br/>[artifact.ts]"]
  node_githubapi["GitHub API adapter<br/>[api.ts]"]
  node_comment["PR comment upsert<br/>[comment.ts]"]
  node_annotate["Finding annotations<br/>[annotate.ts]"]
  node_summary["Job summary<br/>[summary.ts]"]
end

node_workflow(("Workflow caller"))
node_nextoutput["Next.js build output"]
node_github(("GitHub services"))
node_artifactstore[("Workflow artifacts")]

node_workflow -->|"runs"| node_main
node_main -->|"parses"| node_inputs
node_main -->|"optionally runs"| node_build
node_build -->|"builds"| node_nextoutput
node_main -->|"collects"| node_collector
node_collector -->|"reads"| node_nextoutput
node_collector -->|"detects"| node_environment
node_collector -->|"collects routes"| node_appcollect
node_collector -->|"collects routes"| node_pagescollect
node_appcollect -.->|"reads manifests"| node_manifest
node_appcollect -.->|"supports"| node_turbopack
node_collector -->|"normalizes routes"| node_routepath
node_collector -->|"measures files"| node_compression
node_collector -->|"produces"| node_reportdata
node_main -->|"finds baseline"| node_baseline
node_baseline -->|"queries runs"| node_githubapi
node_baseline -->|"downloads report"| node_artifact
node_artifact -->|"accesses artifacts"| node_github
node_githubapi -->|"calls API"| node_github
node_artifact -->|"reads baseline"| node_reportdata
node_main -->|"compares reports"| node_comparison
node_baseline -->|"compares fallback"| node_comparison
node_reportdata -->|"supplies measurements"| node_comparison
node_main -->|"builds config"| node_config
node_main -->|"evaluates findings"| node_evaluation
node_evaluation -->|"resolves overrides"| node_budgets
node_comparison -->|"supplies deltas"| node_evaluation
node_main -->|"renders report"| node_render
node_comparison -->|"supplies comparison"| node_render
node_evaluation -->|"supplies findings"| node_render
node_main -->|"upserts comment"| node_comment
node_comment -->|"reads and writes"| node_githubapi
node_main -->|"publishes findings"| node_annotate
node_annotate -->|"creates annotations"| node_github
node_main -->|"writes summary"| node_summary
node_summary -->|"writes job summary"| node_github
node_main -->|"uploads report"| node_artifact
node_artifact -->|"stores report"| node_artifactstore
node_artifactstore -->|"provides baseline"| node_artifact

click node_main "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/main.ts"
click node_inputs "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/inputs.ts"
click node_build "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/main.ts"
click node_collector "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/index.ts"
click node_environment "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/environment.ts"
click node_appcollect "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/detect.ts"
click node_pagescollect "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/pages.ts"
click node_manifest "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/app-manifest.ts"
click node_turbopack "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/app-turbopack.ts"
click node_routepath "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/route-path.ts"
click node_compression "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/compression.ts"
click node_reportdata "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/types.ts"
click node_baseline "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/baseline.ts"
click node_artifact "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/artifact.ts"
click node_githubapi "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/api.ts"
click node_comparison "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/report/compare.ts"
click node_config "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/config.ts"
click node_budgets "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/thresholds/budgets-file.ts"
click node_evaluation "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/thresholds/evaluate.ts"
click node_render "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/report/render.ts"
click node_comment "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/comment.ts"
click node_annotate "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/annotate.ts"
click node_summary "https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/summary.ts"

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_inputs,node_build toneBlue
class node_collector,node_environment,node_appcollect,node_pagescollect,node_manifest,node_turbopack,node_routepath,node_compression,node_artifactstore toneAmber
class node_reportdata,node_comparison,node_config,node_budgets,node_evaluation,node_render toneMint
class node_baseline,node_artifact,node_githubapi,node_comment,node_annotate,node_summary toneRose
class node_workflow,node_nextoutput,node_github toneIndigo
```

## Components

### Action runtime

- [Action orchestrator](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/main.ts): `src/main.ts`
- [Input parsing](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/inputs.ts): `src/inputs.ts`
- [Optional build](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/main.ts): `src/main.ts`

### Bundle measurement

- [Report collection](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/index.ts): `src/collectors/index.ts`
- [Version and bundler](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/environment.ts): `src/collectors/environment.ts`
- [App Router routes](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/detect.ts): `src/collectors/detect.ts`
- [Pages Router routes](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/pages.ts): `src/collectors/pages.ts`
- [App manifest parsing](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/app-manifest.ts): `src/collectors/app-manifest.ts`
- [Turbopack support](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/app-turbopack.ts): `src/collectors/app-turbopack.ts`
- [Route normalization](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/route-path.ts): `src/collectors/route-path.ts`
- [Chunk size compression](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/compression.ts): `src/collectors/compression.ts`

### Comparison and budgets

- [Bundle report](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/collectors/types.ts): `src/collectors/types.ts`
- [Report comparison](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/report/compare.ts): `src/report/compare.ts`
- [Threshold configuration](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/config.ts): `src/config.ts`
- [Route budget rules](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/thresholds/budgets-file.ts): `src/thresholds/budgets-file.ts`
- [Threshold evaluation](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/thresholds/evaluate.ts): `src/thresholds/evaluate.ts`
- [Markdown reporting](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/report/render.ts): `src/report/render.ts`

### GitHub delivery

- [Baseline lookup](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/baseline.ts): `src/github/baseline.ts`
- [Artifact transfer](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/artifact.ts): `src/github/artifact.ts`
- [GitHub API adapter](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/api.ts): `src/github/api.ts`
- [PR comment upsert](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/comment.ts): `src/github/comment.ts`
- [Finding annotations](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/annotate.ts): `src/github/annotate.ts`
- [Job summary](https://github.com/garnertb/nextjs-bundle-analysis-action/blob/main/src/github/summary.ts): `src/github/summary.ts`

### Other components

- **Workflow caller**
- **Next.js build output**
- **GitHub services**
- **Workflow artifacts**

## Connections

- Workflow caller → Action orchestrator: runs
- Action orchestrator → Input parsing: parses
- Action orchestrator → Optional build: optionally runs
- Optional build → Next.js build output: builds
- Action orchestrator → Report collection: collects
- Report collection → Next.js build output: reads
- Report collection → Version and bundler: detects
- Report collection → App Router routes: collects routes
- Report collection → Pages Router routes: collects routes
- App Router routes → App manifest parsing: reads manifests
- App Router routes → Turbopack support: supports
- Report collection → Route normalization: normalizes routes
- Report collection → Chunk size compression: measures files
- Report collection → Bundle report: produces
- Action orchestrator → Baseline lookup: finds baseline
- Baseline lookup → GitHub API adapter: queries runs
- Baseline lookup → Artifact transfer: downloads report
- Artifact transfer → GitHub services: accesses artifacts
- GitHub API adapter → GitHub services: calls API
- Artifact transfer → Bundle report: reads baseline
- Action orchestrator → Report comparison: compares reports
- Baseline lookup → Report comparison: compares fallback
- Bundle report → Report comparison: supplies measurements
- Action orchestrator → Threshold configuration: builds config
- Action orchestrator → Threshold evaluation: evaluates findings
- Threshold evaluation → Route budget rules: resolves overrides
- Report comparison → Threshold evaluation: supplies deltas
- Action orchestrator → Markdown reporting: renders report
- Report comparison → Markdown reporting: supplies comparison
- Threshold evaluation → Markdown reporting: supplies findings
- Action orchestrator → PR comment upsert: upserts comment
- PR comment upsert → GitHub API adapter: reads and writes
- Action orchestrator → Finding annotations: publishes findings
- Finding annotations → GitHub services: creates annotations
- Action orchestrator → Job summary: writes summary
- Job summary → GitHub services: writes job summary
- Action orchestrator → Artifact transfer: uploads report
- Artifact transfer → Workflow artifacts: stores report
- Workflow artifacts → Artifact transfer: provides baseline
