Getting Started
Docs Getting started

Quick Start

One store holds meaning, connections, and facts — and every query can use all three at once.

In this section

One store holds meaning, connections, and facts — and every query can use all three at once.

import { Brainy, NounType, VerbType } from '@soulcraft/brainy'

const brain = new Brainy({ storage: { type: 'filesystem', path: './data' } })
await brain.init()

// Write: the engine embeds on your machine — text in, meaning out,
// nothing leaves the box.
const note = await brain.add({
  type: NounType.Concept,
  data: 'Brainy keeps meaning, connections and facts in one store',
  metadata: { topic: 'databases', status: 'active' },
})
const author = await brain.add({
  type: NounType.Person,
  data: 'The author of that note',
  metadata: { name: 'sam' },
})

// Connect: each saved thing knows what it touches.
await brain.relate({ from: author, to: note, type: VerbType.Created })

// Ask three ways at once — by meaning, by connection, by fact:
const results = await brain.find({
  query: 'databases that unify search',     // meaning (semantic)
  where: { status: 'active' },              // fact (metadata)
  limit: 10,
})TYPESCRIPT

Skip the embedding when you mean to

Telemetry rows, counters, sessions — things nobody will semantic-search — write with an explicit empty vector and cost the vector index nothing:

await brain.add({ type: NounType.Document, data: 'raw event', metadata: { kind: 'event' }, vector: [] })TYPESCRIPT

Time travel

Every change is a generation in the log; any past moment reopens exactly as it was:

const then = await brain.asOf(yesterdayTimestamp)
const whatWeKnew = await then.find({ query: 'databases' })TYPESCRIPT

Where to go next