TypeScript builders for real backends.
Services from a ServiceBuilder. Commands and subscriptions chained as typed builders. Schemas with Zod. Handler context with logger, resources, stores, emit and cross-service invocation — fully inferred end to end.
Every service has the same anatomy .
A service is a typed container of primitives: commands, subscriptions, streams, queues and AI agents. It declares owner, version and IAM. The event bridge handles routing. Adapters bind concrete infrastructure at boot — never imported in your code.
A command, built step by step .
Every command is a chain of typed calls — schemas, exposure, events it can emit, then the handler. Inference flows through the chain so payload and ctx are fully typed inside your function body.
- 01
Get the builder from the service
orderService.getCommandBuilder(name, description)— locked to that service's typed surface. - 02
Attach Zod schemas
addPayloadSchema,addParameterSchema,addOutputSchema. Validated at the boundary, inferred everywhere downstream. - 03
Declare exposure & events
exposeAsHttpEndpoint,canEmit,canInvoke— the framework auto-generates OpenAPI and gates cross-service calls. - 04
Wire the handler
setCommandFunction(async function (ctx, payload, parameter) {...}). Returns are validated against the output schema.
// 1. Build the commandexport const createOrderBuilder = orderService .getCommandBuilder('createOrder', 'Place a new order') .addPayloadSchema(createOrderInput) .addOutputSchema(orderConfirmed) .exposeAsHttpEndpoint('POST', 'orders') .canEmit('OrderPlaced', orderPlacedEvent) .setCommandFunction(async function (ctx, payload) { const id = await ctx.resources.db.insert('orders', payload) await ctx.emit('OrderPlaced', { id }) return { id, status: 'confirmed' } }) Inside the handler: everything typed .
The first argument to every handler is the context. It exposes logger, resources, secrets, configs, and states, emit, cross-service invocation, queue helpers, and OpenTelemetry spans — all inferred from your service definition.
Scoped logger with trace correlation.
ctx.logger.info(...) Typed dependencies declared on the service.
ctx.resources.db Secret · config · state. Provider-agnostic.
ctx.secrets.getSecret(...) Emit events; downstream subscriptions react.
ctx.emit(name, payload) Typed cross-service command invocation.
ctx.service.Profile['1'].create(...) Enqueue background jobs durably.
ctx.queue.enqueue(...) Wrap any block in an OpenTelemetry span.
ctx.wrapInSpan(name, fn) Trace ID, tenantId, principalId, headers.
ctx.message.principalId Listen, react, move on .
A subscription is a typed reaction to an event from another service. Same builder discipline as commands — but fire-and-forget. Filter by sender, principal or tenant; advise durability and acknowledgement.
// React to events emitted by other servicesexport const onPaid = orderService .getSubscriptionBuilder('onPaid', 'mark order paid') .subscribeToEvent('Payment', '1', 'PaymentMade') .addPayloadSchema(paymentMadeEvent) .setSubscriptionFunction(async function (ctx, payload) { await ctx.resources.db.markPaid(payload.orderId) ctx.logger.info('order paid', payload) }) Adapters at the edge. Never in your code .
First-party adapters for the infrastructure you already run. Implement the interface to add your own — the rest of your services never know the difference.
AI Harness
Sandbox and LLM adapters for safe AI integration with audit trails.
HTTP Server
Routes, middleware, CORS, and OpenAPI auto-generated from definitions.
Event Bridge
Pub/sub, message queues, and retry logic wired at runtime.
Secret Store
Vault, env vars, and rotation injected at bootstrap.
State Store
KV, blob storage, and caches bound by name, swappable by config.
Config Store
Runtime config with validation and environment-aware values.
Queue Bridge
Durable delivery with dead-letter support.
Temporal
Durable workflows for long-running business processes.
Dapr SDK
Native sidecar integration via Distributed Application Runtime.
Kubernetes SDK
K8s-native deployment with health probes and graceful shutdown.
Scaffold a service. Ship a system .
The Handbook walks you from a single command on an in-memory bridge to a multi-service deployment on the broker of your choice.