ObjectStackObjectStack

Introduction

The Core Microkernel of ObjectStack

ObjectStack Core

The @objectstack/core package is the Microkernel of the ObjectStack operating system. It provides the minimal runtime environment required to load plugins, manage dependencies, and orchestrate the system lifecycle.

Similar to how the Linux Kernel manages hardware drivers and processes, the ObjectStack Core manages Protocol Plugins and Services.

Why a Microkernel?

ObjectStack is designed to be:

  1. Modular: Every feature, including the API Server, Database Driver, and UI Engine, is a plugin.
  2. Extensible: You can replace any default component with your own implementation.
  3. Environment Agnostic: Runs on Node.js, Bun, Edge Runtimes (Cloudflare Workers), or even in the Browser (via Mock Service Worker).

Key Responsibilities

  1. Plugin Lifecycle Management: Loading, validating, initializing, and starting plugins in the correct dependency order.
  2. Dependency Injection (DI): A central registry for services to communicate without tight coupling.
  3. Event Bus: System-wide hook system for intercepting logic (e.g., data:beforeCreate, kernel:ready).
  4. Configuration Management: Standardized configuration loading using Zod validation.

Installation

pnpm add @objectstack/core

Basic Usage

import { ObjectKernel } from '@objectstack/core';

// 1. Create the Kernel
const kernel = new ObjectKernel({
    logger: { level: 'info' }
});

// 2. Register Plugins
kernel.use({
    name: 'my-custom-plugin',
    version: '1.0.0',
    async init(ctx) {
        ctx.logger.info('Initializing my plugin...');
    },
    async start(ctx) {
        ctx.logger.info('Plugin started!');
    }
});

// 3. Boot system
await kernel.bootstrap();

On this page