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:
- Modular: Every feature, including the API Server, Database Driver, and UI Engine, is a plugin.
- Extensible: You can replace any default component with your own implementation.
- Environment Agnostic: Runs on Node.js, Bun, Edge Runtimes (Cloudflare Workers), or even in the Browser (via Mock Service Worker).
Key Responsibilities
- Plugin Lifecycle Management: Loading, validating, initializing, and starting plugins in the correct dependency order.
- Dependency Injection (DI): A central registry for services to communicate without tight coupling.
- Event Bus: System-wide hook system for intercepting logic (e.g.,
data:beforeCreate,kernel:ready). - Configuration Management: Standardized configuration loading using Zod validation.
Installation
pnpm add @objectstack/coreBasic 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();