# System map — oven-sh/bun

> Canonical page: https://codevetter.com/unpack/bun/system-map

# System map — oven-sh/bun

Scanned commit bf80d21c69c355f6e5bae2749485674663ed13a1 (2026-09-22). Generated by codevetter codevetter 1.12.0 on 2026-09-22.

One native executable with a Rust core, a C++ JSC binding layer, and a build-time-bundled TypeScript module layer. `src/runtime/bin_entry/mod.rs` is the C-ABI `main`; it initializes the crash handler, allocator, stdio, and stack limits, then hands off to `cli::Cli::start()` which decodes a `Tag` and dispatches to one of 34 subcommand bodies. Storage is not a database — it's the lockfile (`bun.lock` text / `bun.lockb` binary under `src/install/lockfile/`), the global package cache, and the standalone-executable graph appended to the binary itself. Builds go through `scripts/build.ts` → CMake/ninja + `cargo` per-crate rlibs; CI is a generated Buildkite pipeline (`.buildkite/ci.ts`) plus 25 GitHub Actions workflows. Deployment shape is a downloadable binary plus npm packages, Docker images (`dockerhub/`), and a VS Code extension (`packages/bun-vscode`).
- Process entry is `extern "C" fn main(argc, argv)` in `src/runtime/bin_entry/mod.rs`, which captures argv first (because musl static builds never pass argv to `.init_array` hooks), then initializes the crash handler, points ICU/libuv/BoringSSL at mimalloc, ignores SIGPIPE/SIGXFSZ, calls `output::stdio::init()`, `StackCheck::configure_thread()`, and finally `cli::Cli::start()` before `Global::exit(0)`. — [src/runtime/bin_entry/mod.rs#L159-212](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/runtime/bin_entry/mod.rs#L159-L212)
- The allocator is selected at compile time: mimalloc is the `#[global_allocator]` normally, but under `bun_asan` the build swaps to `std::alloc::System` so the ASAN interceptor sees every allocation; the binary also strong-defines `__asan_default_options` and `__lsan_default_suppressions` from the binary crate (not an rlib) so the link actually picks them up. — [src/runtime/bin_entry/mod.rs#L45-140](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/runtime/bin_entry/mod.rs#L45-L140)
- CLI dispatch is a flat `match tag { … }` over `bun_options_types::command_tag::Tag`, with every arm out-lined into its own `#[cold] #[inline(never)]` fn so `Cli::start` compiles to a jump table and cold subcommand bodies (`install`, `create`, bundler, test runner) don't share `.text` pages with the `bun run` startup chain. — [src/runtime/cli/mod.rs#L1286-1330](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/runtime/cli/mod.rs#L1286-L1330) [src/runtime/cli/mod.rs#L540-578](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/runtime/cli/mod.rs#L540-L578)
- `Tag` enumerates 34 subcommands and each carries a single-byte `char()` code used in crash-report URLs, explicitly documented as needing to stay in sync with the external `oven-sh/bun.report` decoder. — [src/options_types/command_tag.rs#L12-90](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/options_types/command_tag.rs#L12-L90)
- The Rust side is a Cargo workspace of ~200 member crates declared in the root `Cargo.toml`, tiered so lower crates (`bun_core`, `bun_sys`, `bun_paths`) never depend on `bun_jsc` or `bun_runtime`; `bun_runtime` is the graph root and every crate's rlib is an input to the final link. — [Cargo.toml#L1-100](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/Cargo.toml#L1-L100) [src/AGENTS.md#L1-20](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/AGENTS.md#L1-L20)
- The JS engine boundary lives in two halves: Rust-side glue in `src/jsc/` (`VirtualMachine.rs` at 7,700 lines, `ModuleLoader.rs`, `event_loop.rs`) and 407 files of hand-written + generated C++ in `src/jsc/bindings/` (`BunObject.cpp`, `ZigGlobalObject`, `BunPlugin.h`, per-class `JS*` files). — [src/jsc/VirtualMachine.rs#L1-30](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/jsc/VirtualMachine.rs#L1-L30) [src/jsc/bindings/BunObject.cpp#L930-1030](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/jsc/bindings/BunObject.cpp#L930-L1030) [src/jsc/ModuleLoader.rs#L1-25](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/jsc/ModuleLoader.rs#L1-L25)
- Built-in JS modules are authored as TypeScript under `src/js/{node,bun,internal,thirdparty,builtins}` and bundled into the binary by `src/codegen/bundle-modules.ts`; they are not ES modules — only string-literal `require()` and `$`-prefixed intrinsics are allowed. — [src/js/AGENTS.md#L1-30](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/js/AGENTS.md#L1-L30) [src/codegen/bundle-modules.ts](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/codegen/bundle-modules.ts)
- Code generation is build-integrated: `generate-classes.ts` turns `*.classes.ts` definitions into paired Rust + C++ bindings, alongside `generate-jssink.ts`, `generate-host-exports.ts`, `generate-js2native.ts`, `bundle-functions.ts` and `generate-node-errors.ts`. — [src/codegen/generate-classes.ts#L1-50](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/codegen/generate-classes.ts#L1-L50) [src/runtime/generated_classes.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/runtime/generated_classes.rs) [src/runtime/generated_host_exports.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/runtime/generated_host_exports.rs)
- The build orchestrator is `scripts/build.ts`: it configures and runs ninja, supports profiles (`debug`, `release`, `release-asan`, `release-assertions`, `debug-local`), and implements build-then-exec arg routing where the first unrecognized arg starts the exec-args for the produced binary. — [scripts/build.ts#L1-24](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/scripts/build.ts#L1-L24) [package.json#L30-55](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/package.json#L30-L55)
- External integrations are first-class runtime surface rather than libraries: Postgres/MySQL/SQLite (`src/sql/`), Valkey/Redis (`src/valkey/`), S3 with SigV4 signing (`src/s3_signing/`), and an npm registry client (`src/install/npm.rs`). — [src/sql/lib.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/sql/lib.rs) [src/valkey/valkey_protocol.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/valkey/valkey_protocol.rs) [src/s3_signing/credentials.rs#L1-50](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/s3_signing/credentials.rs#L1-L50) [src/install/npm.rs#L300-440](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/install/npm.rs#L300-L440)
- Persistence for the package manager is the lockfile subsystem under `src/install/lockfile/`, which supports both the text `bun.lock` and legacy binary `bun.lockb` formats plus migration from other package managers (`src/install/migration/`, `src/install/pnpm.rs`). — [src/install/lockfile/bun.lock.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/install/lockfile/bun.lock.rs) [src/install/lockfile/bun.lockb.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/install/lockfile/bun.lockb.rs) [src/install/pnpm.rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/src/install/pnpm.rs)
- CI is a programmatically generated Buildkite pipeline: `.buildkite/ci.ts` (1,997 lines) emits build steps, baked machine-image steps, and sharded test steps whose parallelism is platform-dependent (20 shards on Linux, 8 on Windows, 2 on macOS) with per-platform timeouts. — [.buildkite/ci.ts#L895-965](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/.buildkite/ci.ts#L895-L965) [.buildkite/ci.mjs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/.buildkite/ci.mjs)
- Twenty-five GitHub Actions workflows handle the non-Buildkite lanes — formatting, lint, Rust lints, source lints, bun-types tsc checks, FreeBSD smoke, release, docs deploy, and a family of automated vendor-bump workflows (`update-cares.yml`, `update-zstd.yml`, `update-libarchive.yml`, …). — [.github/workflows/format.yml](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/.github/workflows/format.yml) [.github/workflows/rust-lints.yml](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/.github/workflows/rust-lints.yml) [.github/workflows/bun-types.yml](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/.github/workflows/bun-types.yml) [.github/workflows/update-vendor.yml](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/.github/workflows/update-vendor.yml)
- Sibling deliverables ship from `packages/`: the public `bun-types` TypeScript declarations (the only npm workspace in the root `package.json`), a VS Code extension, a debug-adapter/inspector protocol pair, a Lambda layer, and native plugin APIs for Rust and C. — [package.json#L4-6](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/package.json#L4-L6) [packages/bun-types](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/packages/bun-types) [packages/bun-vscode](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/packages/bun-vscode) [packages/bun-native-plugin-rs](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/packages/bun-native-plugin-rs) [packages/bun-lambda](https://github.com/oven-sh/bun/blob/bf80d21c69c355f6e5bae2749485674663ed13a1/packages/bun-lambda)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
