@soulcraft/brainy 3.50.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +242 -0
- package/README.md +358 -658
- package/dist/api/ConfigAPI.js +56 -19
- package/dist/api/DataAPI.js +24 -18
- package/dist/augmentations/storageAugmentations.d.ts +24 -0
- package/dist/augmentations/storageAugmentations.js +22 -0
- package/dist/brainy.js +32 -9
- package/dist/cli/commands/core.d.ts +20 -10
- package/dist/cli/commands/core.js +384 -82
- package/dist/cli/commands/import.d.ts +41 -0
- package/dist/cli/commands/import.js +456 -0
- package/dist/cli/commands/insights.d.ts +34 -0
- package/dist/cli/commands/insights.js +300 -0
- package/dist/cli/commands/neural.d.ts +6 -12
- package/dist/cli/commands/neural.js +113 -10
- package/dist/cli/commands/nlp.d.ts +28 -0
- package/dist/cli/commands/nlp.js +246 -0
- package/dist/cli/commands/storage.d.ts +64 -0
- package/dist/cli/commands/storage.js +730 -0
- package/dist/cli/index.js +210 -24
- package/dist/coreTypes.d.ts +206 -34
- package/dist/distributed/configManager.js +8 -6
- package/dist/distributed/shardMigration.js +2 -0
- package/dist/distributed/storageDiscovery.js +6 -4
- package/dist/embeddings/EmbeddingManager.d.ts +2 -2
- package/dist/embeddings/EmbeddingManager.js +5 -1
- package/dist/graph/lsm/LSMTree.js +32 -20
- package/dist/hnsw/typeAwareHNSWIndex.js +6 -2
- package/dist/storage/adapters/azureBlobStorage.d.ts +545 -0
- package/dist/storage/adapters/azureBlobStorage.js +1809 -0
- package/dist/storage/adapters/baseStorageAdapter.d.ts +16 -13
- package/dist/storage/adapters/fileSystemStorage.d.ts +21 -9
- package/dist/storage/adapters/fileSystemStorage.js +204 -127
- package/dist/storage/adapters/gcsStorage.d.ts +119 -9
- package/dist/storage/adapters/gcsStorage.js +317 -62
- package/dist/storage/adapters/memoryStorage.d.ts +30 -18
- package/dist/storage/adapters/memoryStorage.js +99 -94
- package/dist/storage/adapters/opfsStorage.d.ts +48 -10
- package/dist/storage/adapters/opfsStorage.js +201 -80
- package/dist/storage/adapters/r2Storage.d.ts +12 -5
- package/dist/storage/adapters/r2Storage.js +63 -15
- package/dist/storage/adapters/s3CompatibleStorage.d.ts +164 -17
- package/dist/storage/adapters/s3CompatibleStorage.js +472 -80
- package/dist/storage/adapters/typeAwareStorageAdapter.d.ts +38 -6
- package/dist/storage/adapters/typeAwareStorageAdapter.js +218 -39
- package/dist/storage/baseStorage.d.ts +41 -38
- package/dist/storage/baseStorage.js +110 -134
- package/dist/storage/storageFactory.d.ts +29 -2
- package/dist/storage/storageFactory.js +30 -1
- package/dist/utils/entityIdMapper.js +5 -2
- package/dist/utils/fieldTypeInference.js +8 -1
- package/dist/utils/metadataFilter.d.ts +3 -2
- package/dist/utils/metadataFilter.js +1 -0
- package/dist/utils/metadataIndex.d.ts +2 -1
- package/dist/utils/metadataIndex.js +9 -1
- package/dist/utils/metadataIndexChunking.js +9 -4
- package/dist/utils/periodicCleanup.js +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -11,91 +11,88 @@
|
|
|
11
11
|
|
|
12
12
|
**🧠 Brainy - The Knowledge Operating System**
|
|
13
13
|
|
|
14
|
-
**The world's first Knowledge Operating System** where every piece of knowledge - files, concepts, entities, ideas - exists as living information that understands itself, evolves over time, and connects to everything related.
|
|
14
|
+
**The world's first Knowledge Operating System** where every piece of knowledge - files, concepts, entities, ideas - exists as living information that understands itself, evolves over time, and connects to everything related.
|
|
15
15
|
|
|
16
16
|
**Why Brainy Changes Everything**: Traditional systems trap knowledge in files or database rows. Brainy liberates it. Your characters exist across stories. Your concepts span projects. Your APIs remember their evolution. Every piece of knowledge - whether it's code, prose, or pure ideas - lives, breathes, and connects in a unified intelligence layer where everything understands its meaning, remembers its history, and relates to everything else.
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
Built on revolutionary **Triple Intelligence™** that unifies vector similarity, graph relationships, and document filtering in one magical API. **Framework-first design.** Zero configuration. O(log n) performance, <10ms search latency. **Production-ready for billion-scale deployments.**
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 🎉 NEW in v4.0.0 - Enterprise-Scale Cost Optimization
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
**Major Release: Production cost optimization and enterprise-scale features**
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
### 💰 **Up to 96% Storage Cost Savings**
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
- **Memory @ 1B scale**: 384GB → 50GB (-87% / -334GB)
|
|
28
|
-
- **Single-type queries**: 10x faster (search 100M nodes instead of 1B)
|
|
29
|
-
- **Multi-type queries**: 5-8x faster (search subset of types)
|
|
30
|
-
- **All-types queries**: ~3x faster (31 smaller graphs vs 1 large graph)
|
|
28
|
+
Automatic cloud storage lifecycle management for **AWS S3**, **Google Cloud Storage**, and **Azure Blob Storage**:
|
|
31
29
|
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- **Lazy loading**: 15 minutes for top 2 types only
|
|
30
|
+
- **GCS Autoclass**: Fully automatic tier optimization (94% savings!)
|
|
31
|
+
- **AWS Intelligent-Tiering**: Smart archival with instant retrieval
|
|
32
|
+
- **Azure Lifecycle Policies**: Automatic tier transitions
|
|
33
|
+
- **Cost Impact**: $138,000/year → $5,940/year @ 500TB scale
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
- 47 new tests (33 unit + 14 integration) - all passing
|
|
40
|
-
- Backward compatible - opt-in via configuration
|
|
41
|
-
- Works with all storage backends (FileSystem, S3, GCS, R2, Memory, OPFS)
|
|
35
|
+
### ⚡ **Performance at Billion-Scale**
|
|
42
36
|
|
|
43
|
-
**
|
|
37
|
+
- **1000x faster batch deletions** (533 entities/sec vs 0.5/sec)
|
|
38
|
+
- **60-80% FileSystem compression** with gzip
|
|
39
|
+
- **OPFS quota monitoring** for browser storage
|
|
40
|
+
- **Enhanced CLI** with 47 commands including 9 storage management tools
|
|
44
41
|
|
|
45
|
-
###
|
|
42
|
+
### 🛡️ **Zero Breaking Changes**
|
|
46
43
|
|
|
47
|
-
**
|
|
44
|
+
**100% backward compatible.** No migration required. All new features are opt-in.
|
|
48
45
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
- Model memory accounting (150MB Q8, 250MB FP32 reserved before cache)
|
|
46
|
+
**[📖 Read the full v4.0.0 Changelog →](CHANGELOG.md)** | **[Migration Guide →](docs/MIGRATION-V3-TO-V4.md)**
|
|
47
|
+
|
|
48
|
+
---
|
|
53
49
|
|
|
54
|
-
|
|
55
|
-
- Intelligent sync/async branching - synchronous when data is in memory
|
|
56
|
-
- Falls back to async only when loading from storage
|
|
57
|
-
- Massive performance win for hot paths (vector search, distance calculations)
|
|
50
|
+
## 🎯 What Makes Brainy Revolutionary?
|
|
58
51
|
|
|
59
|
-
-
|
|
60
|
-
- `getCacheStats()` - UnifiedCache hit rates, fairness metrics, memory pressure
|
|
61
|
-
- Actionable recommendations for tuning
|
|
62
|
-
- Tracks model memory, cache efficiency, and competition across indexes
|
|
52
|
+
### 🧠 **Triple Intelligence™ - The Impossible Made Possible**
|
|
63
53
|
|
|
64
|
-
|
|
65
|
-
- Public API unchanged
|
|
66
|
-
- Automatic memory detection and allocation
|
|
67
|
-
- Progressive enhancement for existing applications
|
|
54
|
+
**The world's first to unify three database paradigms in ONE API:**
|
|
68
55
|
|
|
69
|
-
**
|
|
56
|
+
- **Vector Search** 🔍 Semantic similarity like Pinecone/Weaviate
|
|
57
|
+
- **Graph Relationships** 🕸️ Navigate connections like Neo4j/ArangoDB
|
|
58
|
+
- **Document Filtering** 📊 MongoDB-style queries with O(log n) performance
|
|
70
59
|
|
|
71
|
-
|
|
60
|
+
**Others make you choose.** Vector OR graph OR document. **Brainy does ALL THREE together.** This is what enables The Knowledge Operating System.
|
|
61
|
+
|
|
62
|
+
### 🚀 **Zero Configuration - Just Works™**
|
|
63
|
+
|
|
64
|
+
```javascript
|
|
65
|
+
import { Brainy } from '@soulcraft/brainy'
|
|
66
|
+
|
|
67
|
+
const brain = new Brainy()
|
|
68
|
+
await brain.init()
|
|
69
|
+
|
|
70
|
+
// That's it! Auto-detects storage, optimizes memory, configures everything.
|
|
71
|
+
```
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
- **⚡ Entity Caching**: 10-100x speedup on repeated entity extraction
|
|
75
|
-
- **🔗 Relationship Confidence**: Multi-factor confidence scoring (0-1 scale)
|
|
76
|
-
- **📝 Evidence Tracking**: Understand why relationships were detected
|
|
77
|
-
- **🎯 Production Ready**: Fully backward compatible, opt-in features
|
|
73
|
+
No configuration files. No environment variables. No complex setup. **It just works.**
|
|
78
74
|
|
|
79
|
-
###
|
|
75
|
+
### ⚡ **Production Performance at Any Scale**
|
|
80
76
|
|
|
81
|
-
- **
|
|
82
|
-
- **
|
|
83
|
-
- **
|
|
84
|
-
- **
|
|
77
|
+
- **<10ms search** across millions of entities
|
|
78
|
+
- **87% memory reduction** @ billion scale (384GB → 50GB)
|
|
79
|
+
- **10x faster queries** with type-aware indexing
|
|
80
|
+
- **99% storage cost savings** with intelligent archival
|
|
81
|
+
- **Container-aware** memory allocation (Docker/K8s)
|
|
85
82
|
|
|
86
|
-
### 🎯 **
|
|
83
|
+
### 🎯 **31 Noun Types × 40 Verb Types = Infinite Expressiveness**
|
|
87
84
|
|
|
88
|
-
|
|
89
|
-
- **Type Safety**: Full TypeScript integration
|
|
90
|
-
- **Zero Config**: Works out of the box with intelligent storage auto-detection
|
|
91
|
-
- **Consistent Parameters**: Clean, predictable API surface
|
|
85
|
+
Model **ANY domain** with 1,240 base type combinations + unlimited metadata:
|
|
92
86
|
|
|
93
|
-
|
|
87
|
+
- Healthcare: Patient → diagnoses → Condition
|
|
88
|
+
- Finance: Account → transfers → Transaction
|
|
89
|
+
- Manufacturing: Product → assembles → Component
|
|
90
|
+
- Education: Student → completes → Course
|
|
91
|
+
- **Your domain**: Your types + Your relationships = Your knowledge graph
|
|
94
92
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
- **Production Ready**: Thoroughly tested core functionality
|
|
93
|
+
[→ See the Mathematical Proof](docs/architecture/noun-verb-taxonomy.md)
|
|
94
|
+
|
|
95
|
+
---
|
|
99
96
|
|
|
100
97
|
## ⚡ Quick Start - Zero Configuration
|
|
101
98
|
|
|
@@ -103,7 +100,7 @@
|
|
|
103
100
|
npm install @soulcraft/brainy
|
|
104
101
|
```
|
|
105
102
|
|
|
106
|
-
### 🎯 **
|
|
103
|
+
### 🎯 **Your First Knowledge Graph in 30 Seconds**
|
|
107
104
|
|
|
108
105
|
```javascript
|
|
109
106
|
import { Brainy, NounType } from '@soulcraft/brainy'
|
|
@@ -145,7 +142,9 @@ await brain.relate({
|
|
|
145
142
|
})
|
|
146
143
|
|
|
147
144
|
// Natural language search with graph relationships
|
|
148
|
-
const results = await brain.find({
|
|
145
|
+
const results = await brain.find({
|
|
146
|
+
query: "programming languages used by server runtimes"
|
|
147
|
+
})
|
|
149
148
|
|
|
150
149
|
// Triple Intelligence: vector + metadata + relationships
|
|
151
150
|
const filtered = await brain.find({
|
|
@@ -155,525 +154,346 @@ const filtered = await brain.find({
|
|
|
155
154
|
})
|
|
156
155
|
```
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
**Brainy is framework-first!** Works seamlessly with any modern JavaScript framework:
|
|
161
|
-
|
|
162
|
-
### ⚛️ **React & Next.js**
|
|
163
|
-
```javascript
|
|
164
|
-
import { Brainy } from '@soulcraft/brainy'
|
|
165
|
-
|
|
166
|
-
function SearchComponent() {
|
|
167
|
-
const [brain] = useState(() => new Brainy())
|
|
168
|
-
|
|
169
|
-
useEffect(() => {
|
|
170
|
-
brain.init()
|
|
171
|
-
}, [])
|
|
172
|
-
|
|
173
|
-
const handleSearch = async (query) => {
|
|
174
|
-
const results = await brain.find(query)
|
|
175
|
-
setResults(results)
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### 🟢 **Vue.js & Nuxt.js**
|
|
181
|
-
```javascript
|
|
182
|
-
import { Brainy } from '@soulcraft/brainy'
|
|
183
|
-
|
|
184
|
-
export default {
|
|
185
|
-
async mounted() {
|
|
186
|
-
this.brain = new Brainy()
|
|
187
|
-
await this.brain.init()
|
|
188
|
-
},
|
|
189
|
-
methods: {
|
|
190
|
-
async search(query) {
|
|
191
|
-
return await this.brain.find(query)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
```
|
|
157
|
+
**That's it!** You just created a knowledge graph with semantic search, relationship traversal, and metadata filtering. **No configuration. No complexity. Just works.**
|
|
196
158
|
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
import { Injectable } from '@angular/core'
|
|
200
|
-
import { Brainy } from '@soulcraft/brainy'
|
|
201
|
-
|
|
202
|
-
@Injectable({ providedIn: 'root' })
|
|
203
|
-
export class BrainyService {
|
|
204
|
-
private brain = new Brainy()
|
|
205
|
-
|
|
206
|
-
async init() {
|
|
207
|
-
await this.brain.init()
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
async search(query: string) {
|
|
211
|
-
return await this.brain.find(query)
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### 🔥 **Other Frameworks**
|
|
217
|
-
Brainy works with **any** framework that supports ES6 imports: Svelte, Solid.js, Qwik, Fresh, and more!
|
|
218
|
-
|
|
219
|
-
**Framework Compatibility:**
|
|
220
|
-
- ✅ All modern bundlers (Webpack, Vite, Rollup, Parcel)
|
|
221
|
-
- ✅ SSR/SSG (Next.js, Nuxt, SvelteKit, Astro)
|
|
222
|
-
- ✅ Edge runtimes (Vercel Edge, Cloudflare Workers)
|
|
223
|
-
- ✅ Browser and Node.js environments
|
|
224
|
-
|
|
225
|
-
## 📋 System Requirements
|
|
226
|
-
|
|
227
|
-
**Node.js Version:** 22 LTS or later (recommended)
|
|
228
|
-
|
|
229
|
-
- ✅ **Node.js 22 LTS** - Fully supported and recommended for production
|
|
230
|
-
- ✅ **Node.js 20 LTS** - Compatible (maintenance mode)
|
|
231
|
-
- ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
|
|
232
|
-
|
|
233
|
-
> **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause
|
|
234
|
-
> crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
|
|
235
|
-
|
|
236
|
-
If using nvm: `nvm use` (we provide a `.nvmrc` file)
|
|
237
|
-
|
|
238
|
-
## 🚀 Key Features
|
|
239
|
-
|
|
240
|
-
### World's First Triple Intelligence™ Engine
|
|
241
|
-
|
|
242
|
-
**The breakthrough that enables The Knowledge Operating System:**
|
|
243
|
-
|
|
244
|
-
- **Vector Search**: Semantic similarity with HNSW indexing
|
|
245
|
-
- **Graph Relationships**: Navigate connected knowledge like Neo4j
|
|
246
|
-
- **Document Filtering**: MongoDB-style queries with O(log n) performance
|
|
247
|
-
- **Unified in ONE API**: No separate queries, no complex joins
|
|
248
|
-
- **First to solve this**: Others do vector OR graph OR document—we do ALL
|
|
249
|
-
|
|
250
|
-
### The Knowledge Operating System with Infinite Expressiveness
|
|
251
|
-
|
|
252
|
-
**Enabled by Triple Intelligence, standardized for everyone:**
|
|
159
|
+
---
|
|
253
160
|
|
|
254
|
-
|
|
255
|
-
- **∞ Expressiveness**: Unlimited metadata = model ANY data
|
|
256
|
-
- **One Language**: All tools, augmentations, AI models speak the same types
|
|
257
|
-
- **Perfect Interoperability**: Move data between any Brainy instance
|
|
258
|
-
- **No Schema Lock-in**: Evolve without migrations
|
|
161
|
+
## 🌟 Core Features
|
|
259
162
|
|
|
260
|
-
### Natural Language Understanding
|
|
163
|
+
### 🧠 **Natural Language Understanding**
|
|
261
164
|
|
|
262
165
|
```javascript
|
|
263
|
-
// Ask questions naturally
|
|
166
|
+
// Ask questions naturally - Brainy understands
|
|
264
167
|
await brain.find("Show me recent React components with tests")
|
|
265
168
|
await brain.find("Popular JavaScript libraries similar to Vue")
|
|
266
169
|
await brain.find("Documentation about authentication from last month")
|
|
267
|
-
```
|
|
268
170
|
|
|
269
|
-
|
|
171
|
+
// Structured queries with Triple Intelligence
|
|
172
|
+
await brain.find({
|
|
173
|
+
like: "React", // Vector similarity
|
|
174
|
+
where: { // Document filtering
|
|
175
|
+
type: "library",
|
|
176
|
+
year: {greaterThan: 2020}
|
|
177
|
+
},
|
|
178
|
+
connected: {to: "JavaScript", depth: 2} // Graph relationships
|
|
179
|
+
})
|
|
180
|
+
```
|
|
270
181
|
|
|
271
|
-
|
|
182
|
+
### 🌐 **Virtual Filesystem - Intelligent File Management**
|
|
272
183
|
|
|
273
|
-
|
|
274
|
-
- **Semantic Search**: Find files by content, not just filename
|
|
275
|
-
- **Production Storage**: Filesystem and cloud storage for real applications
|
|
276
|
-
- **Zero-Config**: Works out of the box with intelligent defaults
|
|
184
|
+
Build file explorers, IDEs, and knowledge systems that **never crash**:
|
|
277
185
|
|
|
278
186
|
```javascript
|
|
279
|
-
import { Brainy } from '@soulcraft/brainy'
|
|
280
|
-
|
|
281
|
-
// ✅ CORRECT: Use persistent storage for file systems
|
|
282
|
-
const brain = new Brainy({
|
|
283
|
-
storage: {
|
|
284
|
-
type: 'filesystem', // Persisted to disk
|
|
285
|
-
path: './brainy-data' // Your file storage
|
|
286
|
-
}
|
|
287
|
-
})
|
|
288
|
-
await brain.init()
|
|
289
|
-
|
|
290
187
|
const vfs = brain.vfs()
|
|
291
188
|
await vfs.init()
|
|
292
189
|
|
|
293
190
|
// ✅ Safe file operations
|
|
294
191
|
await vfs.writeFile('/projects/app/index.js', 'console.log("Hello")')
|
|
295
192
|
await vfs.mkdir('/docs')
|
|
296
|
-
await vfs.writeFile('/docs/README.md', '# My Project')
|
|
297
193
|
|
|
298
194
|
// ✅ NEVER crashes: Tree-aware directory listing
|
|
299
195
|
const children = await vfs.getDirectChildren('/projects')
|
|
300
|
-
// Returns only direct children, never the directory itself
|
|
301
196
|
|
|
302
197
|
// ✅ Build file explorers safely
|
|
303
198
|
const tree = await vfs.getTreeStructure('/projects', {
|
|
304
199
|
maxDepth: 3, // Prevent deep recursion
|
|
305
|
-
sort: 'name'
|
|
200
|
+
sort: 'name'
|
|
306
201
|
})
|
|
307
202
|
|
|
308
203
|
// ✅ Semantic file search
|
|
309
204
|
const reactFiles = await vfs.search('React components with hooks')
|
|
310
|
-
const docs = await vfs.search('API documentation', {
|
|
311
|
-
path: '/docs' // Search within specific directory
|
|
312
|
-
})
|
|
313
|
-
|
|
314
|
-
// ✅ Connect related files
|
|
315
|
-
await vfs.addRelationship('/src/auth.js', '/tests/auth.test.js', 'tested-by')
|
|
316
|
-
|
|
317
|
-
// Perfect for: File explorers, IDEs, documentation systems, code analysis
|
|
318
205
|
```
|
|
319
206
|
|
|
320
|
-
|
|
321
|
-
- ❌ No infinite recursion in file trees (like brain-cloud team experienced)
|
|
322
|
-
- ❌ No data loss from memory storage
|
|
323
|
-
- ❌ No performance issues with large directories
|
|
324
|
-
- ❌ No need for complex fallback patterns
|
|
207
|
+
**Prevents infinite recursion** that crashes traditional file systems. Tree-aware operations ensure your file explorer never hangs.
|
|
325
208
|
|
|
326
209
|
**[📖 VFS Quick Start →](docs/vfs/QUICK_START.md)** | **[🎯 Common Patterns →](docs/vfs/COMMON_PATTERNS.md)**
|
|
327
210
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
### 🚀 **NEW: Enhanced Directory Import with Caching**
|
|
331
|
-
|
|
332
|
-
**Import large projects 10-100x faster with intelligent caching:**
|
|
211
|
+
### 🚀 **Import Anything - CSV, Excel, PDF, URLs**
|
|
333
212
|
|
|
334
213
|
```javascript
|
|
335
|
-
|
|
336
|
-
import
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
const brain = new Brainy()
|
|
340
|
-
await brain.init()
|
|
341
|
-
|
|
342
|
-
// Progress tracking for long operations
|
|
343
|
-
const tracker = ProgressTracker.create(1000)
|
|
344
|
-
tracker.start()
|
|
345
|
-
|
|
346
|
-
for await (const progress of importer.importStream('./project', {
|
|
347
|
-
batchSize: 100,
|
|
348
|
-
generateEmbeddings: true
|
|
349
|
-
})) {
|
|
350
|
-
const p = tracker.update(progress.processed, progress.current)
|
|
351
|
-
console.log(formatProgress(p))
|
|
352
|
-
// [RUNNING] 45% (450/1000) - 23.5 items/s - 23s remaining
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
// Entity extraction with intelligent caching
|
|
356
|
-
const entities = await brain.neural.extractor.extract(text, {
|
|
357
|
-
types: ['person', 'organization', 'technology'],
|
|
358
|
-
confidence: 0.7,
|
|
359
|
-
cache: {
|
|
360
|
-
enabled: true,
|
|
361
|
-
ttl: 7 * 24 * 60 * 60 * 1000, // 7 days
|
|
362
|
-
invalidateOn: 'mtime' // Re-extract when file changes
|
|
363
|
-
}
|
|
364
|
-
})
|
|
214
|
+
// Import CSV with auto-detection
|
|
215
|
+
await brain.import('customers.csv')
|
|
216
|
+
// ✨ Auto-detects: encoding, delimiter, types, creates entities!
|
|
365
217
|
|
|
366
|
-
//
|
|
367
|
-
|
|
368
|
-
|
|
218
|
+
// Import Excel workbooks with multi-sheet support
|
|
219
|
+
await brain.import('sales-data.xlsx', {
|
|
220
|
+
excelSheets: ['Q1', 'Q2']
|
|
369
221
|
})
|
|
370
222
|
|
|
371
|
-
//
|
|
372
|
-
await brain.
|
|
373
|
-
|
|
374
|
-
to: targetId,
|
|
375
|
-
type: 'creates',
|
|
376
|
-
confidence: 0.85,
|
|
377
|
-
evidence: {
|
|
378
|
-
sourceText: 'John created the database',
|
|
379
|
-
method: 'pattern',
|
|
380
|
-
reasoning: 'Matches creation pattern; entities in same sentence'
|
|
381
|
-
}
|
|
223
|
+
// Import PDF documents with table extraction
|
|
224
|
+
await brain.import('research-paper.pdf', {
|
|
225
|
+
pdfExtractTables: true
|
|
382
226
|
})
|
|
383
227
|
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
console.log(`Cache hit rate: ${(stats.hitRate * 100).toFixed(1)}%`)
|
|
387
|
-
// Cache hit rate: 89.5%
|
|
228
|
+
// Import from URLs (auto-fetched)
|
|
229
|
+
await brain.import('https://api.example.com/data.json')
|
|
388
230
|
```
|
|
389
231
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
### 🎯 Zero Configuration Philosophy
|
|
232
|
+
**[📖 Complete Import Guide →](docs/guides/import-anything.md)**
|
|
393
233
|
|
|
394
|
-
|
|
234
|
+
### 🧠 **Neural API - Advanced Semantic Analysis**
|
|
395
235
|
|
|
396
236
|
```javascript
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
// 1. Pure zero-config - detects everything
|
|
400
|
-
const brain = new Brainy()
|
|
237
|
+
const neural = brain.neural
|
|
401
238
|
|
|
402
|
-
//
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
239
|
+
// Automatic semantic clustering
|
|
240
|
+
const clusters = await neural.clusters({
|
|
241
|
+
algorithm: 'kmeans',
|
|
242
|
+
maxClusters: 5,
|
|
243
|
+
threshold: 0.8
|
|
407
244
|
})
|
|
408
245
|
|
|
409
|
-
//
|
|
410
|
-
const
|
|
411
|
-
mode: 'production',
|
|
412
|
-
model: 'q8', // Optimized model (99% accuracy, 75% smaller)
|
|
413
|
-
storage: 'cloud', // or 'memory', 'disk', 'auto'
|
|
414
|
-
features: ['core', 'search', 'cache']
|
|
415
|
-
})
|
|
416
|
-
```
|
|
246
|
+
// Calculate similarity between any items
|
|
247
|
+
const similarity = await neural.similar('item1', 'item2')
|
|
417
248
|
|
|
418
|
-
|
|
249
|
+
// Find nearest neighbors
|
|
250
|
+
const neighbors = await neural.neighbors('item-id', 10)
|
|
419
251
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
- **Features**: Minimal → Default → Full based on environment
|
|
423
|
-
- **Memory**: Optimal cache sizes and batching
|
|
424
|
-
- **Performance**: Threading, chunking, indexing strategies
|
|
252
|
+
// Detect outliers
|
|
253
|
+
const outliers = await neural.outliers(0.3)
|
|
425
254
|
|
|
426
|
-
|
|
255
|
+
// Generate visualization data for D3/Cytoscape
|
|
256
|
+
const vizData = await neural.visualize({
|
|
257
|
+
maxNodes: 100,
|
|
258
|
+
dimensions: 3,
|
|
259
|
+
algorithm: 'force'
|
|
260
|
+
})
|
|
261
|
+
```
|
|
427
262
|
|
|
428
|
-
|
|
429
|
-
- **24MB memory footprint** - Efficient resource usage
|
|
430
|
-
- **Worker-based embeddings** - Non-blocking operations
|
|
431
|
-
- **Automatic caching** - Intelligent result caching
|
|
263
|
+
---
|
|
432
264
|
|
|
433
|
-
|
|
265
|
+
## 🌐 Framework Integration
|
|
434
266
|
|
|
435
|
-
|
|
267
|
+
**Brainy is framework-first!** Works with **any** modern framework:
|
|
436
268
|
|
|
269
|
+
### ⚛️ React & Next.js
|
|
437
270
|
```javascript
|
|
438
|
-
|
|
439
|
-
const brain = new Brainy()
|
|
440
|
-
|
|
441
|
-
// Storage control (auto-detected by default)
|
|
442
|
-
const diskBrain = new Brainy({storage: 'disk'}) // Local filesystem
|
|
443
|
-
const cloudBrain = new Brainy({storage: 'cloud'}) // S3/GCS/R2
|
|
271
|
+
function SearchComponent() {
|
|
272
|
+
const [brain] = useState(() => new Brainy())
|
|
273
|
+
useEffect(() => { brain.init() }, [])
|
|
444
274
|
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
}
|
|
275
|
+
const handleSearch = async (query) => {
|
|
276
|
+
const results = await brain.find(query)
|
|
277
|
+
setResults(results)
|
|
278
|
+
}
|
|
279
|
+
}
|
|
449
280
|
```
|
|
450
281
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
282
|
+
### 🟢 Vue.js & Nuxt.js
|
|
283
|
+
```javascript
|
|
284
|
+
export default {
|
|
285
|
+
async mounted() {
|
|
286
|
+
this.brain = new Brainy()
|
|
287
|
+
await this.brain.init()
|
|
288
|
+
},
|
|
289
|
+
methods: {
|
|
290
|
+
async search(query) {
|
|
291
|
+
return await this.brain.find(query)
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
```
|
|
458
296
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
297
|
+
### 🅰️ Angular
|
|
298
|
+
```typescript
|
|
299
|
+
@Injectable({ providedIn: 'root' })
|
|
300
|
+
export class BrainyService {
|
|
301
|
+
private brain = new Brainy()
|
|
302
|
+
async search(query: string) {
|
|
303
|
+
return await this.brain.find(query)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
462
306
|
```
|
|
463
307
|
|
|
464
|
-
|
|
308
|
+
**Works with:** Svelte, Solid.js, Qwik, Fresh, and more! All bundlers (Webpack, Vite, Rollup). SSR/SSG. Edge runtimes.
|
|
465
309
|
|
|
466
|
-
|
|
310
|
+
---
|
|
467
311
|
|
|
468
|
-
|
|
469
|
-
// Import CSV with auto-detection
|
|
470
|
-
await brain.import('customers.csv')
|
|
471
|
-
// ✨ Auto-detects: encoding, delimiter, types, creates entities!
|
|
312
|
+
## 💾 Storage - From Development to Production
|
|
472
313
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
// ✨ Processes all sheets, preserves structure, infers types!
|
|
314
|
+
### 🚀 **Development: Just Works**
|
|
315
|
+
```javascript
|
|
316
|
+
const brain = new Brainy() // Memory storage, auto-configured
|
|
317
|
+
```
|
|
478
318
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
319
|
+
### ⚡ **Production: FileSystem with Compression**
|
|
320
|
+
```javascript
|
|
321
|
+
const brain = new Brainy({
|
|
322
|
+
storage: {
|
|
323
|
+
type: 'filesystem',
|
|
324
|
+
path: './brainy-data',
|
|
325
|
+
compression: true // 60-80% space savings!
|
|
326
|
+
}
|
|
482
327
|
})
|
|
483
|
-
// ✨ Extracts text, detects tables, preserves metadata!
|
|
484
|
-
|
|
485
|
-
// Import JSON/YAML data
|
|
486
|
-
await brain.import([
|
|
487
|
-
{ name: 'Alice', role: 'Engineer' },
|
|
488
|
-
{ name: 'Bob', role: 'Designer' }
|
|
489
|
-
])
|
|
490
|
-
// ✨ Automatically creates Person entities with relationships!
|
|
491
|
-
|
|
492
|
-
// Import from URLs (auto-fetched)
|
|
493
|
-
await brain.import('https://api.example.com/data.json')
|
|
494
|
-
// ✨ Auto-detects URL, fetches, parses, processes!
|
|
495
328
|
```
|
|
496
329
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
## 📚 Core API
|
|
330
|
+
### ☁️ **Production: Cloud Storage** (NEW in v4.0.0)
|
|
500
331
|
|
|
501
|
-
|
|
332
|
+
Choose your cloud provider - all support **automatic cost optimization:**
|
|
502
333
|
|
|
334
|
+
#### **AWS S3 / Cloudflare R2 / DigitalOcean Spaces**
|
|
503
335
|
```javascript
|
|
504
|
-
const
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
336
|
+
const brain = new Brainy({
|
|
337
|
+
storage: {
|
|
338
|
+
type: 's3',
|
|
339
|
+
s3Storage: {
|
|
340
|
+
bucketName: 'my-knowledge-base',
|
|
341
|
+
region: 'us-east-1',
|
|
342
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
343
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
344
|
+
}
|
|
345
|
+
}
|
|
508
346
|
})
|
|
509
|
-
```
|
|
510
347
|
|
|
511
|
-
|
|
348
|
+
// Enable Intelligent-Tiering for automatic 96% cost savings
|
|
349
|
+
await brain.storage.enableIntelligentTiering('entities/', 'brainy-auto-tier')
|
|
350
|
+
```
|
|
512
351
|
|
|
352
|
+
#### **Google Cloud Storage**
|
|
513
353
|
```javascript
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
important: true
|
|
523
|
-
},
|
|
524
|
-
related: {to: "React"} // Graph relationships
|
|
354
|
+
const brain = new Brainy({
|
|
355
|
+
storage: {
|
|
356
|
+
type: 'gcs',
|
|
357
|
+
gcsStorage: {
|
|
358
|
+
bucketName: 'my-knowledge-base',
|
|
359
|
+
keyFilename: '/path/to/service-account.json'
|
|
360
|
+
}
|
|
361
|
+
}
|
|
525
362
|
})
|
|
526
|
-
```
|
|
527
363
|
|
|
528
|
-
|
|
364
|
+
// Enable Autoclass for automatic 94% cost savings
|
|
365
|
+
await brain.storage.enableAutoclass({ terminalStorageClass: 'ARCHIVE' })
|
|
366
|
+
```
|
|
529
367
|
|
|
368
|
+
#### **Azure Blob Storage**
|
|
530
369
|
```javascript
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
370
|
+
const brain = new Brainy({
|
|
371
|
+
storage: {
|
|
372
|
+
type: 'azure',
|
|
373
|
+
azureStorage: {
|
|
374
|
+
containerName: 'knowledge-base',
|
|
375
|
+
connectionString: process.env.AZURE_STORAGE_CONNECTION_STRING
|
|
376
|
+
}
|
|
377
|
+
}
|
|
538
378
|
})
|
|
539
379
|
|
|
540
|
-
//
|
|
541
|
-
|
|
542
|
-
|
|
380
|
+
// Batch tier changes for 99% cost savings
|
|
381
|
+
await brain.storage.setBlobTierBatch(
|
|
382
|
+
oldBlobs.map(name => ({ blobName: name, tier: 'Archive' }))
|
|
383
|
+
)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
### 💰 **Cost Optimization Impact**
|
|
543
387
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
388
|
+
| Scale | Before | After (Archive) | Savings/Year |
|
|
389
|
+
|-------|--------|-----------------|--------------|
|
|
390
|
+
| 5TB | $1,380/year | $59/year | **$1,321 (96%)** |
|
|
391
|
+
| 50TB | $13,800/year | $594/year | **$13,206 (96%)** |
|
|
392
|
+
| 500TB | $138,000/year | $5,940/year | **$132,060 (96%)** |
|
|
547
393
|
|
|
548
|
-
|
|
549
|
-
await brain.deleteNoun(id)
|
|
550
|
-
await brain.deleteVerb(verbId)
|
|
394
|
+
**[📖 AWS S3 Cost Guide →](docs/operations/cost-optimization-aws-s3.md)** | **[GCS →](docs/operations/cost-optimization-gcs.md)** | **[Azure →](docs/operations/cost-optimization-azure.md)** | **[R2 →](docs/operations/cost-optimization-cloudflare-r2.md)**
|
|
551
395
|
|
|
552
|
-
|
|
553
|
-
await brain.import(arrayOfData)
|
|
554
|
-
const exported = await brain.export({format: 'json'})
|
|
396
|
+
---
|
|
555
397
|
|
|
556
|
-
|
|
557
|
-
await brain.import('customers.csv') // CSV with encoding detection
|
|
558
|
-
await brain.import('sales-report.xlsx') // Excel with multi-sheet support
|
|
559
|
-
await brain.import('research.pdf') // PDF with table extraction
|
|
560
|
-
```
|
|
398
|
+
## 🚀 Production Scale Features (NEW in v4.0.0)
|
|
561
399
|
|
|
562
|
-
|
|
400
|
+
### 🎯 **Type-Aware HNSW - 87% Memory Reduction**
|
|
563
401
|
|
|
564
|
-
|
|
402
|
+
**Billion-scale deployments made affordable:**
|
|
403
|
+
|
|
404
|
+
- **Memory @ 1B entities**: 384GB → 50GB (-87%)
|
|
405
|
+
- **Single-type queries**: 10x faster (search 100M instead of 1B)
|
|
406
|
+
- **Multi-type queries**: 5-8x faster
|
|
407
|
+
- **Optimized rebuilds**: 31x faster with type filtering
|
|
565
408
|
|
|
566
409
|
```javascript
|
|
567
|
-
// Single node (default)
|
|
568
410
|
const brain = new Brainy({
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
bucketName: 'my-data',
|
|
573
|
-
region: 'us-east-1',
|
|
574
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
575
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
576
|
-
}
|
|
577
|
-
}
|
|
411
|
+
hnsw: {
|
|
412
|
+
typeAware: true // Enable type-aware indexing
|
|
413
|
+
}
|
|
578
414
|
})
|
|
415
|
+
```
|
|
579
416
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
417
|
+
### ⚡ **Production-Ready Storage**
|
|
418
|
+
|
|
419
|
+
**NEW v4.0.0 enterprise features:**
|
|
420
|
+
|
|
421
|
+
- **🗑️ Batch Operations**: Delete thousands of entities with retry logic
|
|
422
|
+
- **📦 Gzip Compression**: 60-80% space savings (FileSystem)
|
|
423
|
+
- **💽 OPFS Quota Monitoring**: Real-time quota tracking (Browser)
|
|
424
|
+
- **🔄 Metadata/Vector Separation**: Billion-entity scalability
|
|
425
|
+
- **🛡️ Enterprise Reliability**: Backpressure, circuit breakers, retries
|
|
426
|
+
|
|
427
|
+
```javascript
|
|
428
|
+
// Batch delete with retry logic
|
|
429
|
+
await brain.storage.batchDelete(keys, {
|
|
430
|
+
maxRetries: 3,
|
|
431
|
+
continueOnError: true
|
|
592
432
|
})
|
|
433
|
+
|
|
434
|
+
// Get storage status
|
|
435
|
+
const status = await brain.storage.getStorageStatus()
|
|
436
|
+
console.log(`Used: ${status.used}, Quota: ${status.quota}`)
|
|
593
437
|
```
|
|
594
438
|
|
|
595
|
-
###
|
|
439
|
+
### 📊 **Adaptive Memory Management**
|
|
596
440
|
|
|
597
|
-
|
|
598
|
-
- **Automatic Sharding**: Data distributed by content hash
|
|
599
|
-
- **Smart Query Planning**: Queries routed to optimal shards
|
|
600
|
-
- **Live Rebalancing**: Handles node joins/leaves automatically
|
|
601
|
-
- **Zero Downtime**: Streaming shard migration
|
|
441
|
+
**Auto-scales from 2GB to 128GB+ based on resources:**
|
|
602
442
|
|
|
603
|
-
|
|
443
|
+
- Container-aware (Docker/K8s cgroups v1/v2)
|
|
444
|
+
- Environment-smart (25% dev, 40% container, 50% production)
|
|
445
|
+
- Model memory accounting (150MB Q8, 250MB FP32)
|
|
446
|
+
- Built-in cache monitoring with recommendations
|
|
604
447
|
|
|
605
448
|
```javascript
|
|
606
|
-
|
|
449
|
+
// Get cache statistics and recommendations
|
|
450
|
+
const stats = brain.getCacheStats()
|
|
451
|
+
console.log(`Hit rate: ${stats.hitRate * 100}%`)
|
|
452
|
+
// Actionable tuning recommendations included
|
|
453
|
+
```
|
|
607
454
|
|
|
608
|
-
|
|
609
|
-
const ingestionNode = new Brainy({
|
|
610
|
-
storage: {
|
|
611
|
-
type: 's3',
|
|
612
|
-
s3Storage: {
|
|
613
|
-
bucketName: 'social-data',
|
|
614
|
-
region: 'us-east-1',
|
|
615
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
616
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
617
|
-
}
|
|
618
|
-
},
|
|
619
|
-
distributed: true,
|
|
620
|
-
writeOnly: true // Optimized for high-throughput writes
|
|
621
|
-
})
|
|
455
|
+
**[📖 Capacity Planning Guide →](docs/operations/capacity-planning.md)**
|
|
622
456
|
|
|
623
|
-
|
|
624
|
-
blueskyStream.on('post', async (post) => {
|
|
625
|
-
await ingestionNode.add(post, {
|
|
626
|
-
nounType: NounType.Message,
|
|
627
|
-
platform: 'bluesky',
|
|
628
|
-
author: post.author,
|
|
629
|
-
timestamp: post.createdAt
|
|
630
|
-
})
|
|
631
|
-
})
|
|
457
|
+
---
|
|
632
458
|
|
|
633
|
-
|
|
634
|
-
const searchNode = new Brainy({
|
|
635
|
-
storage: {
|
|
636
|
-
type: 's3',
|
|
637
|
-
s3Storage: {
|
|
638
|
-
bucketName: 'social-data',
|
|
639
|
-
region: 'us-east-1',
|
|
640
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
641
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY
|
|
642
|
-
}
|
|
643
|
-
},
|
|
644
|
-
distributed: true,
|
|
645
|
-
readOnly: true // Optimized for fast queries
|
|
646
|
-
})
|
|
459
|
+
## 🏢 Enterprise Features - No Paywalls
|
|
647
460
|
|
|
648
|
-
|
|
649
|
-
const trending = await searchNode.find('trending AI topics', {
|
|
650
|
-
where: {timestamp: {greaterThan: Date.now() - 3600000}},
|
|
651
|
-
limit: 100
|
|
652
|
-
})
|
|
653
|
-
```
|
|
461
|
+
Brainy includes **enterprise-grade capabilities at no extra cost**:
|
|
654
462
|
|
|
655
|
-
|
|
463
|
+
- ✅ **Scales to billions of entities** with 18ms search latency @ 1B scale
|
|
464
|
+
- ✅ **Distributed architecture** with sharding and replication
|
|
465
|
+
- ✅ **Read/write separation** for horizontal scaling
|
|
466
|
+
- ✅ **Connection pooling** and request deduplication
|
|
467
|
+
- ✅ **Built-in monitoring** with metrics and health checks
|
|
468
|
+
- ✅ **Production ready** with circuit breakers and backpressure
|
|
656
469
|
|
|
657
|
-
|
|
658
|
-
|----------------|----------------------------------|-------------------------------|
|
|
659
|
-
| Setup | Complex (k8s, operators) | One flag: `distributed: true` |
|
|
660
|
-
| Coordination | External (etcd, Consul) | Built-in (via storage) |
|
|
661
|
-
| Minimum Nodes | 3-5 for HA | 1 (scale as needed) |
|
|
662
|
-
| Sharding | Random | Domain-aware |
|
|
663
|
-
| Query Planning | Basic | Triple Intelligence |
|
|
664
|
-
| Cost | High (always-on clusters) | Low (scale to zero) |
|
|
470
|
+
**No premium tiers. No feature gates. Everyone gets the same powerful system.**
|
|
665
471
|
|
|
666
|
-
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## 📊 Benchmarks
|
|
475
|
+
|
|
476
|
+
| Operation | Performance | Memory |
|
|
477
|
+
|----------------------------------|-------------|----------|
|
|
478
|
+
| Initialize | 450ms | 24MB |
|
|
479
|
+
| Add Item | 12ms | +0.1MB |
|
|
480
|
+
| Vector Search (1k items) | 3ms | - |
|
|
481
|
+
| Metadata Filter (10k items) | 0.8ms | - |
|
|
482
|
+
| Natural Language Query | 15ms | - |
|
|
483
|
+
| Bulk Import (1000 items) | 2.3s | +8MB |
|
|
484
|
+
| **Production Scale (10M items)** | **5.8ms** | **12GB** |
|
|
485
|
+
| **Billion Scale (1B items)** | **18ms** | **50GB** |
|
|
486
|
+
|
|
487
|
+
---
|
|
667
488
|
|
|
668
|
-
|
|
489
|
+
## 🎯 Use Cases
|
|
669
490
|
|
|
491
|
+
### Knowledge Management
|
|
670
492
|
```javascript
|
|
671
|
-
//
|
|
493
|
+
// Create knowledge graph with relationships
|
|
672
494
|
const apiGuide = await brain.add("REST API Guide", {
|
|
673
495
|
nounType: NounType.Document,
|
|
674
|
-
|
|
675
|
-
category: "documentation",
|
|
676
|
-
version: "2.0"
|
|
496
|
+
category: "documentation"
|
|
677
497
|
})
|
|
678
498
|
|
|
679
499
|
const author = await brain.add("Jane Developer", {
|
|
@@ -681,37 +501,17 @@ const author = await brain.add("Jane Developer", {
|
|
|
681
501
|
role: "tech-lead"
|
|
682
502
|
})
|
|
683
503
|
|
|
684
|
-
|
|
685
|
-
nounType: NounType.Project,
|
|
686
|
-
status: "active"
|
|
687
|
-
})
|
|
688
|
-
|
|
689
|
-
// Create knowledge graph
|
|
690
|
-
await brain.relate(author, apiGuide, "authored", {
|
|
691
|
-
date: "2024-03-15"
|
|
692
|
-
})
|
|
693
|
-
await brain.relate(apiGuide, project, "documents", {
|
|
694
|
-
coverage: "complete"
|
|
695
|
-
})
|
|
696
|
-
|
|
697
|
-
// Query the knowledge graph naturally
|
|
698
|
-
const docs = await brain.find("documentation authored by tech leads for active projects")
|
|
699
|
-
```
|
|
700
|
-
|
|
701
|
-
### Semantic Search
|
|
504
|
+
await brain.relate(author, apiGuide, "authored")
|
|
702
505
|
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
threshold: 0.8
|
|
708
|
-
})
|
|
506
|
+
// Query naturally
|
|
507
|
+
const docs = await brain.find(
|
|
508
|
+
"documentation authored by tech leads for active projects"
|
|
509
|
+
)
|
|
709
510
|
```
|
|
710
511
|
|
|
711
|
-
### AI Memory Layer
|
|
712
|
-
|
|
512
|
+
### AI Memory Layer
|
|
713
513
|
```javascript
|
|
714
|
-
// Store
|
|
514
|
+
// Store conversation context with relationships
|
|
715
515
|
const userId = await brain.add("User 123", {
|
|
716
516
|
nounType: NounType.User,
|
|
717
517
|
tier: "premium"
|
|
@@ -719,20 +519,12 @@ const userId = await brain.add("User 123", {
|
|
|
719
519
|
|
|
720
520
|
const messageId = await brain.add(userMessage, {
|
|
721
521
|
nounType: NounType.Message,
|
|
722
|
-
timestamp: Date.now()
|
|
723
|
-
session: "abc"
|
|
724
|
-
})
|
|
725
|
-
|
|
726
|
-
const topicId = await brain.add("Product Support", {
|
|
727
|
-
nounType: NounType.Topic,
|
|
728
|
-
category: "support"
|
|
522
|
+
timestamp: Date.now()
|
|
729
523
|
})
|
|
730
524
|
|
|
731
|
-
// Link message elements
|
|
732
525
|
await brain.relate(userId, messageId, "sent")
|
|
733
|
-
await brain.relate(messageId, topicId, "about")
|
|
734
526
|
|
|
735
|
-
// Retrieve context
|
|
527
|
+
// Retrieve context
|
|
736
528
|
const context = await brain.find({
|
|
737
529
|
where: {type: "message"},
|
|
738
530
|
connected: {from: userId, type: "sent"},
|
|
@@ -740,40 +532,20 @@ const context = await brain.find({
|
|
|
740
532
|
})
|
|
741
533
|
```
|
|
742
534
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
Brainy supports multiple storage backends:
|
|
746
|
-
|
|
535
|
+
### Semantic Search
|
|
747
536
|
```javascript
|
|
748
|
-
//
|
|
749
|
-
const
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
path: './data'
|
|
753
|
-
}
|
|
754
|
-
})
|
|
755
|
-
|
|
756
|
-
// Browser Storage (OPFS) - Works with frameworks
|
|
757
|
-
const brain = new Brainy({
|
|
758
|
-
storage: {type: 'opfs'} // Framework handles browser polyfills
|
|
759
|
-
})
|
|
760
|
-
|
|
761
|
-
// S3 Compatible (Production)
|
|
762
|
-
const brain = new Brainy({
|
|
763
|
-
storage: {
|
|
764
|
-
type: 's3',
|
|
765
|
-
bucket: 'my-bucket',
|
|
766
|
-
region: 'us-east-1'
|
|
767
|
-
}
|
|
537
|
+
// Find similar content
|
|
538
|
+
const similar = await brain.search(existingContent, {
|
|
539
|
+
limit: 5,
|
|
540
|
+
threshold: 0.8
|
|
768
541
|
})
|
|
769
542
|
```
|
|
770
543
|
|
|
771
|
-
|
|
544
|
+
---
|
|
772
545
|
|
|
773
|
-
|
|
546
|
+
## 🛠️ CLI
|
|
774
547
|
|
|
775
548
|
```bash
|
|
776
|
-
# Install globally
|
|
777
549
|
npm install -g brainy
|
|
778
550
|
|
|
779
551
|
# Add data
|
|
@@ -787,137 +559,78 @@ brainy find "awesome programming languages"
|
|
|
787
559
|
|
|
788
560
|
# Interactive mode
|
|
789
561
|
brainy chat
|
|
790
|
-
|
|
791
|
-
# Export data
|
|
792
|
-
brainy export --format json > backup.json
|
|
793
|
-
```
|
|
794
|
-
|
|
795
|
-
## 🧠 Neural API - Advanced AI Features
|
|
796
|
-
|
|
797
|
-
Brainy includes a powerful Neural API for advanced semantic analysis:
|
|
798
|
-
|
|
799
|
-
### Clustering & Analysis
|
|
800
|
-
|
|
801
|
-
```javascript
|
|
802
|
-
// Access via brain.neural
|
|
803
|
-
const neural = brain.neural
|
|
804
|
-
|
|
805
|
-
// Automatic semantic clustering
|
|
806
|
-
const clusters = await neural.clusters()
|
|
807
|
-
// Returns groups of semantically similar items
|
|
808
|
-
|
|
809
|
-
// Cluster with options
|
|
810
|
-
const clusters = await neural.clusters({
|
|
811
|
-
algorithm: 'kmeans', // or 'hierarchical', 'sample'
|
|
812
|
-
maxClusters: 5, // Maximum number of clusters
|
|
813
|
-
threshold: 0.8 // Similarity threshold
|
|
814
|
-
})
|
|
815
|
-
|
|
816
|
-
// Calculate similarity between any items
|
|
817
|
-
const similarity = await neural.similar('item1', 'item2')
|
|
818
|
-
// Returns 0-1 score
|
|
819
|
-
|
|
820
|
-
// Find nearest neighbors
|
|
821
|
-
const neighbors = await neural.neighbors('item-id', 10)
|
|
822
|
-
|
|
823
|
-
// Build semantic hierarchy
|
|
824
|
-
const hierarchy = await neural.hierarchy('item-id')
|
|
825
|
-
|
|
826
|
-
// Detect outliers
|
|
827
|
-
const outliers = await neural.outliers(0.3)
|
|
828
|
-
|
|
829
|
-
// Generate visualization data for D3/Cytoscape
|
|
830
|
-
const vizData = await neural.visualize({
|
|
831
|
-
maxNodes: 100,
|
|
832
|
-
dimensions: 3,
|
|
833
|
-
algorithm: 'force'
|
|
834
|
-
})
|
|
835
562
|
```
|
|
836
563
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
```javascript
|
|
840
|
-
// Group customer feedback into themes
|
|
841
|
-
const feedbackClusters = await neural.clusters()
|
|
842
|
-
for (const cluster of feedbackClusters) {
|
|
843
|
-
console.log(`Theme: ${cluster.label}`)
|
|
844
|
-
console.log(`Items: ${cluster.members.length}`)
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
// Find related documents
|
|
848
|
-
const docId = await brain.add("Machine learning guide", { nounType: NounType.Document })
|
|
849
|
-
const similar = await neural.neighbors(docId, 5)
|
|
850
|
-
// Returns 5 most similar documents
|
|
564
|
+
---
|
|
851
565
|
|
|
852
|
-
|
|
853
|
-
const anomalies = await neural.outliers(0.2)
|
|
854
|
-
console.log(`Found ${anomalies.length} outliers`)
|
|
855
|
-
```
|
|
566
|
+
## 📖 Documentation
|
|
856
567
|
|
|
857
|
-
|
|
568
|
+
### Getting Started
|
|
569
|
+
- [Getting Started Guide](docs/guides/getting-started.md)
|
|
570
|
+
- [v4.0.0 Migration Guide](docs/MIGRATION-V3-TO-V4.md) **← NEW**
|
|
571
|
+
- [AWS S3 Cost Guide](docs/operations/cost-optimization-aws-s3.md) | [GCS](docs/operations/cost-optimization-gcs.md) | [Azure](docs/operations/cost-optimization-azure.md) | [R2](docs/operations/cost-optimization-cloudflare-r2.md) **← NEW**
|
|
858
572
|
|
|
859
|
-
|
|
573
|
+
### Framework Integration
|
|
574
|
+
- [Framework Integration Guide](docs/guides/framework-integration.md)
|
|
575
|
+
- [Next.js Integration](docs/guides/nextjs-integration.md)
|
|
576
|
+
- [Vue.js Integration](docs/guides/vue-integration.md)
|
|
860
577
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
578
|
+
### Virtual Filesystem
|
|
579
|
+
- [VFS Core Documentation](docs/vfs/VFS_CORE.md)
|
|
580
|
+
- [Semantic VFS Guide](docs/vfs/SEMANTIC_VFS.md)
|
|
581
|
+
- [Neural Extraction API](docs/vfs/NEURAL_EXTRACTION.md)
|
|
864
582
|
|
|
865
|
-
|
|
866
|
-
|
|
583
|
+
### Core Documentation
|
|
584
|
+
- [API Reference](docs/api/README.md)
|
|
585
|
+
- [Architecture Overview](docs/architecture/overview.md)
|
|
586
|
+
- [Data Storage Architecture](docs/architecture/data-storage-architecture.md)
|
|
587
|
+
- [Natural Language Guide](docs/guides/natural-language.md)
|
|
588
|
+
- [Triple Intelligence](docs/architecture/triple-intelligence.md)
|
|
589
|
+
- [Noun-Verb Taxonomy](docs/architecture/noun-verb-taxonomy.md)
|
|
867
590
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
591
|
+
### Operations & Production
|
|
592
|
+
- [Capacity Planning](docs/operations/capacity-planning.md)
|
|
593
|
+
- [Cloud Deployment Guide](docs/deployment/CLOUD_DEPLOYMENT_GUIDE.md) **← NEW**
|
|
594
|
+
- [AWS S3 Cost Guide](docs/operations/cost-optimization-aws-s3.md) | [GCS](docs/operations/cost-optimization-gcs.md) | [Azure](docs/operations/cost-optimization-azure.md) | [R2](docs/operations/cost-optimization-cloudflare-r2.md) **← NEW**
|
|
871
595
|
|
|
872
|
-
|
|
596
|
+
---
|
|
873
597
|
|
|
874
|
-
|
|
598
|
+
## 💖 Support Brainy
|
|
875
599
|
|
|
876
|
-
|
|
877
|
-
- **Distributed architecture** with sharding and replication
|
|
878
|
-
- **Read/write separation** for horizontal scaling
|
|
879
|
-
- **Connection pooling** and request deduplication
|
|
880
|
-
- **Built-in monitoring** with metrics and health checks
|
|
881
|
-
- **Production ready** with circuit breakers and backpressure
|
|
600
|
+
Brainy is **free and open source** - no paywalls, no premium tiers, no feature gates. If Brainy helps your project, consider supporting development:
|
|
882
601
|
|
|
883
|
-
|
|
602
|
+
- ⭐ **Star us on [GitHub](https://github.com/soulcraftlabs/brainy)**
|
|
603
|
+
- 💝 **Sponsor via [GitHub Sponsors](https://github.com/sponsors/soulcraftlabs)**
|
|
604
|
+
- 🐛 **Report issues** and contribute code
|
|
605
|
+
- 📣 **Share** with your team and community
|
|
884
606
|
|
|
885
|
-
|
|
607
|
+
Your support keeps Brainy free for everyone and enables continued development of enterprise features at no cost.
|
|
886
608
|
|
|
887
|
-
|
|
888
|
-
|----------------------------------|-------------|----------|
|
|
889
|
-
| Initialize | 450ms | 24MB |
|
|
890
|
-
| Add Item | 12ms | +0.1MB |
|
|
891
|
-
| Vector Search (1k items) | 3ms | - |
|
|
892
|
-
| Metadata Filter (10k items) | 0.8ms | - |
|
|
893
|
-
| Natural Language Query | 15ms | - |
|
|
894
|
-
| Bulk Import (1000 items) | 2.3s | +8MB |
|
|
895
|
-
| **Production Scale (10M items)** | **5.8ms** | **12GB** |
|
|
609
|
+
---
|
|
896
610
|
|
|
897
|
-
##
|
|
611
|
+
## 📋 System Requirements
|
|
898
612
|
|
|
899
|
-
|
|
613
|
+
**Node.js Version:** 22 LTS (recommended)
|
|
900
614
|
|
|
901
|
-
-
|
|
902
|
-
-
|
|
903
|
-
-
|
|
904
|
-
- Distributed architecture support
|
|
615
|
+
- ✅ **Node.js 22 LTS** - Fully supported (recommended for production)
|
|
616
|
+
- ✅ **Node.js 20 LTS** - Compatible (maintenance mode)
|
|
617
|
+
- ❌ **Node.js 24** - Not supported (ONNX compatibility issues)
|
|
905
618
|
|
|
906
|
-
|
|
619
|
+
If using nvm: `nvm use` (we provide a `.nvmrc` file)
|
|
907
620
|
|
|
908
|
-
|
|
621
|
+
---
|
|
909
622
|
|
|
910
623
|
## 🧠 The Knowledge Operating System Explained
|
|
911
624
|
|
|
912
625
|
### How We Achieved The Impossible
|
|
913
626
|
|
|
914
|
-
**Triple Intelligence™**
|
|
627
|
+
**Triple Intelligence™** unifies three database paradigms that were previously incompatible:
|
|
915
628
|
|
|
916
629
|
1. **Vector databases** (Pinecone, Weaviate) - semantic similarity
|
|
917
630
|
2. **Graph databases** (Neo4j, ArangoDB) - relationships
|
|
918
631
|
3. **Document databases** (MongoDB, Elasticsearch) - metadata filtering
|
|
919
632
|
|
|
920
|
-
**
|
|
633
|
+
**Others make you choose. Brainy does all three together.**
|
|
921
634
|
|
|
922
635
|
### The Math of Infinite Expressiveness
|
|
923
636
|
|
|
@@ -945,40 +658,26 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
|
945
658
|
|
|
946
659
|
[→ See the Mathematical Proof & Full Taxonomy](docs/architecture/noun-verb-taxonomy.md)
|
|
947
660
|
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
### Framework Integration
|
|
951
|
-
- [Framework Integration Guide](docs/guides/framework-integration.md) - Complete framework setup guide
|
|
952
|
-
- [Next.js Integration](docs/guides/nextjs-integration.md) - React and Next.js examples
|
|
953
|
-
- [Vue.js Integration](docs/guides/vue-integration.md) - Vue and Nuxt examples
|
|
954
|
-
|
|
955
|
-
### Virtual Filesystem (Semantic VFS) 🧠📁
|
|
956
|
-
- [VFS Core Documentation](docs/vfs/VFS_CORE.md) - Complete filesystem architecture and API
|
|
957
|
-
- [Semantic VFS Guide](docs/vfs/SEMANTIC_VFS.md) - Multi-dimensional file access (6 semantic dimensions)
|
|
958
|
-
- [Neural Extraction API](docs/vfs/NEURAL_EXTRACTION.md) - AI-powered concept and entity extraction
|
|
959
|
-
- [Examples & Scenarios](docs/vfs/VFS_EXAMPLES_SCENARIOS.md) - Real-world use cases and code
|
|
960
|
-
- [VFS API Guide](docs/vfs/VFS_API_GUIDE.md) - Complete API reference
|
|
961
|
-
|
|
962
|
-
### Core Documentation
|
|
963
|
-
- [Getting Started Guide](docs/guides/getting-started.md)
|
|
964
|
-
- [API Reference](docs/api/README.md)
|
|
965
|
-
- [Architecture Overview](docs/architecture/overview.md)
|
|
966
|
-
- [Data Storage Architecture](docs/architecture/data-storage-architecture.md) - Deep dive into storage, indexing, and sharding
|
|
967
|
-
- [Natural Language Guide](docs/guides/natural-language.md)
|
|
968
|
-
- [Triple Intelligence](docs/architecture/triple-intelligence.md)
|
|
969
|
-
- [Noun-Verb Taxonomy](docs/architecture/noun-verb-taxonomy.md)
|
|
661
|
+
---
|
|
970
662
|
|
|
971
663
|
## 🏢 Enterprise & Cloud
|
|
972
664
|
|
|
973
665
|
**Brain Cloud** - Managed Brainy with team sync, persistent memory, and enterprise connectors.
|
|
974
666
|
|
|
975
667
|
```bash
|
|
976
|
-
# Get started with free trial
|
|
977
668
|
brainy cloud setup
|
|
978
669
|
```
|
|
979
670
|
|
|
980
671
|
Visit [soulcraft.com](https://soulcraft.com) for more information.
|
|
981
672
|
|
|
673
|
+
---
|
|
674
|
+
|
|
675
|
+
## 🤝 Contributing
|
|
676
|
+
|
|
677
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
678
|
+
|
|
679
|
+
---
|
|
680
|
+
|
|
982
681
|
## 📄 License
|
|
983
682
|
|
|
984
683
|
MIT © Brainy Contributors
|
|
@@ -987,5 +686,6 @@ MIT © Brainy Contributors
|
|
|
987
686
|
|
|
988
687
|
<p align="center">
|
|
989
688
|
<strong>Built with ❤️ by the Brainy community</strong><br>
|
|
990
|
-
<em>Zero-Configuration AI Database with Triple Intelligence™</em>
|
|
991
|
-
</
|
|
689
|
+
<em>Zero-Configuration AI Database with Triple Intelligence™</em><br>
|
|
690
|
+
<em>v4.0.0 - Production-Scale Storage with 99% Cost Savings</em>
|
|
691
|
+
</p>
|