# wasmerio/edgejs architecture

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

- Interactive diagram: https://gitdiagram.com/wasmerio/edgejs
- Repository: https://github.com/wasmerio/edgejs

## Overview

Edge.js is a Node.js-compatible JavaScript runtime aimed at secure edge and AI workloads. The main workflow is to launch a program or wrap a package-manager command, execute JavaScript through a selectable engine, and expose Node-compatible APIs; safe mode adds WebAssembly sandboxing. The README also documents an experimental host-engine WASIX mode using N-API imports. The supplied tree and excerpts show only a few runtime internals and vendored components, so several documented subsystems have no confidently identifiable implementation path here.

Main entry points: [`lib/internal/webstorage.js`](https://github.com/wasmerio/edgejs/blob/main/lib/internal/webstorage.js) (Web Storage), [`deps/v8`](https://github.com/wasmerio/edgejs/tree/main/deps/v8) (V8 engine), [`deps/v8/src/wasm/wasm-engine.cc`](https://github.com/wasmerio/edgejs/blob/main/deps/v8/src/wasm/wasm-engine.cc) (Wasm sandbox), [`lib/internal/streams/pipeline.js`](https://github.com/wasmerio/edgejs/blob/main/lib/internal/streams/pipeline.js) (Stream pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime execution"]
  node_cli["Edge CLI"]
  node_runtime_core["Runtime core"]
  node_napi["N-API layer"]
end

subgraph group_security["Engine and security"]
  node_v8["V8 engine"]
  node_quickjs["QuickJS engine"]
  node_jsc["JavaScriptCore"]
  node_wasm["Wasm sandbox<br/>[wasm-engine.cc]"]
end

subgraph group_apis["Runtime APIs"]
  node_node_compat["Node compatibility"]
  node_streams["Stream pipeline<br/>[pipeline.js]"]
  node_webstorage["Web Storage<br/>[webstorage.js]"]
  node_network["Networking"]
  node_crypto["Crypto engines<br/>[engine.cc]"]
end

subgraph group_integrations["External integrations"]
  node_package_tools["Package commands"]
  node_host_engine["Host JavaScript engine"]
  node_storage_file[("Storage file")]
end

node_user(("User"))

node_user -->|"launches"| node_cli
node_cli -->|"starts"| node_runtime_core
node_cli -->|"wraps commands"| node_package_tools
node_package_tools -->|"returns result"| node_user
node_runtime_core -->|"exposes APIs"| node_napi
node_napi -.->|"executes on"| node_v8
node_napi -.->|"executes on"| node_quickjs
node_napi -.->|"executes on"| node_jsc
node_runtime_core -.->|"sandboxes in safe mode"| node_wasm
node_runtime_core -.->|"imports host N-API"| node_host_engine
node_runtime_core -->|"provides compatibility"| node_node_compat
node_node_compat -->|"includes pipeline"| node_streams
node_node_compat -->|"includes storage API"| node_webstorage
node_node_compat -->|"includes DNS support"| node_network
node_node_compat -->|"includes crypto support"| node_crypto
node_webstorage -->|"uses configured file"| node_storage_file

click node_v8 "https://github.com/wasmerio/edgejs/tree/main/deps/v8"
click node_wasm "https://github.com/wasmerio/edgejs/blob/main/deps/v8/src/wasm/wasm-engine.cc"
click node_streams "https://github.com/wasmerio/edgejs/blob/main/lib/internal/streams/pipeline.js"
click node_webstorage "https://github.com/wasmerio/edgejs/blob/main/lib/internal/webstorage.js"
click node_network "https://github.com/wasmerio/edgejs/tree/main/deps/cares/src/lib"
click node_crypto "https://github.com/wasmerio/edgejs/blob/main/deps/ncrypto/engine.cc"

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_runtime_core,node_napi,node_user toneBlue
class node_v8,node_quickjs,node_jsc,node_wasm toneAmber
class node_node_compat,node_streams,node_webstorage,node_network,node_crypto toneMint
class node_package_tools,node_host_engine,node_storage_file toneRose
```

## Components

### Runtime execution

- **Edge CLI**
- **Runtime core**
- **N-API layer**

### Engine and security

- [V8 engine](https://github.com/wasmerio/edgejs/tree/main/deps/v8): `deps/v8`
- **QuickJS engine**
- **JavaScriptCore**
- [Wasm sandbox](https://github.com/wasmerio/edgejs/blob/main/deps/v8/src/wasm/wasm-engine.cc): `deps/v8/src/wasm/wasm-engine.cc`

### Runtime APIs

- **Node compatibility**
- [Stream pipeline](https://github.com/wasmerio/edgejs/blob/main/lib/internal/streams/pipeline.js): `lib/internal/streams/pipeline.js`
- [Web Storage](https://github.com/wasmerio/edgejs/blob/main/lib/internal/webstorage.js): `lib/internal/webstorage.js`
- [Networking](https://github.com/wasmerio/edgejs/tree/main/deps/cares/src/lib): `deps/cares/src/lib`
- [Crypto engines](https://github.com/wasmerio/edgejs/blob/main/deps/ncrypto/engine.cc): `deps/ncrypto/engine.cc`

### External integrations

- **Package commands**
- **Host JavaScript engine**
- **Storage file**

### Other components

- **User**

## Connections

- User → Edge CLI: launches
- Edge CLI → Runtime core: starts
- Edge CLI → Package commands: wraps commands
- Package commands → User: returns result
- Runtime core → N-API layer: exposes APIs
- N-API layer → V8 engine: executes on
- N-API layer → QuickJS engine: executes on
- N-API layer → JavaScriptCore: executes on
- Runtime core → Wasm sandbox: sandboxes in safe mode
- Runtime core → Host JavaScript engine: imports host N-API
- Runtime core → Node compatibility: provides compatibility
- Node compatibility → Stream pipeline: includes pipeline
- Node compatibility → Web Storage: includes storage API
- Node compatibility → Networking: includes DNS support
- Node compatibility → Crypto engines: includes crypto support
- Web Storage → Storage file: uses configured file
