# facebook/hermes architecture

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

- Interactive diagram: https://gitdiagram.com/facebook/hermes
- Repository: https://github.com/facebook/hermes

## Overview

Hermes is a JavaScript engine optimized for React Native startup, combining ahead-of-time compilation and compact bytecode with a runtime that executes JavaScript. Its main user-to-result workflow is source compilation into optimized bytecode, followed by execution in an embedding application. The repository also exposes embedding APIs, debugging and profiling facilities, extensions, and alternate runtime interfaces. The README documents the high-level workflow; sampled source and the source index support selected internal relationships, while unsampled subsystems are represented without asserting unverified calls.

Main entry points: [`API/hermes/hermes.cpp`](https://github.com/facebook/hermes/blob/static_h/API/hermes/hermes.cpp) (Hermes VM), [`lib/BCGen/HBC/LoweringPipelines.cpp`](https://github.com/facebook/hermes/blob/static_h/lib/BCGen/HBC/LoweringPipelines.cpp) (Bytecode generation), [`lib/Parser/JSParserImpl.cpp`](https://github.com/facebook/hermes/blob/static_h/lib/Parser/JSParserImpl.cpp) (Parser and diagnostics), [`lib/Optimizer/PassManager/Pipeline.cpp`](https://github.com/facebook/hermes/blob/static_h/lib/Optimizer/PassManager/Pipeline.cpp) (IR optimizer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_compiler["Compilation"]
  node_parser["Parser and diagnostics<br/>[JSParserImpl.cpp]"]
  node_optimizer["IR optimizer<br/>[Pipeline.cpp]"]
  node_bytecode["Bytecode generation"]
  node_strings["String packing"]
end

subgraph group_runtime["Execution runtime"]
  node_runtime["Hermes VM<br/>[hermes.cpp]"]
  node_arraystorage["Array storage<br/>[ArrayStorage.cpp]"]
  node_heap[("Heap storage provider")]
end

subgraph group_interfaces["Embedding interfaces"]
  node_jsi["JSI interface<br/>[jsi.cpp]"]
  node_napi["Node API<br/>[hermes_napi.cpp]"]
  node_abi["C ABI wrapper"]
  node_sandbox["Sandbox runtime"]
end

subgraph group_inspection["Debugging and tracing"]
  node_inspector["Inspector protocol<br/>[CDPAgent.cpp]"]
  node_debugger["Debugger API<br/>[DebuggerAPI.cpp]"]
  node_trace["Tracing runtime<br/>[TracingRuntime.cpp]"]
end

subgraph group_extensions["Runtime extensions"]
  node_extensions["Core extensions<br/>[Extensions.cpp]"]
  node_contrib["Contributed extensions"]
end

node_developer(("Application developer"))
node_source["JavaScript source"]
node_host(("Embedding application"))
node_bytecode_result["Compact bytecode"]
node_execution_result["JavaScript result"]

node_developer -->|"provides source"| node_source
node_source -.->|"parses"| node_parser
node_parser -.->|"produces IR"| node_optimizer
node_optimizer -.->|"lowers"| node_bytecode
node_bytecode -->|"packs strings"| node_strings
node_bytecode -->|"emits"| node_bytecode_result
node_host -->|"runs bytecode"| node_runtime
node_runtime -->|"executes"| node_execution_result
node_runtime -->|"uses storage"| node_arraystorage
node_arraystorage -.->|"allocates from"| node_heap
node_host -.->|"embeds through"| node_jsi
node_host -.->|"embeds through"| node_napi
node_host -.->|"embeds through"| node_abi
node_host -.->|"runs isolated"| node_sandbox
node_host -.->|"inspects runtime"| node_inspector
node_inspector -.->|"controls debugging"| node_debugger
node_host -.->|"enables tracing"| node_trace
node_runtime -.->|"registers extensions"| node_extensions
node_runtime -.->|"registers extensions"| node_contrib

click node_parser "https://github.com/facebook/hermes/blob/static_h/lib/Parser/JSParserImpl.cpp"
click node_optimizer "https://github.com/facebook/hermes/blob/static_h/lib/Optimizer/PassManager/Pipeline.cpp"
click node_bytecode "https://github.com/facebook/hermes/blob/static_h/lib/BCGen/HBC/LoweringPipelines.cpp"
click node_strings "https://github.com/facebook/hermes/blob/static_h/lib/BCGen/HBC/ConsecutiveStringStorage.cpp"
click node_runtime "https://github.com/facebook/hermes/blob/static_h/API/hermes/hermes.cpp"
click node_arraystorage "https://github.com/facebook/hermes/blob/static_h/lib/VM/ArrayStorage.cpp"
click node_heap "https://github.com/facebook/hermes/blob/static_h/lib/VM/StorageProvider.cpp"
click node_jsi "https://github.com/facebook/hermes/blob/static_h/API/jsi/jsi/jsi.cpp"
click node_napi "https://github.com/facebook/hermes/blob/static_h/API/napi/hermes_napi.cpp"
click node_abi "https://github.com/facebook/hermes/blob/static_h/API/hermes_abi/HermesABIRuntimeWrapper.cpp"
click node_sandbox "https://github.com/facebook/hermes/blob/static_h/API/hermes_sandbox/HermesSandboxRuntime.cpp"
click node_inspector "https://github.com/facebook/hermes/blob/static_h/API/hermes/cdp/CDPAgent.cpp"
click node_debugger "https://github.com/facebook/hermes/blob/static_h/API/hermes/DebuggerAPI.cpp"
click node_trace "https://github.com/facebook/hermes/blob/static_h/API/hermes/TracingRuntime.cpp"
click node_extensions "https://github.com/facebook/hermes/blob/static_h/API/hermes/extensions/Extensions.cpp"
click node_contrib "https://github.com/facebook/hermes/blob/static_h/API/hermes/extensions/contrib/ContribExtensions.cpp"

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_parser,node_optimizer,node_bytecode,node_strings toneBlue
class node_runtime,node_arraystorage,node_heap toneAmber
class node_jsi,node_napi,node_abi,node_sandbox toneMint
class node_inspector,node_debugger,node_trace toneRose
class node_extensions,node_contrib,node_developer,node_source,node_host,node_bytecode_result,node_execution_result toneIndigo
```

## Components

### Compilation

- [Parser and diagnostics](https://github.com/facebook/hermes/blob/static_h/lib/Parser/JSParserImpl.cpp): `lib/Parser/JSParserImpl.cpp`
- [IR optimizer](https://github.com/facebook/hermes/blob/static_h/lib/Optimizer/PassManager/Pipeline.cpp): `lib/Optimizer/PassManager/Pipeline.cpp`
- [Bytecode generation](https://github.com/facebook/hermes/blob/static_h/lib/BCGen/HBC/LoweringPipelines.cpp): `lib/BCGen/HBC/LoweringPipelines.cpp`
- [String packing](https://github.com/facebook/hermes/blob/static_h/lib/BCGen/HBC/ConsecutiveStringStorage.cpp): `lib/BCGen/HBC/ConsecutiveStringStorage.cpp`

### Execution runtime

- [Hermes VM](https://github.com/facebook/hermes/blob/static_h/API/hermes/hermes.cpp): `API/hermes/hermes.cpp`
- [Array storage](https://github.com/facebook/hermes/blob/static_h/lib/VM/ArrayStorage.cpp): `lib/VM/ArrayStorage.cpp`
- [Heap storage provider](https://github.com/facebook/hermes/blob/static_h/lib/VM/StorageProvider.cpp): `lib/VM/StorageProvider.cpp`

### Embedding interfaces

- [JSI interface](https://github.com/facebook/hermes/blob/static_h/API/jsi/jsi/jsi.cpp): `API/jsi/jsi/jsi.cpp`
- [Node API](https://github.com/facebook/hermes/blob/static_h/API/napi/hermes_napi.cpp): `API/napi/hermes_napi.cpp`
- [C ABI wrapper](https://github.com/facebook/hermes/blob/static_h/API/hermes_abi/HermesABIRuntimeWrapper.cpp): `API/hermes_abi/HermesABIRuntimeWrapper.cpp`
- [Sandbox runtime](https://github.com/facebook/hermes/blob/static_h/API/hermes_sandbox/HermesSandboxRuntime.cpp): `API/hermes_sandbox/HermesSandboxRuntime.cpp`

### Debugging and tracing

- [Inspector protocol](https://github.com/facebook/hermes/blob/static_h/API/hermes/cdp/CDPAgent.cpp): `API/hermes/cdp/CDPAgent.cpp`
- [Debugger API](https://github.com/facebook/hermes/blob/static_h/API/hermes/DebuggerAPI.cpp): `API/hermes/DebuggerAPI.cpp`
- [Tracing runtime](https://github.com/facebook/hermes/blob/static_h/API/hermes/TracingRuntime.cpp): `API/hermes/TracingRuntime.cpp`

### Runtime extensions

- [Core extensions](https://github.com/facebook/hermes/blob/static_h/API/hermes/extensions/Extensions.cpp): `API/hermes/extensions/Extensions.cpp`
- [Contributed extensions](https://github.com/facebook/hermes/blob/static_h/API/hermes/extensions/contrib/ContribExtensions.cpp): `API/hermes/extensions/contrib/ContribExtensions.cpp`

### Other components

- **Application developer**
- **JavaScript source**
- **Embedding application**
- **Compact bytecode**
- **JavaScript result**

## Connections

- Application developer → JavaScript source: provides source (evidence: `README.md`)
- JavaScript source → Parser and diagnostics: parses
- Parser and diagnostics → IR optimizer: produces IR
- IR optimizer → Bytecode generation: lowers
- Bytecode generation → String packing: packs strings (evidence: `lib/BCGen/HBC/ConsecutiveStringStorage.cpp`)
- Bytecode generation → Compact bytecode: emits (evidence: `README.md`)
- Embedding application → Hermes VM: runs bytecode (evidence: `README.md`)
- Hermes VM → JavaScript result: executes (evidence: `README.md`)
- Hermes VM → Array storage: uses storage
- Array storage → Heap storage provider: allocates from
- Embedding application → JSI interface: embeds through
- Embedding application → Node API: embeds through
- Embedding application → C ABI wrapper: embeds through
- Embedding application → Sandbox runtime: runs isolated
- Embedding application → Inspector protocol: inspects runtime
- Inspector protocol → Debugger API: controls debugging
- Embedding application → Tracing runtime: enables tracing
- Hermes VM → Core extensions: registers extensions
- Hermes VM → Contributed extensions: registers extensions
