# ncsoft/unreal.js-core architecture

> Architecture diagram of the GitHub repository ncsoft/unreal.js-core, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ncsoft/unreal.js-core
- Repository: https://github.com/ncsoft/unreal.js-core

## Overview

##### Project Type and Purpose
- Recognize that this is a plugin for Unreal Engine, specifically designed to allow JavaScript scripting in an otherwise C++/Blueprint-based ecosystem.
- That its core functionality revolves around integrating V8 (Google’s JavaScript engine) with Unreal Engine to expose engine APIs to JavaScript, as well as provide various editor extensions and runtime modules (e.g., for UI, HTTP communications, WebSockets, etc.).

##### File Structure for Architectural Insights
- Top-level Directories:
- The “Content/Scripts” directory contains a variety of JavaScript files that appear to provide runtime and utility functions (polyfills, event handling, UMG integration, etc.).
- The “Source” directory is subdivided into several modules corresponding to different aspects of the integration:
- JavascriptConsole – for executing commands or scripts.
- JavascriptEditor – extending editor functionalities (asset editing, picking, custom UI elements, etc.).
- JavascriptGraphEditor – handling graph-based editing aspects (node editors, custom nodes, etc.).
- JavascriptHttp – for handling HTTP requests from JavaScript.
- JavascriptUMG – for integrating Unreal Motion Graphics (UMG) with JavaScript.
- JavascriptWebSocket – for real-time bi-directional communication.
- V8 – encapsulating the integration with the V8 engine itself.
- The “ThirdParty” directory holds the V8 third-party engine libraries and headers, emphasizing that integration with V8 is a central aspect.
- Build and configuration files (e.g., .uplugin, build scripts, and .ini configurations) indicate that the project is set up to work as an Unreal Engine plugin with modular builds.

##### Main Components and Their Relationships
- Unreal Engine Host Environment: The primary application that loads this plugin.
- Plugin Core:
- The UnrealJS.uplugin file serves as the entry point, which loads and ties together various modules.
- V8 Integration Layer:
- “Source/V8” along with ThirdParty/V8: Manages the bridge between Unreal Engine (C++) and V8 (JavaScript engine), handling context creation, script execution, and memory management.
- Module Extensions:
- Each of the “Javascript…” modules (Console, Editor, GraphEditor, Http, UMG, WebSocket) represents a different integration point or feature set. These modules expose engine features, provide custom UI components, or handle asynchronous operations for JavaScript.
- Content Scripts:
- Located in “Content/Scripts”, they likely contain additional JavaScript libraries, polyfills, and utility functions that support the core functionalities and extend the scripting API.
- Configuration and Build Tools:
- Folders like “Config” and “.github/workflows” indicate automated processes and configuration management for building, testing, or deploying the plugin.

##### Architectural Patterns and Design Principles
- Modular Separation: Each module (e.g., JavascriptConsole, JavascriptEditor) encapsulates a specific functionality, facilitating separation of concerns and easier maintenance.
- Plugin Architecture: The design leverages Unreal Engine’s plugin system to integrate seamlessly, suggesting that components are loosely coupled and extendable.
- Bridging Native and Managed Environments: The V8 integration is central, acting as the bridge between high-performance C++ native code and dynamic JavaScript code.
- Use of Abstraction Layers: Many modules have both public (API/interface) and private (implementation detail) directories, implying careful abstraction of functionality.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Host("Unreal Engine Host"):::host
    Plugin("Unreal.js Plugin (UnrealJS.uplugin)"):::plugin
    Host -->|"loadsPlugin"| Plugin

    subgraph "Plugin Modules"
        subgraph "V8 Integration Layer"
            V8S("V8: Source/V8"):::native
            V8TP("V8: ThirdParty/v8"):::native
            V8S -->|"integrates"| V8TP
        end
        Console("JavascriptConsole Module"):::module
        Editor("JavascriptEditor Module"):::module
        Graph("JavascriptGraphEditor Module"):::module
        Http("JavascriptHttp Module"):::module
        UMG("JavascriptUMG Module"):::module
        WS("JavascriptWebSocket Module"):::module
        Scripts("Content Scripts"):::scripts
    end

    Plugin -->|"initializes"| V8S
    Plugin -->|"loads"| Console
    Plugin -->|"loads"| Editor
    Plugin -->|"loads"| Graph
    Plugin -->|"loads"| Http
    Plugin -->|"loads"| UMG
    Plugin -->|"loads"| WS
    Plugin -->|"loads"| Scripts

    Console -->|"API_call"| V8S
    Editor -->|"API_call"| V8S
    Graph -->|"API_call"| V8S
    Http -->|"API_call"| V8S
    UMG -->|"API_call"| V8S
    WS -->|"API_call"| V8S
    Scripts -->|"executesScript"| V8S

    classDef host fill:#B3E5FC,stroke:#0277BD,stroke-width:2px;
    classDef plugin fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef native fill:#FFE0B2,stroke:#EF6C00,stroke-width:2px;
    classDef module fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
    classDef scripts fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;

    click Plugin "https://github.com/ncsoft/unreal.js-core/blob/master/UnrealJS.uplugin"
    click Scripts "https://github.com/ncsoft/unreal.js-core/tree/master/Content/Scripts"
    click V8S "https://github.com/ncsoft/unreal.js-core/tree/master/Source/V8"
    click V8TP "https://github.com/ncsoft/unreal.js-core/tree/master/ThirdParty/v8"
    click Console "https://github.com/ncsoft/unreal.js-core/tree/master/Source/JavascriptConsole"
    click Editor "https://github.com/ncsoft/unreal.js-core/tree/master/Source/JavascriptEditor"
    click Graph "https://github.com/ncsoft/unreal.js-core/tree/master/Source/JavascriptGraphEditor"
    click Http "https://github.com/ncsoft/unreal.js-core/tree/master/Source/JavascriptHttp"
    click UMG "https://github.com/ncsoft/unreal.js-core/tree/master/Source/JavascriptUMG"
    click WS "https://github.com/ncsoft/unreal.js-core/tree/master/Source/JavascriptWebSocket"
```
