Headless Execution

← Lifecycle
STRVCT

Running STRVCT applications natively in Node.js without DOM or browser dependencies.

Overview

STRVCT's domain model layer, persistence engine, and boot sequence execute natively in Node.js. The same application domain classes that run in the browser run headlessly under Node.js—with identical storage behavior, slot metadata annotations, and object lifecycles—just without DOM or view classes.

This enables ultra-fast unit/integration testing, server-side processing, batch simulations, and CLI tools.

Shared Domain Model SvStorableNode subclasses Environment Filtering server-only / browser-only LevelDB Storage Backend classic-level via SvIndexedDbFolder Model code holds zero DOM references; views observe the model, but the model is completely unaware of views.

Environment Detection (`SvPlatform`)

// Environment checks
if (SvPlatform.isNodePlatform()) {
    // Node.js specific code
} else if (SvPlatform.isBrowserPlatform()) {
    // Browser specific code
}

Directory Filtering Conventions (`browser-only` & `server-only`)

During boot resource discovery, StrvctFile.canUseInCurrentEnv() inspects path segments:

  • In Node.js: Files in browser-only/ paths are skipped.
  • In Browser: Files in server-only/ paths are skipped.

The Same-Name Class Pattern:

This convention provides environment-specific implementations of the exact same class interface:

source/boot/browser-only/SvIndexedDbFolder.js   # Uses native IndexedDB
source/boot/server-only/SvIndexedDbFolder.js     # Uses LevelDB via classic-level

Browser API Shims for Node.js (`server-only`)

In source/library/ideal/categories/server-only/:

Shim FileBrowser API PolyfilledNode.js Implementation
XMLHttpRequestShim.jsXMLHttpRequestWraps xhr2 package
FileReaderShim.jsFileReaderReads ArrayBuffer and text from Blobs
ImageShim.jsImage, HTMLCanvasElementWraps canvas package
FontFaceShim.jsFontFaceStub accepting font declarations

Storage Engine Parity

Storage works identically in both environments through SvIndexedDbFolder:

  • Browser: Writes to native IndexedDB.
  • Node.js: Writes to LevelDB (classic-level) in ./data/leveldb/.