# suleymancelikel/metro-bundle-visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/suleymancelikel/metro-bundle-visualizer
- Repository: https://github.com/suleymancelikel/metro-bundle-visualizer

## Overview

metro-bundle-visualizer is a React Native CLI tool that captures Metro’s per-module JavaScript sizes and produces a self-contained interactive HTML treemap. The main workflow detects project settings, bundles through a temporary Metro configuration, captures module statistics in the serializer, generates the report, and optionally opens it. The graph also preserves the documented package breakdown, search/filter, tooltip, and file-detail capabilities. Relationships are limited to those shown in the CLI, serializer, report code, or README; UI asset wiring is supported by the report implementation.

Main entry points: [`src/cli.ts`](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/cli.ts) (CLI workflow), [`src/report.ts`](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/report.ts) (HTML report generator), [`src/bundle.ts`](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/bundle.ts) (Bundle runner), [`src/serializer.ts`](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/serializer.ts) (Stats serializer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_project["Project discovery"]
  node_cli["CLI workflow<br/>[cli.ts]"]
  node_detect["Project detection<br/>[detect.ts]"]
end

subgraph group_capture["Bundle capture"]
  node_metro["Metro bundler"]
  node_bundle["Bundle runner<br/>[bundle.ts]"]
  node_serializer["Stats serializer<br/>[serializer.ts]"]
  node_stats["Module statistics"]
end

subgraph group_report["Report visualization"]
  node_report["HTML report generator<br/>[report.ts]"]
  node_template["Report template<br/>[template.html]"]
  node_styles["Report styles<br/>[styles.css]"]
  node_treemap["Treemap interface<br/>[treemap.js]"]
end

node_user(("React Native developer"))
node_browser(("Browser"))

node_user -->|"runs"| node_cli
node_cli -->|"detects project"| node_detect
node_cli -->|"runs bundle"| node_bundle
node_bundle -->|"spawns bundler"| node_metro
node_metro -->|"invokes serializer"| node_serializer
node_serializer -->|"writes statistics"| node_stats
node_cli -->|"reads statistics"| node_stats
node_cli -->|"generates report"| node_report
node_report -->|"loads template"| node_template
node_report -->|"embeds styles"| node_styles
node_report -->|"embeds interface"| node_treemap
node_treemap -->|"renders treemap"| node_browser
node_cli -->|"opens report"| node_browser

click node_cli "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/cli.ts"
click node_detect "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/detect.ts"
click node_bundle "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/bundle.ts"
click node_serializer "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/serializer.ts"
click node_report "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/report.ts"
click node_template "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/ui/template.html"
click node_styles "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/ui/styles.css"
click node_treemap "https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/ui/treemap.js"

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_detect,node_browser toneBlue
class node_metro,node_bundle,node_serializer,node_stats toneAmber
class node_report,node_template,node_styles,node_treemap toneMint
class node_user toneIndigo
```

## Components

### Project discovery

- [CLI workflow](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/cli.ts): `src/cli.ts`
- [Project detection](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/detect.ts): `src/detect.ts`

### Bundle capture

- **Metro bundler**
- [Bundle runner](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/bundle.ts): `src/bundle.ts`
- [Stats serializer](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/serializer.ts): `src/serializer.ts`
- **Module statistics**

### Report visualization

- [HTML report generator](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/report.ts): `src/report.ts`
- [Report template](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/ui/template.html): `src/ui/template.html`
- [Report styles](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/ui/styles.css): `src/ui/styles.css`
- [Treemap interface](https://github.com/suleymancelikel/metro-bundle-visualizer/blob/main/src/ui/treemap.js): `src/ui/treemap.js`

### Other components

- **React Native developer**
- **Browser**

## Connections

- React Native developer → CLI workflow: runs (evidence: `README.md`)
- CLI workflow → Project detection: detects project (evidence: `src/cli.ts`)
- CLI workflow → Bundle runner: runs bundle (evidence: `src/cli.ts`)
- Bundle runner → Metro bundler: spawns bundler (evidence: `src/bundle.ts`)
- Metro bundler → Stats serializer: invokes serializer (evidence: `README.md`)
- Stats serializer → Module statistics: writes statistics (evidence: `src/serializer.ts`)
- CLI workflow → Module statistics: reads statistics (evidence: `src/cli.ts`)
- CLI workflow → HTML report generator: generates report (evidence: `src/cli.ts`)
- HTML report generator → Report template: loads template (evidence: `src/report.ts`)
- HTML report generator → Report styles: embeds styles (evidence: `src/report.ts`)
- HTML report generator → Treemap interface: embeds interface (evidence: `src/report.ts`)
- Treemap interface → Browser: renders treemap (evidence: `README.md`)
- CLI workflow → Browser: opens report (evidence: `src/cli.ts`)
