# redstarbird/arrowpack architecture

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

- Interactive diagram: https://gitdiagram.com/redstarbird/arrowpack
- Repository: https://github.com/redstarbird/arrowpack

## Overview

ArrowPack is a web bundler with a Node.js CLI and an Emscripten-compiled native core. The principal workflow takes project settings and entry files, discovers dependencies, orders them, and bundles files; plugin validation and transformation are additional stages. In development mode, file changes trigger native incremental rebuilding and the server sends updates to clients. The README identifies HTML includes and JavaScript module bundling as implemented; it marks CSS bundling and HTML/CSS minification as unimplemented. Some internal calls are not shown in the excerpts, so the graph omits those links rather than inferring them.

Main entry points: [`bin/arrowpack.js`](https://github.com/redstarbird/arrowpack/blob/main/bin/arrowpack.js) (ArrowPack CLI), [`src/native/bridge/Main.c`](https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/Main.c) (Native runtime bridge), [`src/node/server/DevServer.js`](https://github.com/redstarbird/arrowpack/blob/main/src/node/server/DevServer.js) (Development server), [`src/native/bridge/plugins/Plugins.c`](https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/plugins/Plugins.c) (Plugin validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and configuration"]
  node_cli["ArrowPack CLI<br/>[arrowpack.js]"]
  node_settings["Settings<br/>[config.js]"]
end

subgraph group_native["Native bundling core"]
  node_wasm["Native runtime bridge<br/>[Main.c]"]
  node_graph["Dependency graph<br/>[DependencyGraph.c]"]
  node_filetypes["File type handling<br/>[FileTypesHandler.c]"]
  node_bundle["File bundling<br/>[BundleFiles.c]"]
  node_minify["HTML and JS minifiers"]
  node_fileutil["File operations<br/>[FileUtil.c]"]
end

subgraph group_plugins["Plugins and transforms"]
  node_transform["Plugin transforms<br/>[Transform.c]"]
  node_validation["Plugin validation<br/>[Plugins.c]"]
  node_pluginapi["Validator API<br/>[index.cjs]"]
end

subgraph group_dev["Development server"]
  node_devserver["Development server<br/>[DevServer.js]"]
  node_watcher["File change watcher<br/>[arrowpack.js]"]
end

node_developer(("Project developer"))
node_project["Website source files"]
node_client(("Browser clients"))

node_developer -->|"runs"| node_cli
node_project -->|"configures"| node_cli
node_cli -->|"loads settings"| node_settings
node_cli -->|"calls native API"| node_wasm
node_wasm -->|"finds dependents"| node_graph
node_wasm -->|"rebundles files"| node_bundle
node_wasm -->|"classifies new files"| node_filetypes
node_cli -->|"invokes validators"| node_validation
node_cli -->|"invokes transforms"| node_transform
node_validation -.->|"calls validator"| node_pluginapi
node_cli -->|"watches entry"| node_watcher
node_watcher -->|"requests rebuild"| node_wasm
node_cli -->|"starts server"| node_devserver
node_cli -->|"sends updates"| node_devserver
node_devserver -.->|"serves pages"| node_client

click node_cli "https://github.com/redstarbird/arrowpack/blob/main/bin/arrowpack.js"
click node_settings "https://github.com/redstarbird/arrowpack/blob/main/src/node/config.js"
click node_wasm "https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/Main.c"
click node_graph "https://github.com/redstarbird/arrowpack/blob/main/src/native/graph/DependencyGraph.c"
click node_filetypes "https://github.com/redstarbird/arrowpack/blob/main/src/native/graph/FileTypesHandler.c"
click node_bundle "https://github.com/redstarbird/arrowpack/blob/main/src/native/codegen/BundleFiles.c"
click node_minify "https://github.com/redstarbird/arrowpack/tree/main/src/native/minify"
click node_fileutil "https://github.com/redstarbird/arrowpack/blob/main/src/native/util/FileUtil.c"
click node_transform "https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/plugins/Transform.c"
click node_validation "https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/plugins/Plugins.c"
click node_pluginapi "https://github.com/redstarbird/arrowpack/blob/main/plugin/index.cjs"
click node_devserver "https://github.com/redstarbird/arrowpack/blob/main/src/node/server/DevServer.js"
click node_watcher "https://github.com/redstarbird/arrowpack/blob/main/bin/arrowpack.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_settings,node_client toneBlue
class node_wasm,node_graph,node_filetypes,node_bundle,node_minify,node_fileutil toneAmber
class node_transform,node_validation,node_pluginapi toneMint
class node_devserver,node_watcher toneRose
class node_developer,node_project toneIndigo
```

## Components

### CLI and configuration

- [ArrowPack CLI](https://github.com/redstarbird/arrowpack/blob/main/bin/arrowpack.js): `bin/arrowpack.js`
- [Settings](https://github.com/redstarbird/arrowpack/blob/main/src/node/config.js): `src/node/config.js`

### Native bundling core

- [Native runtime bridge](https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/Main.c): `src/native/bridge/Main.c`
- [Dependency graph](https://github.com/redstarbird/arrowpack/blob/main/src/native/graph/DependencyGraph.c): `src/native/graph/DependencyGraph.c`
- [File type handling](https://github.com/redstarbird/arrowpack/blob/main/src/native/graph/FileTypesHandler.c): `src/native/graph/FileTypesHandler.c`
- [File bundling](https://github.com/redstarbird/arrowpack/blob/main/src/native/codegen/BundleFiles.c): `src/native/codegen/BundleFiles.c`
- [HTML and JS minifiers](https://github.com/redstarbird/arrowpack/tree/main/src/native/minify): `src/native/minify`
- [File operations](https://github.com/redstarbird/arrowpack/blob/main/src/native/util/FileUtil.c): `src/native/util/FileUtil.c`

### Plugins and transforms

- [Plugin transforms](https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/plugins/Transform.c): `src/native/bridge/plugins/Transform.c`
- [Plugin validation](https://github.com/redstarbird/arrowpack/blob/main/src/native/bridge/plugins/Plugins.c): `src/native/bridge/plugins/Plugins.c`
- [Validator API](https://github.com/redstarbird/arrowpack/blob/main/plugin/index.cjs): `plugin/index.cjs`

### Development server

- [Development server](https://github.com/redstarbird/arrowpack/blob/main/src/node/server/DevServer.js): `src/node/server/DevServer.js`
- [File change watcher](https://github.com/redstarbird/arrowpack/blob/main/bin/arrowpack.js): `bin/arrowpack.js`

### Other components

- **Project developer**
- **Website source files**
- **Browser clients**

## Connections

- Project developer → ArrowPack CLI: runs (evidence: `bin/arrowpack.js`)
- Website source files → ArrowPack CLI: configures (evidence: `bin/arrowpack.js`)
- ArrowPack CLI → Settings: loads settings (evidence: `bin/arrowpack.js`)
- ArrowPack CLI → Native runtime bridge: calls native API (evidence: `bin/arrowpack.js`)
- Native runtime bridge → Dependency graph: finds dependents (evidence: `src/native/bridge/Main.c`)
- Native runtime bridge → File bundling: rebundles files (evidence: `src/native/bridge/Main.c`)
- Native runtime bridge → File type handling: classifies new files (evidence: `src/native/bridge/Main.c`)
- ArrowPack CLI → Plugin validation: invokes validators (evidence: `bin/arrowpack.js`)
- ArrowPack CLI → Plugin transforms: invokes transforms (evidence: `bin/arrowpack.js`)
- Plugin validation → Validator API: calls validator
- ArrowPack CLI → File change watcher: watches entry (evidence: `bin/arrowpack.js`)
- File change watcher → Native runtime bridge: requests rebuild (evidence: `bin/arrowpack.js`)
- ArrowPack CLI → Development server: starts server (evidence: `bin/arrowpack.js`)
- ArrowPack CLI → Development server: sends updates (evidence: `bin/arrowpack.js`)
- Development server → Browser clients: serves pages
