@cnstra/core
v1.8.1
Published
Neural network-inspired event flow system for building reactive applications with dependency-injected neurons and synapses
Maintainers
Readme
@cnstra/core
Graph-routed, type-safe orchestration for reactive apps — no global event bus.
📚 Full Documentation → | Quick Start | API Reference | Recipes
What is CNStra?
CNStra (Central Nervous System Orchestrator) models your app as a typed neuron graph. You explicitly start a run with cns.stimulate(...); CNStra then performs a deterministic, hop-bounded traversal from collateral → dendrite → returned signal, step by step.
Zero dependencies • No pub/sub • CNS approach (Central Neural Network of your app)
👉 Read the full documentation →
Quick Start
npm install @cnstra/coreimport { CNS, collateral, neuron } from '@cnstra/core';
// Define collaterals (communication channels)
const userCreated = collateral<{ id: string; name: string }>('user:created');
const userRegistered = collateral<{ userId: string; status: string }>('user:registered');
// Create a neuron
const userService = neuron('user-service', {
userRegistered
})
.dendrite({
collateral: userCreated,
response: (payload, axon) => {
return axon.userRegistered.createSignal({
userId: payload.id,
status: 'completed'
});
}
});
// Create the CNS system
const cns = new CNS([userService]);
// Stimulate the system
const stimulation = cns.stimulate(userCreated.createSignal({
id: '123',
name: 'John Doe'
}));
await stimulation.waitUntilComplete();Documentation
- Quick Start Guide — Get up and running in minutes
- API Reference — Complete API documentation
- Concepts — Neurons, collaterals, signals, and the CNS model (Central Neural Network of your app)
- Recipes — Common patterns and use cases
- Advanced Topics — Performance, context stores, integrations
CNStra provides deterministic, type-safe orchestration without the complexity of traditional event systems.
