2025-08-26 12:32:21 -07:00
|
|
|
|
# Brainy
|
|
|
|
|
|
|
|
|
|
|
|
<p align="center">
|
2025-08-26 13:48:09 -07:00
|
|
|
|
<img src="https://raw.githubusercontent.com/soulcraftlabs/brainy/main/brainy.png" alt="Brainy Logo" width="200">
|
2025-08-26 12:32:21 -07:00
|
|
|
|
</p>
|
|
|
|
|
|
|
2025-08-26 13:48:09 -07:00
|
|
|
|
[](https://www.npmjs.com/package/@soulcraft/brainy)
|
|
|
|
|
|
[](https://www.npmjs.com/package/@soulcraft/brainy)
|
2025-08-26 12:32:21 -07:00
|
|
|
|
[](LICENSE)
|
|
|
|
|
|
[](https://www.typescriptlang.org/)
|
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
**🧠 Brainy 3.0 - Planet-Scale Universal Knowledge Protocol™**
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
**World's first Triple Intelligence™ database**—now with true distributed scaling, enterprise features, and
|
|
|
|
|
|
production-ready performance. Unifying vector similarity, graph relationships, and document filtering in one magical
|
|
|
|
|
|
API. Model ANY data from ANY domain using 31 standardized noun types × 40 verb types.
|
2025-08-27 09:27:12 -07:00
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
**Why Brainy Leads**: We're the first to solve the impossible—combining three different database paradigms (vector,
|
|
|
|
|
|
graph, document) into one unified query interface, now with horizontal scaling across multiple nodes. This breakthrough
|
|
|
|
|
|
enables us to be the Universal Knowledge Protocol where all tools, augmentations, and AI models speak the same language
|
|
|
|
|
|
at enterprise scale.
|
2025-08-27 09:27:12 -07:00
|
|
|
|
|
2025-09-08 14:28:22 -07:00
|
|
|
|
**Build once, integrate everywhere.** O(log n) performance, <10ms search latency, distributed across unlimited nodes.
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-09-08 14:28:22 -07:00
|
|
|
|
## 🎉 What's New in 3.0
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
### 🌐 **Zero-Config Distributed System** (Industry First!)
|
|
|
|
|
|
|
|
|
|
|
|
- **Storage-Based Coordination**: No Consul/etcd/Zookeeper needed - uses your S3/GCS!
|
|
|
|
|
|
- **Automatic Node Discovery**: Nodes find each other via storage
|
|
|
|
|
|
- **Intelligent Sharding**: Domain-aware data placement for optimal queries
|
|
|
|
|
|
- **Live Shard Migration**: Zero-downtime data movement with streaming
|
|
|
|
|
|
- **Auto-Rebalancing**: Handles node joins/leaves automatically
|
|
|
|
|
|
|
|
|
|
|
|
### 🏢 **Enterprise Features**
|
|
|
|
|
|
|
|
|
|
|
|
- **Distributed Scaling**: Horizontal sharding across unlimited nodes
|
|
|
|
|
|
- **Read/Write Separation**: Optimized nodes for different workloads
|
|
|
|
|
|
- **Multi-Tenancy**: Customer isolation with shared infrastructure
|
|
|
|
|
|
- **Rate Limiting & Audit**: Production-ready governance
|
|
|
|
|
|
- **Geographic Distribution**: Global nodes with local performance
|
|
|
|
|
|
|
|
|
|
|
|
### ⚡ **Performance Breakthroughs**
|
|
|
|
|
|
|
|
|
|
|
|
- **<10ms Search**: Even with 10K+ items per node
|
|
|
|
|
|
- **Linear Write Scaling**: Add nodes for more throughput
|
|
|
|
|
|
- **Smart Query Planning**: Routes queries to optimal shards
|
|
|
|
|
|
- **Streaming Ingestion**: Handle firehoses (Bluesky, Twitter, etc.)
|
|
|
|
|
|
- **100+ Concurrent Ops**: Production-tested at scale
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
## ⚡ Quick Start - Zero Configuration
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
```bash
|
2025-08-26 13:48:09 -07:00
|
|
|
|
npm install @soulcraft/brainy
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
### 🎯 **True Zero Configuration**
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
2025-09-11 16:23:32 -07:00
|
|
|
|
import {BrainyData} from '@soulcraft/brainy'
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
// Just this - auto-detects everything!
|
2025-08-26 12:32:21 -07:00
|
|
|
|
const brain = new BrainyData()
|
|
|
|
|
|
await brain.init()
|
|
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
// Add entities (nouns) with automatic embedding
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const jsId = await brain.addNoun("JavaScript is a programming language", 'concept', {
|
|
|
|
|
|
type: "language",
|
|
|
|
|
|
year: 1995,
|
|
|
|
|
|
paradigm: "multi-paradigm"
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const nodeId = await brain.addNoun("Node.js runtime environment", 'concept', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
type: "runtime",
|
|
|
|
|
|
year: 2009,
|
|
|
|
|
|
platform: "server-side"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
// Create relationships (verbs) between entities
|
|
|
|
|
|
await brain.addVerb(nodeId, jsId, "executes", {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
since: 2009,
|
|
|
|
|
|
performance: "high"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Natural language search with graph relationships
|
|
|
|
|
|
const results = await brain.find("programming languages used by server runtimes")
|
|
|
|
|
|
|
|
|
|
|
|
// Triple Intelligence: vector + metadata + relationships
|
|
|
|
|
|
const filtered = await brain.find({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
like: "JavaScript", // Vector similarity
|
|
|
|
|
|
where: {type: "language"}, // Metadata filtering
|
|
|
|
|
|
connected: {from: nodeId, depth: 1} // Graph relationships
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-28 16:05:14 -07:00
|
|
|
|
## 📋 System Requirements
|
|
|
|
|
|
|
|
|
|
|
|
**Node.js Version:** 22 LTS or later (recommended)
|
|
|
|
|
|
|
|
|
|
|
|
- ✅ **Node.js 22 LTS** - Fully supported and recommended for production
|
|
|
|
|
|
- ✅ **Node.js 20 LTS** - Compatible (maintenance mode)
|
|
|
|
|
|
- ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
|
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
> **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause
|
|
|
|
|
|
> crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
|
2025-08-28 16:05:14 -07:00
|
|
|
|
|
|
|
|
|
|
If using nvm: `nvm use` (we provide a `.nvmrc` file)
|
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
## 🚀 Key Features
|
|
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
### World's First Triple Intelligence™ Engine
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
**The breakthrough that enables the Universal Knowledge Protocol:**
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
- **Vector Search**: Semantic similarity with HNSW indexing
|
2025-08-27 09:27:12 -07:00
|
|
|
|
- **Graph Relationships**: Navigate connected knowledge like Neo4j
|
|
|
|
|
|
- **Document Filtering**: MongoDB-style queries with O(log n) performance
|
|
|
|
|
|
- **Unified in ONE API**: No separate queries, no complex joins
|
|
|
|
|
|
- **First to solve this**: Others do vector OR graph OR document—we do ALL
|
|
|
|
|
|
|
|
|
|
|
|
### Universal Knowledge Protocol with Infinite Expressiveness
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
**Enabled by Triple Intelligence, standardized for everyone:**
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
- **24 Noun Types × 40 Verb Types**: 960 base combinations
|
|
|
|
|
|
- **∞ Expressiveness**: Unlimited metadata = model ANY data
|
|
|
|
|
|
- **One Language**: All tools, augmentations, AI models speak the same types
|
|
|
|
|
|
- **Perfect Interoperability**: Move data between any Brainy instance
|
|
|
|
|
|
- **No Schema Lock-in**: Evolve without migrations
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
### Natural Language Understanding
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
|
|
|
|
|
// Ask questions naturally
|
|
|
|
|
|
await brain.find("Show me recent React components with tests")
|
|
|
|
|
|
await brain.find("Popular JavaScript libraries similar to Vue")
|
|
|
|
|
|
await brain.find("Documentation about authentication from last month")
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
### 🎯 Zero Configuration Philosophy
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
Brainy 2.9+ automatically configures **everything**:
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
2025-09-11 16:23:32 -07:00
|
|
|
|
import {BrainyData, PresetName} from '@soulcraft/brainy'
|
2025-08-29 15:39:07 -07:00
|
|
|
|
|
|
|
|
|
|
// 1. Pure zero-config - detects everything
|
|
|
|
|
|
const brain = new BrainyData()
|
|
|
|
|
|
|
|
|
|
|
|
// 2. Environment presets (strongly typed)
|
|
|
|
|
|
const devBrain = new BrainyData(PresetName.DEVELOPMENT) // Memory + verbose
|
|
|
|
|
|
const prodBrain = new BrainyData(PresetName.PRODUCTION) // Disk + optimized
|
|
|
|
|
|
const miniBrain = new BrainyData(PresetName.MINIMAL) // Q8 + minimal features
|
|
|
|
|
|
|
|
|
|
|
|
// 3. Distributed architecture presets
|
|
|
|
|
|
const writer = new BrainyData(PresetName.WRITER) // Write-only instance
|
|
|
|
|
|
const reader = new BrainyData(PresetName.READER) // Read-only + caching
|
|
|
|
|
|
const ingestion = new BrainyData(PresetName.INGESTION_SERVICE) // High-throughput
|
|
|
|
|
|
const searchAPI = new BrainyData(PresetName.SEARCH_API) // Low-latency search
|
|
|
|
|
|
|
|
|
|
|
|
// 4. Custom zero-config (type-safe)
|
|
|
|
|
|
const customBrain = new BrainyData({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
mode: 'production',
|
|
|
|
|
|
model: 'q8', // Optimized model (99% accuracy, 75% smaller)
|
|
|
|
|
|
storage: 'cloud', // or 'memory', 'disk', 'auto'
|
|
|
|
|
|
features: ['core', 'search', 'cache']
|
2025-08-29 15:39:07 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
**What's Auto-Detected:**
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
- **Storage**: S3/GCS/R2 → Filesystem → Memory (priority order)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
- **Models**: Always Q8 for optimal balance
|
2025-08-29 15:39:07 -07:00
|
|
|
|
- **Features**: Minimal → Default → Full based on environment
|
|
|
|
|
|
- **Memory**: Optimal cache sizes and batching
|
|
|
|
|
|
- **Performance**: Threading, chunking, indexing strategies
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
### Production Performance
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
- **3ms average search** - Lightning fast queries
|
|
|
|
|
|
- **24MB memory footprint** - Efficient resource usage
|
|
|
|
|
|
- **Worker-based embeddings** - Non-blocking operations
|
|
|
|
|
|
- **Automatic caching** - Intelligent result caching
|
|
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
### 🎛️ Advanced Configuration (When Needed)
|
2025-08-29 11:09:40 -07:00
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
Most users **never need this** - zero-config handles everything. For advanced use cases:
|
2025-08-29 11:09:40 -07:00
|
|
|
|
|
|
|
|
|
|
```javascript
|
2025-09-11 16:23:32 -07:00
|
|
|
|
// Model is always Q8 for optimal performance
|
|
|
|
|
|
const brain = new BrainyData() // Uses Q8 automatically
|
2025-08-29 15:39:07 -07:00
|
|
|
|
|
|
|
|
|
|
// Storage control (auto-detected by default)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const memoryBrain = new BrainyData({storage: 'memory'}) // RAM only
|
|
|
|
|
|
const diskBrain = new BrainyData({storage: 'disk'}) // Local filesystem
|
|
|
|
|
|
const cloudBrain = new BrainyData({storage: 'cloud'}) // S3/GCS/R2
|
2025-08-29 11:09:40 -07:00
|
|
|
|
|
2025-08-29 15:39:07 -07:00
|
|
|
|
// Legacy full config (still supported)
|
|
|
|
|
|
const legacyBrain = new BrainyData({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
storage: {forceMemoryStorage: true}
|
2025-08-29 11:09:40 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
**Model Details:**
|
2025-08-29 11:09:40 -07:00
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
- **Q8**: 33MB, 99% accuracy, 75% smaller than full precision
|
|
|
|
|
|
- Fast loading and optimal memory usage
|
|
|
|
|
|
- Perfect for all environments
|
2025-08-29 11:09:40 -07:00
|
|
|
|
|
|
|
|
|
|
**Air-gap deployment:**
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-29 11:09:40 -07:00
|
|
|
|
```bash
|
2025-09-11 16:23:32 -07:00
|
|
|
|
npm run download-models # Download Q8 model
|
|
|
|
|
|
npm run download-models:q8 # Download Q8 model
|
2025-08-29 11:09:40 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
## 📚 Core API
|
|
|
|
|
|
|
|
|
|
|
|
### `search()` - Vector Similarity
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
|
|
|
|
|
const results = await brain.search("machine learning", {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
limit: 10, // Number of results
|
|
|
|
|
|
metadata: {type: "article"}, // Filter by metadata
|
|
|
|
|
|
includeContent: true // Include full content
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### `find()` - Natural Language Queries
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
|
|
|
|
|
// Simple natural language
|
|
|
|
|
|
const results = await brain.find("recent important documents")
|
|
|
|
|
|
|
|
|
|
|
|
// Structured query with Triple Intelligence
|
|
|
|
|
|
const results = await brain.find({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
like: "JavaScript", // Vector similarity
|
|
|
|
|
|
where: { // Metadata filters
|
|
|
|
|
|
year: {greaterThan: 2020},
|
|
|
|
|
|
important: true
|
|
|
|
|
|
},
|
|
|
|
|
|
related: {to: "React"} // Graph relationships
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### CRUD Operations
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
2025-08-27 09:27:12 -07:00
|
|
|
|
// Create entities (nouns)
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const id = await brain.addNoun(data, nounType, metadata)
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
// Create relationships (verbs)
|
|
|
|
|
|
const verbId = await brain.addVerb(sourceId, targetId, "relationType", {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
strength: 0.9,
|
|
|
|
|
|
bidirectional: false
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
// Read
|
|
|
|
|
|
const item = await brain.getNoun(id)
|
2025-08-27 09:27:12 -07:00
|
|
|
|
const verb = await brain.getVerb(verbId)
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
// Update
|
|
|
|
|
|
await brain.updateNoun(id, newData, newMetadata)
|
2025-08-27 09:27:12 -07:00
|
|
|
|
await brain.updateVerb(verbId, newMetadata)
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
// Delete
|
|
|
|
|
|
await brain.deleteNoun(id)
|
2025-08-27 09:27:12 -07:00
|
|
|
|
await brain.deleteVerb(verbId)
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
// Bulk operations
|
|
|
|
|
|
await brain.import(arrayOfData)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const exported = await brain.export({format: 'json'})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 🌐 Distributed System (NEW!)
|
|
|
|
|
|
|
|
|
|
|
|
### Zero-Config Distributed Setup
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
// Single node (default)
|
|
|
|
|
|
const brain = new BrainyData({
|
|
|
|
|
|
storage: {type: 's3', options: {bucket: 'my-data'}}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Distributed cluster - just add one flag!
|
|
|
|
|
|
const brain = new BrainyData({
|
|
|
|
|
|
storage: {type: 's3', options: {bucket: 'my-data'}},
|
|
|
|
|
|
distributed: true // That's it! Everything else is automatic
|
|
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### How It Works
|
|
|
|
|
|
|
|
|
|
|
|
- **Storage-Based Discovery**: Nodes find each other via S3/GCS (no Consul/etcd!)
|
|
|
|
|
|
- **Automatic Sharding**: Data distributed by content hash
|
|
|
|
|
|
- **Smart Query Planning**: Queries routed to optimal shards
|
|
|
|
|
|
- **Live Rebalancing**: Handles node joins/leaves automatically
|
|
|
|
|
|
- **Zero Downtime**: Streaming shard migration
|
|
|
|
|
|
|
|
|
|
|
|
### Real-World Example: Social Media Firehose
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
// Ingestion nodes (optimized for writes)
|
|
|
|
|
|
const ingestionNode = new BrainyData({
|
|
|
|
|
|
storage: {type: 's3', options: {bucket: 'social-data'}},
|
|
|
|
|
|
distributed: true,
|
|
|
|
|
|
writeOnly: true // Optimized for high-throughput writes
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Process Bluesky firehose
|
|
|
|
|
|
blueskyStream.on('post', async (post) => {
|
|
|
|
|
|
await ingestionNode.addNoun(post, 'social-post', {
|
|
|
|
|
|
platform: 'bluesky',
|
|
|
|
|
|
author: post.author,
|
|
|
|
|
|
timestamp: post.createdAt
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Search nodes (optimized for queries)
|
|
|
|
|
|
const searchNode = new BrainyData({
|
|
|
|
|
|
storage: {type: 's3', options: {bucket: 'social-data'}},
|
|
|
|
|
|
distributed: true,
|
|
|
|
|
|
readOnly: true // Optimized for fast queries
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Search across ALL data from ALL nodes
|
|
|
|
|
|
const trending = await searchNode.find('trending AI topics', {
|
|
|
|
|
|
where: {timestamp: {greaterThan: Date.now() - 3600000}},
|
|
|
|
|
|
limit: 100
|
|
|
|
|
|
})
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
### Benefits Over Traditional Systems
|
|
|
|
|
|
|
|
|
|
|
|
| Feature | Traditional (Pinecone, Weaviate) | Brainy Distributed |
|
|
|
|
|
|
|----------------|----------------------------------|-------------------------------|
|
|
|
|
|
|
| Setup | Complex (k8s, operators) | One flag: `distributed: true` |
|
|
|
|
|
|
| Coordination | External (etcd, Consul) | Built-in (via storage) |
|
|
|
|
|
|
| Minimum Nodes | 3-5 for HA | 1 (scale as needed) |
|
|
|
|
|
|
| Sharding | Random | Domain-aware |
|
|
|
|
|
|
| Query Planning | Basic | Triple Intelligence |
|
|
|
|
|
|
| Cost | High (always-on clusters) | Low (scale to zero) |
|
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
## 🎯 Use Cases
|
|
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
### Knowledge Management with Relationships
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
2025-08-27 09:27:12 -07:00
|
|
|
|
// Store documentation with rich relationships
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const apiGuide = await brain.addNoun("REST API Guide", 'document', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
title: "API Guide",
|
|
|
|
|
|
category: "documentation",
|
|
|
|
|
|
version: "2.0"
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const author = await brain.addNoun("Jane Developer", 'person', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
type: "person",
|
|
|
|
|
|
role: "tech-lead"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const project = await brain.addNoun("E-commerce Platform", 'project', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
type: "project",
|
|
|
|
|
|
status: "active"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Create knowledge graph
|
2025-09-11 16:23:32 -07:00
|
|
|
|
await brain.addVerb(author, apiGuide, "authored", {
|
|
|
|
|
|
date: "2024-03-15"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
2025-09-11 16:23:32 -07:00
|
|
|
|
await brain.addVerb(apiGuide, project, "documents", {
|
|
|
|
|
|
coverage: "complete"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Query the knowledge graph naturally
|
|
|
|
|
|
const docs = await brain.find("documentation authored by tech leads for active projects")
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Semantic Search
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
|
|
|
|
|
// Find similar content
|
|
|
|
|
|
const similar = await brain.search(existingContent, {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
limit: 5,
|
|
|
|
|
|
threshold: 0.8
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
### AI Memory Layer with Context
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```javascript
|
2025-08-27 09:27:12 -07:00
|
|
|
|
// Store conversation with relationships
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const userId = await brain.addNoun("User 123", 'user', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
type: "user",
|
|
|
|
|
|
tier: "premium"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const messageId = await brain.addNoun(userMessage, 'message', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
type: "message",
|
|
|
|
|
|
timestamp: Date.now(),
|
|
|
|
|
|
session: "abc"
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const topicId = await brain.addNoun("Product Support", 'topic', {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
type: "topic",
|
|
|
|
|
|
category: "support"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Link conversation elements
|
|
|
|
|
|
await brain.addVerb(userId, messageId, "sent")
|
|
|
|
|
|
await brain.addVerb(messageId, topicId, "about")
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve context with relationships
|
|
|
|
|
|
const context = await brain.find({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
where: {type: "message"},
|
|
|
|
|
|
connected: {from: userId, type: "sent"},
|
|
|
|
|
|
like: "previous product issues"
|
2025-08-27 09:27:12 -07:00
|
|
|
|
})
|
2025-08-26 12:32:21 -07:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 💾 Storage Options
|
|
|
|
|
|
|
|
|
|
|
|
Brainy supports multiple storage backends:
|
|
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
|
// Memory (default for testing)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const brain = new BrainyData({
|
|
|
|
|
|
storage: {type: 'memory'}
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// FileSystem (Node.js)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const brain = new BrainyData({
|
|
|
|
|
|
storage: {
|
|
|
|
|
|
type: 'filesystem',
|
|
|
|
|
|
path: './data'
|
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Browser Storage (OPFS)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const brain = new BrainyData({
|
|
|
|
|
|
storage: {type: 'opfs'}
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// S3 Compatible (Production)
|
2025-09-11 16:23:32 -07:00
|
|
|
|
const brain = new BrainyData({
|
|
|
|
|
|
storage: {
|
|
|
|
|
|
type: 's3',
|
|
|
|
|
|
bucket: 'my-bucket',
|
|
|
|
|
|
region: 'us-east-1'
|
|
|
|
|
|
}
|
2025-08-26 12:32:21 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 🛠️ CLI
|
|
|
|
|
|
|
|
|
|
|
|
Brainy includes a powerful CLI for testing and management:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# Install globally
|
|
|
|
|
|
npm install -g brainy
|
|
|
|
|
|
|
|
|
|
|
|
# Add data
|
|
|
|
|
|
brainy add "JavaScript is awesome" --metadata '{"type":"opinion"}'
|
|
|
|
|
|
|
|
|
|
|
|
# Search
|
|
|
|
|
|
brainy search "programming"
|
|
|
|
|
|
|
|
|
|
|
|
# Natural language find
|
|
|
|
|
|
brainy find "awesome programming languages"
|
|
|
|
|
|
|
|
|
|
|
|
# Interactive mode
|
|
|
|
|
|
brainy chat
|
|
|
|
|
|
|
|
|
|
|
|
# Export data
|
|
|
|
|
|
brainy export --format json > backup.json
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-28 13:59:59 -07:00
|
|
|
|
## 🧠 Neural API - Advanced AI Features
|
|
|
|
|
|
|
|
|
|
|
|
Brainy includes a powerful Neural API for advanced semantic analysis:
|
|
|
|
|
|
|
|
|
|
|
|
### Clustering & Analysis
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-28 13:59:59 -07:00
|
|
|
|
```javascript
|
|
|
|
|
|
// Access via brain.neural
|
|
|
|
|
|
const neural = brain.neural
|
|
|
|
|
|
|
|
|
|
|
|
// Automatic semantic clustering
|
|
|
|
|
|
const clusters = await neural.clusters()
|
|
|
|
|
|
// Returns groups of semantically similar items
|
|
|
|
|
|
|
|
|
|
|
|
// Cluster with options
|
|
|
|
|
|
const clusters = await neural.clusters({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
algorithm: 'kmeans', // or 'hierarchical', 'sample'
|
|
|
|
|
|
maxClusters: 5, // Maximum number of clusters
|
|
|
|
|
|
threshold: 0.8 // Similarity threshold
|
2025-08-28 13:59:59 -07:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate similarity between any items
|
|
|
|
|
|
const similarity = await neural.similar('item1', 'item2')
|
|
|
|
|
|
// Returns 0-1 score
|
|
|
|
|
|
|
|
|
|
|
|
// Find nearest neighbors
|
|
|
|
|
|
const neighbors = await neural.neighbors('item-id', 10)
|
|
|
|
|
|
|
|
|
|
|
|
// Build semantic hierarchy
|
|
|
|
|
|
const hierarchy = await neural.hierarchy('item-id')
|
|
|
|
|
|
|
|
|
|
|
|
// Detect outliers
|
|
|
|
|
|
const outliers = await neural.outliers(0.3)
|
|
|
|
|
|
|
|
|
|
|
|
// Generate visualization data for D3/Cytoscape
|
|
|
|
|
|
const vizData = await neural.visualize({
|
2025-09-11 16:23:32 -07:00
|
|
|
|
maxNodes: 100,
|
|
|
|
|
|
dimensions: 3,
|
|
|
|
|
|
algorithm: 'force'
|
2025-08-28 13:59:59 -07:00
|
|
|
|
})
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### Real-World Examples
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-28 13:59:59 -07:00
|
|
|
|
```javascript
|
|
|
|
|
|
// Group customer feedback into themes
|
|
|
|
|
|
const feedbackClusters = await neural.clusters()
|
|
|
|
|
|
for (const cluster of feedbackClusters) {
|
2025-09-11 16:23:32 -07:00
|
|
|
|
console.log(`Theme: ${cluster.label}`)
|
|
|
|
|
|
console.log(`Items: ${cluster.members.length}`)
|
2025-08-28 13:59:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Find related documents
|
2025-09-01 09:37:36 -07:00
|
|
|
|
const docId = await brain.addNoun("Machine learning guide", 'document')
|
2025-08-28 13:59:59 -07:00
|
|
|
|
const similar = await neural.neighbors(docId, 5)
|
|
|
|
|
|
// Returns 5 most similar documents
|
|
|
|
|
|
|
|
|
|
|
|
// Detect anomalies in data
|
|
|
|
|
|
const anomalies = await neural.outliers(0.2)
|
|
|
|
|
|
console.log(`Found ${anomalies.length} outliers`)
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
## 🔌 Augmentations
|
|
|
|
|
|
|
|
|
|
|
|
Extend Brainy with powerful augmentations:
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# List available augmentations
|
|
|
|
|
|
brainy augment list
|
|
|
|
|
|
|
|
|
|
|
|
# Install an augmentation
|
|
|
|
|
|
brainy augment install explorer
|
|
|
|
|
|
|
|
|
|
|
|
# Connect to Brain Cloud
|
|
|
|
|
|
brainy cloud setup
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## 🏢 Enterprise Features - Included for Everyone
|
|
|
|
|
|
|
|
|
|
|
|
Brainy includes enterprise-grade capabilities at no extra cost. **No premium tiers, no paywalls.**
|
|
|
|
|
|
|
|
|
|
|
|
- **Scales to 10M+ items** with consistent 3ms search latency
|
|
|
|
|
|
- **Distributed architecture** with sharding and replication
|
|
|
|
|
|
- **Read/write separation** for horizontal scaling
|
|
|
|
|
|
- **Connection pooling** and request deduplication
|
|
|
|
|
|
- **Built-in monitoring** with metrics and health checks
|
|
|
|
|
|
- **Production ready** with circuit breakers and backpressure
|
|
|
|
|
|
|
|
|
|
|
|
📖 **[Read the full Enterprise Features guide →](docs/ENTERPRISE-FEATURES.md)**
|
|
|
|
|
|
|
|
|
|
|
|
## 📊 Benchmarks
|
|
|
|
|
|
|
2025-09-11 16:23:32 -07:00
|
|
|
|
| Operation | Performance | Memory |
|
|
|
|
|
|
|----------------------------------|-------------|----------|
|
|
|
|
|
|
| Initialize | 450ms | 24MB |
|
|
|
|
|
|
| Add Item | 12ms | +0.1MB |
|
|
|
|
|
|
| Vector Search (1k items) | 3ms | - |
|
|
|
|
|
|
| Metadata Filter (10k items) | 0.8ms | - |
|
|
|
|
|
|
| Natural Language Query | 15ms | - |
|
|
|
|
|
|
| Bulk Import (1000 items) | 2.3s | +8MB |
|
|
|
|
|
|
| **Production Scale (10M items)** | **5.8ms** | **12GB** |
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
## 🔄 Migration from 1.x
|
|
|
|
|
|
|
|
|
|
|
|
See [MIGRATION.md](MIGRATION.md) for detailed upgrade instructions.
|
|
|
|
|
|
|
|
|
|
|
|
Key changes:
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
- Search methods consolidated into `search()` and `find()`
|
|
|
|
|
|
- Result format now includes full objects with metadata
|
|
|
|
|
|
- New natural language capabilities
|
|
|
|
|
|
|
|
|
|
|
|
## 🤝 Contributing
|
|
|
|
|
|
|
|
|
|
|
|
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
## 🧠 The Universal Knowledge Protocol Explained
|
|
|
|
|
|
|
|
|
|
|
|
### How We Achieved The Impossible
|
|
|
|
|
|
|
|
|
|
|
|
**Triple Intelligence™** makes us the **world's first** to unify three database paradigms:
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
1. **Vector databases** (Pinecone, Weaviate) - semantic similarity
|
2025-09-11 16:23:32 -07:00
|
|
|
|
2. **Graph databases** (Neo4j, ArangoDB) - relationships
|
2025-08-27 09:27:12 -07:00
|
|
|
|
3. **Document databases** (MongoDB, Elasticsearch) - metadata filtering
|
|
|
|
|
|
|
|
|
|
|
|
**One API to rule them all.** Others make you choose. We unified them.
|
|
|
|
|
|
|
|
|
|
|
|
### The Math of Infinite Expressiveness
|
|
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
24 Nouns × 40 Verbs × ∞ Metadata × Triple Intelligence = Universal Protocol
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
- **960 base combinations** from standardized types
|
|
|
|
|
|
- **∞ domain specificity** via unlimited metadata
|
|
|
|
|
|
- **∞ relationship depth** via graph traversal
|
|
|
|
|
|
- **= Model ANYTHING**: From quantum physics to social networks
|
|
|
|
|
|
|
|
|
|
|
|
### Why This Changes Everything
|
|
|
|
|
|
|
|
|
|
|
|
**Like HTTP for the web, Brainy for knowledge:**
|
2025-09-11 16:23:32 -07:00
|
|
|
|
|
2025-08-27 09:27:12 -07:00
|
|
|
|
- All augmentations compose perfectly - same noun-verb language
|
|
|
|
|
|
- All AI models share knowledge - GPT, Claude, Llama all understand
|
|
|
|
|
|
- All tools integrate seamlessly - no translation layers
|
|
|
|
|
|
- All data flows freely - perfect portability
|
|
|
|
|
|
|
|
|
|
|
|
**The Vision**: One protocol. All knowledge. Every tool. Any AI.
|
|
|
|
|
|
|
|
|
|
|
|
**Proven across industries**: Healthcare, Finance, Manufacturing, Education, Legal, Retail, Government, and beyond.
|
|
|
|
|
|
|
|
|
|
|
|
[→ See the Mathematical Proof & Full Taxonomy](docs/architecture/noun-verb-taxonomy.md)
|
|
|
|
|
|
|
2025-08-26 12:32:21 -07:00
|
|
|
|
## 📖 Documentation
|
|
|
|
|
|
|
|
|
|
|
|
- [Getting Started Guide](docs/guides/getting-started.md)
|
|
|
|
|
|
- [API Reference](docs/api/README.md)
|
|
|
|
|
|
- [Architecture Overview](docs/architecture/overview.md)
|
|
|
|
|
|
- [Natural Language Guide](docs/guides/natural-language.md)
|
|
|
|
|
|
- [Triple Intelligence](docs/architecture/triple-intelligence.md)
|
2025-08-27 09:27:12 -07:00
|
|
|
|
- [Noun-Verb Taxonomy](docs/architecture/noun-verb-taxonomy.md)
|
2025-08-26 12:32:21 -07:00
|
|
|
|
|
|
|
|
|
|
## 🏢 Enterprise & Cloud
|
|
|
|
|
|
|
|
|
|
|
|
**Brain Cloud** - Managed Brainy with team sync, persistent memory, and enterprise connectors.
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
# Get started with free trial
|
|
|
|
|
|
brainy cloud setup
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
Visit [soulcraft.com](https://soulcraft.com) for more information.
|
|
|
|
|
|
|
|
|
|
|
|
## 📄 License
|
|
|
|
|
|
|
|
|
|
|
|
MIT © Brainy Contributors
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
<p align="center">
|
|
|
|
|
|
<strong>Built with ❤️ by the Brainy community</strong><br>
|
|
|
|
|
|
<em>Zero-Configuration AI Database with Triple Intelligence™</em>
|
|
|
|
|
|
</p>
|