@soulcraft/brainy 0.54.7 → 0.56.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/README.md +174 -669
- package/bin/cortex.js +592 -0
- package/dist/augmentations/memoryAugmentations.d.ts.map +1 -1
- package/dist/augmentations/neuralImportSense.d.ts +196 -0
- package/dist/augmentations/neuralImportSense.js +747 -0
- package/dist/augmentations/neuralImportSense.js.map +1 -0
- package/dist/brainyData.d.ts +40 -0
- package/dist/brainyData.d.ts.map +1 -1
- package/dist/brainyData.js +88 -0
- package/dist/brainyData.js.map +1 -1
- package/dist/chat/brainyChat.d.ts +42 -0
- package/dist/chat/brainyChat.js +340 -0
- package/dist/chat/brainyChat.js.map +1 -0
- package/dist/connectors/interfaces/IConnector.d.ts +143 -0
- package/dist/connectors/interfaces/IConnector.js +8 -0
- package/dist/connectors/interfaces/IConnector.js.map +1 -0
- package/dist/coreTypes.d.ts.map +1 -1
- package/dist/cortex/backupRestore.d.ts +85 -0
- package/dist/cortex/backupRestore.js +326 -0
- package/dist/cortex/backupRestore.js.map +1 -0
- package/dist/cortex/cortex.d.ts +249 -0
- package/dist/cortex/cortex.js +2304 -0
- package/dist/cortex/cortex.js.map +1 -0
- package/dist/cortex/healthCheck.d.ts +85 -0
- package/dist/cortex/healthCheck.js +546 -0
- package/dist/cortex/healthCheck.js.map +1 -0
- package/dist/cortex/licensingSystem.d.ts +126 -0
- package/dist/cortex/licensingSystem.js +474 -0
- package/dist/cortex/licensingSystem.js.map +1 -0
- package/dist/cortex/neuralImport.d.ts +145 -0
- package/dist/cortex/neuralImport.js +620 -0
- package/dist/cortex/neuralImport.js.map +1 -0
- package/dist/cortex/performanceMonitor.d.ts +150 -0
- package/dist/cortex/performanceMonitor.js +371 -0
- package/dist/cortex/performanceMonitor.js.map +1 -0
- package/dist/cortex/serviceIntegration.d.ts +156 -0
- package/dist/cortex/serviceIntegration.js +384 -0
- package/dist/cortex/serviceIntegration.js.map +1 -0
- package/dist/cortex/webhookManager.d.ts +39 -0
- package/dist/cortex/webhookManager.js +326 -0
- package/dist/cortex/webhookManager.js.map +1 -0
- package/dist/hnsw/hnswIndex.d.ts.map +1 -1
- package/dist/hnsw/hnswIndexOptimized.d.ts.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/patched-platform-node.d.ts +17 -0
- package/dist/patched-platform-node.d.ts.map +1 -0
- package/dist/shared/default-augmentations.d.ts +41 -0
- package/dist/shared/default-augmentations.js +112 -0
- package/dist/shared/default-augmentations.js.map +1 -0
- package/dist/storage/adapters/baseStorageAdapter.d.ts.map +1 -1
- package/dist/storage/adapters/fileSystemStorage.d.ts +14 -0
- package/dist/storage/adapters/fileSystemStorage.d.ts.map +1 -1
- package/dist/storage/adapters/fileSystemStorage.js +68 -0
- package/dist/storage/adapters/fileSystemStorage.js.map +1 -1
- package/dist/storage/adapters/memoryStorage.d.ts +13 -0
- package/dist/storage/adapters/memoryStorage.d.ts.map +1 -1
- package/dist/storage/adapters/memoryStorage.js +19 -0
- package/dist/storage/adapters/memoryStorage.js.map +1 -1
- package/dist/storage/adapters/opfsStorage.d.ts.map +1 -1
- package/dist/storage/adapters/s3CompatibleStorage.d.ts.map +1 -1
- package/dist/storage/baseStorage.d.ts.map +1 -1
- package/dist/storage/storageFactory.d.ts.map +1 -1
- package/dist/testing/prettyReporter.d.ts +23 -0
- package/dist/testing/prettyReporter.d.ts.map +1 -0
- package/dist/testing/prettySummaryReporter.d.ts +22 -0
- package/dist/testing/prettySummaryReporter.d.ts.map +1 -0
- package/dist/types/augmentations.d.ts +48 -1
- package/dist/unified.min.js +12511 -0
- package/dist/unified.min.js.map +1 -0
- package/dist/utils/embedding.d.ts.map +1 -1
- package/dist/utils/embedding.js +1 -0
- package/dist/utils/embedding.js.map +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/tensorflowUtils.d.ts +17 -0
- package/dist/utils/tensorflowUtils.d.ts.map +1 -0
- package/dist/webhooks/webhookSystem.d.ts +114 -0
- package/dist/webhooks/webhookSystem.js +321 -0
- package/dist/webhooks/webhookSystem.js.map +1 -0
- package/package.json +11 -1
- package/dist/browserFramework.d.ts.map +0 -1
- package/dist/demo.d.ts.map +0 -1
- package/dist/distributed/configManager.d.ts.map +0 -1
- package/dist/distributed/domainDetector.d.ts.map +0 -1
- package/dist/distributed/hashPartitioner.d.ts.map +0 -1
- package/dist/distributed/healthMonitor.d.ts.map +0 -1
- package/dist/distributed/index.d.ts.map +0 -1
- package/dist/distributed/operationalModes.d.ts.map +0 -1
- package/dist/hnsw/distributedSearch.d.ts.map +0 -1
- package/dist/hnsw/optimizedHNSWIndex.d.ts.map +0 -1
- package/dist/hnsw/partitionedHNSWIndex.d.ts.map +0 -1
- package/dist/hnsw/scaledHNSWSystem.d.ts.map +0 -1
- package/dist/storage/adapters/batchS3Operations.d.ts.map +0 -1
- package/dist/storage/adapters/optimizedS3Search.d.ts.map +0 -1
- package/dist/storage/cacheManager.d.ts.map +0 -1
- package/dist/storage/enhancedCacheManager.d.ts.map +0 -1
- package/dist/storage/readOnlyOptimizations.d.ts.map +0 -1
- package/dist/types/distributedTypes.d.ts.map +0 -1
- package/dist/types/paginationTypes.d.ts.map +0 -1
- package/dist/types/tensorflowTypes.js +0 -6
- package/dist/types/tensorflowTypes.js.map +0 -1
- package/dist/utils/autoConfiguration.d.ts.map +0 -1
- package/dist/utils/cacheAutoConfig.d.ts.map +0 -1
- package/dist/utils/crypto.d.ts.map +0 -1
- package/dist/utils/fieldNameTracking.d.ts.map +0 -1
- package/dist/utils/jsonProcessing.d.ts.map +0 -1
- package/dist/utils/logger.d.ts.map +0 -1
- package/dist/utils/robustModelLoader.d.ts +0 -112
- package/dist/utils/robustModelLoader.d.ts.map +0 -1
- package/dist/utils/robustModelLoader.js +0 -624
- package/dist/utils/robustModelLoader.js.map +0 -1
- package/dist/utils/searchCache.d.ts.map +0 -1
- package/dist/utils/statisticsCollector.d.ts.map +0 -1
- package/dist/utils/typeUtils.d.ts.map +0 -1
- package/dist/utils/version.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,49 +1,27 @@
|
|
|
1
|
+
# 🧠⚛️ Brainy - Lightning-Fast Vector + Graph Database with AI Intelligence
|
|
2
|
+
|
|
1
3
|
<div align="center">
|
|
2
|
-
<img src="./brainy.png" alt="Brainy Logo" width="200"/>
|
|
3
|
-
<br/><br/>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
[](https://badge.fury.io/js/%40soulcraft%2Fbrainy)
|
|
8
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
9
|
[](https://nodejs.org/)
|
|
7
10
|
[](https://www.typescriptlang.org/)
|
|
8
|
-
[](CONTRIBUTING.md)
|
|
9
11
|
|
|
10
|
-
**The world's only true Vector + Graph database -
|
|
12
|
+
**The world's only true Vector + Graph database with built-in AI intelligence**
|
|
13
|
+
**Sub-millisecond queries across millions of vectors + billions of relationships**
|
|
11
14
|
|
|
12
15
|
</div>
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
## The Problem: Three Databases for One Search
|
|
15
18
|
|
|
16
|
-
|
|
19
|
+
**"I need semantic search, relationship traversal, AND metadata filtering - that means 3+ databases"**
|
|
17
20
|
|
|
18
|
-
**
|
|
21
|
+
❌ **Current Reality**: Pinecone + Neo4j + Elasticsearch + Custom Sync = Slow, expensive, complex
|
|
22
|
+
✅ **Brainy Reality**: One blazing-fast database. One API. Everything in sync.
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
✅ **Brainy Reality**: One database. One API. All three search types.
|
|
22
|
-
|
|
23
|
-
## 🔥 The Power of Three-in-One Search
|
|
24
|
-
|
|
25
|
-
```javascript
|
|
26
|
-
// This ONE query does what used to require 3 databases:
|
|
27
|
-
const results = await brainy.search("AI startups in healthcare", 10, {
|
|
28
|
-
// 🔍 Vector: Semantic similarity
|
|
29
|
-
includeVerbs: true,
|
|
30
|
-
|
|
31
|
-
// 🔗 Graph: Relationship traversal
|
|
32
|
-
verbTypes: ["invests_in", "partners_with"],
|
|
33
|
-
|
|
34
|
-
// 📊 Faceted: MongoDB-style filtering
|
|
35
|
-
metadata: {
|
|
36
|
-
industry: "healthcare",
|
|
37
|
-
funding: { $gte: 1000000 },
|
|
38
|
-
stage: { $in: ["Series A", "Series B"] }
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
// Returns: Companies similar to your query + their relationships + matching your criteria
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Three search paradigms. One lightning-fast query. Zero complexity.**
|
|
45
|
-
|
|
46
|
-
## 🚀 Install & Go
|
|
24
|
+
## 🚀 Quick Start: 8 Lines to Production
|
|
47
25
|
|
|
48
26
|
```bash
|
|
49
27
|
npm install @soulcraft/brainy
|
|
@@ -52,550 +30,229 @@ npm install @soulcraft/brainy
|
|
|
52
30
|
```javascript
|
|
53
31
|
import { BrainyData } from '@soulcraft/brainy'
|
|
54
32
|
|
|
55
|
-
const brainy = new BrainyData() // Auto-detects
|
|
56
|
-
await brainy.init() //
|
|
33
|
+
const brainy = new BrainyData() // Auto-detects environment
|
|
34
|
+
await brainy.init() // Zero configuration
|
|
57
35
|
|
|
58
36
|
// Add data with relationships
|
|
59
37
|
const openai = await brainy.add("OpenAI", { type: "company", funding: 11000000 })
|
|
60
38
|
const gpt4 = await brainy.add("GPT-4", { type: "product", users: 100000000 })
|
|
61
39
|
await brainy.relate(openai, gpt4, "develops")
|
|
62
40
|
|
|
63
|
-
//
|
|
41
|
+
// One query, three search paradigms
|
|
64
42
|
const results = await brainy.search("AI language models", 5, {
|
|
65
|
-
metadata: { funding: { $gte: 10000000 } },
|
|
66
|
-
includeVerbs: true
|
|
67
|
-
})
|
|
43
|
+
metadata: { funding: { $gte: 10000000 } }, // MongoDB-style filtering
|
|
44
|
+
includeVerbs: true // Graph relationships
|
|
45
|
+
}) // Semantic vector search
|
|
68
46
|
```
|
|
69
47
|
|
|
70
|
-
**That's it. You just built a knowledge graph with semantic search
|
|
71
|
-
|
|
72
|
-
## ⚙️ Configuration Options
|
|
48
|
+
**That's it. You just built a knowledge graph with semantic search in 8 lines.**
|
|
73
49
|
|
|
74
|
-
|
|
50
|
+
## 🎯 Key Features: Why Developers Choose Brainy
|
|
75
51
|
|
|
76
|
-
###
|
|
77
|
-
```javascript
|
|
78
|
-
const brainy = new BrainyData() // Auto-detects everything
|
|
79
|
-
await brainy.init() // Zero config needed
|
|
52
|
+
### ⚡ Blazing Performance at Scale
|
|
80
53
|
```
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
Perfect for high-throughput data ingestion with smart caching:
|
|
86
|
-
```javascript
|
|
87
|
-
const brainy = new BrainyData({
|
|
88
|
-
writeOnly: true, // Skip search index loading
|
|
89
|
-
allowDirectReads: true // Enable ID-based lookups for deduplication
|
|
90
|
-
})
|
|
91
|
-
// ✅ Can: add(), get(), has(), exists(), getMetadata(), getBatch()
|
|
92
|
-
// ❌ Cannot: search(), similar(), query() (saves memory & startup time)
|
|
54
|
+
Vector Search (1M embeddings): 2-8ms p95 latency
|
|
55
|
+
Graph Traversal (100M relations): 1-3ms p95 latency
|
|
56
|
+
Combined Vector+Graph+Filter: 5-15ms p95 latency
|
|
57
|
+
Throughput: 10K+ queries/second
|
|
93
58
|
```
|
|
94
59
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
writeOnly: true, // No search capabilities
|
|
100
|
-
allowDirectReads: false // No read operations at all
|
|
101
|
-
})
|
|
102
|
-
// ✅ Can: add(), addBatch(), relate()
|
|
103
|
-
// ❌ Cannot: Any read operations (fastest startup)
|
|
104
|
-
```
|
|
60
|
+
### 🌍 Write Once, Run Anywhere
|
|
61
|
+
- **Same code** works in React, Vue, Angular, Node.js, Edge Workers
|
|
62
|
+
- **Auto-detects** environment and optimizes automatically
|
|
63
|
+
- **Zero config** - no setup files, no tuning parameters
|
|
105
64
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
frozen: true // Block statistics updates and optimizations
|
|
112
|
-
})
|
|
113
|
-
// ✅ Can: All search operations
|
|
114
|
-
// ❌ Cannot: add(), update(), delete()
|
|
115
|
-
```
|
|
65
|
+
### 🧠 Built-in AI Intelligence (FREE)
|
|
66
|
+
- **Neural Import**: AI understands your data structure automatically
|
|
67
|
+
- **Entity Detection**: Identifies people, companies, locations
|
|
68
|
+
- **Relationship Mapping**: Discovers connections between entities
|
|
69
|
+
- **Chat Interface**: Talk to your data naturally (v0.56+)
|
|
116
70
|
|
|
117
|
-
|
|
118
|
-
```javascript
|
|
119
|
-
const brainy = new BrainyData({
|
|
120
|
-
// Storage options
|
|
121
|
-
storage: {
|
|
122
|
-
type: 's3', // 's3', 'memory', 'filesystem'
|
|
123
|
-
requestPersistentStorage: true, // Browser: request persistent storage
|
|
124
|
-
s3Storage: {
|
|
125
|
-
bucketName: 'my-vectors',
|
|
126
|
-
region: 'us-east-1'
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
// Performance tuning
|
|
131
|
-
hnsw: {
|
|
132
|
-
maxConnections: 16, // Higher = better search quality
|
|
133
|
-
efConstruction: 200, // Higher = better index quality
|
|
134
|
-
useOptimized: true // Enable disk-based storage
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
// Embedding customization
|
|
138
|
-
embeddingFunction: myCustomEmbedder,
|
|
139
|
-
distanceFunction: 'euclidean' // 'cosine', 'euclidean', 'manhattan'
|
|
140
|
-
})
|
|
141
|
-
```
|
|
71
|
+
---
|
|
142
72
|
|
|
143
|
-
|
|
144
|
-
```javascript
|
|
145
|
-
// Microservice A (Writer)
|
|
146
|
-
const writerService = new BrainyData({
|
|
147
|
-
writeOnly: true,
|
|
148
|
-
allowDirectReads: true, // For deduplication
|
|
149
|
-
defaultService: 'data-ingestion'
|
|
150
|
-
})
|
|
73
|
+
# 🎆 NEW: Talk to Your Data with Brainy Chat!
|
|
151
74
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
readOnly: true,
|
|
155
|
-
defaultService: 'search-api'
|
|
156
|
-
})
|
|
75
|
+
```javascript
|
|
76
|
+
import { BrainyChat } from '@soulcraft/brainy'
|
|
157
77
|
|
|
158
|
-
//
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
defaultService: 'full-stack-app'
|
|
162
|
-
})
|
|
78
|
+
const chat = new BrainyChat(brainy) // That's it!
|
|
79
|
+
const answer = await chat.ask("What patterns do you see in customer behavior?")
|
|
80
|
+
// → Works instantly with zero config!
|
|
163
81
|
```
|
|
164
82
|
|
|
165
|
-
|
|
83
|
+
**One line. Zero complexity. Optional LLM for smarter responses.**
|
|
84
|
+
[📖 **Learn More About Brainy Chat**](BRAINY-CHAT.md)
|
|
166
85
|
|
|
167
|
-
|
|
168
|
-
<summary>Click to see complete configuration reference</summary>
|
|
86
|
+
## 🔥 The Power of Three-in-One Search
|
|
169
87
|
|
|
170
88
|
```javascript
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
readOnly?: boolean // Disable write operations
|
|
176
|
-
frozen?: boolean // Disable all optimizations and statistics
|
|
177
|
-
lazyLoadInReadOnlyMode?: boolean // Load index on-demand
|
|
178
|
-
|
|
179
|
-
// === Storage Configuration ===
|
|
180
|
-
storage?: {
|
|
181
|
-
type?: 'auto' | 'memory' | 'filesystem' | 's3' | 'opfs'
|
|
182
|
-
requestPersistentStorage?: boolean // Browser persistent storage
|
|
183
|
-
|
|
184
|
-
// Cloud storage options
|
|
185
|
-
s3Storage?: {
|
|
186
|
-
bucketName: string
|
|
187
|
-
region?: string
|
|
188
|
-
accessKeyId?: string
|
|
189
|
-
secretAccessKey?: string
|
|
190
|
-
},
|
|
191
|
-
|
|
192
|
-
r2Storage?: { /* Cloudflare R2 options */ },
|
|
193
|
-
gcsStorage?: { /* Google Cloud Storage options */ }
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
// === Performance Tuning ===
|
|
197
|
-
hnsw?: {
|
|
198
|
-
maxConnections?: number // Default: 16
|
|
199
|
-
efConstruction?: number // Default: 200
|
|
200
|
-
efSearch?: number // Default: 50
|
|
201
|
-
useOptimized?: boolean // Default: true
|
|
202
|
-
useDiskBasedIndex?: boolean // Default: auto-detected
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
// === Embedding & Distance ===
|
|
206
|
-
embeddingFunction?: EmbeddingFunction
|
|
207
|
-
distanceFunction?: 'cosine' | 'euclidean' | 'manhattan'
|
|
208
|
-
|
|
209
|
-
// === Service Identity ===
|
|
210
|
-
defaultService?: string // Default service name for operations
|
|
89
|
+
// This ONE query does what used to require 3 databases:
|
|
90
|
+
const results = await brainy.search("AI startups in healthcare", 10, {
|
|
91
|
+
// 🔍 Vector: Semantic similarity
|
|
92
|
+
includeVerbs: true,
|
|
211
93
|
|
|
212
|
-
//
|
|
213
|
-
|
|
214
|
-
verbose?: boolean // Enable detailed logging
|
|
215
|
-
},
|
|
94
|
+
// 🔗 Graph: Relationship traversal
|
|
95
|
+
verbTypes: ["invests_in", "partners_with"],
|
|
216
96
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
97
|
+
// 📊 Faceted: MongoDB-style filtering
|
|
98
|
+
metadata: {
|
|
99
|
+
industry: "healthcare",
|
|
100
|
+
funding: { $gte: 1000000 },
|
|
101
|
+
stage: { $in: ["Series A", "Series B"] }
|
|
220
102
|
}
|
|
221
103
|
})
|
|
104
|
+
// Returns: Companies similar to your query + their relationships + matching your criteria
|
|
222
105
|
```
|
|
223
106
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
## 🔥 MAJOR UPDATES: What's New in v0.51, v0.49 & v0.48
|
|
227
|
-
|
|
228
|
-
### 🎯 **v0.51: Revolutionary Developer Experience**
|
|
229
|
-
|
|
230
|
-
**Problem-focused approach that gets you productive in seconds!**
|
|
107
|
+
## 🌍 Works Everywhere - Same Code
|
|
231
108
|
|
|
232
|
-
|
|
233
|
-
- ✅ **8-Line Quickstart** - Three search types in one simple demo
|
|
234
|
-
- ✅ **Streamlined Documentation** - Focus on what matters most
|
|
235
|
-
- ✅ **Clear Positioning** - The only true Vector + Graph database
|
|
109
|
+
**Write once, run anywhere.** Brainy auto-detects your environment:
|
|
236
110
|
|
|
237
|
-
|
|
111
|
+
| Environment | Storage | Optimization |
|
|
112
|
+
|-------------|---------|-------------|
|
|
113
|
+
| 🌐 Browser | OPFS | Web Workers, Memory Cache |
|
|
114
|
+
| 🟢 Node.js | FileSystem / S3 | Worker Threads, Clustering |
|
|
115
|
+
| ⚡ Serverless | S3 / Memory | Cold Start Optimization |
|
|
116
|
+
| 🔥 Edge | Memory / KV | Minimal Footprint |
|
|
238
117
|
|
|
239
|
-
|
|
118
|
+
<details>
|
|
119
|
+
<summary>🔧 <strong>Advanced Configuration Options</strong></summary>
|
|
240
120
|
|
|
241
121
|
```javascript
|
|
242
|
-
//
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
// Returns: ['category', 'price', 'brand', 'rating', ...]
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
- ✅ **Filter Discovery API**: O(1) field discovery for instant filter UI generation
|
|
251
|
-
- ✅ **Improved Performance**: Removed deprecated methods, now uses pagination everywhere
|
|
252
|
-
- ✅ **Better Scalability**: Hybrid indexing with O(1) field access scales to millions
|
|
253
|
-
- ✅ **Smart Caching**: LRU cache for frequently accessed filters
|
|
254
|
-
- ✅ **Zero Configuration**: Everything auto-optimizes based on usage patterns
|
|
255
|
-
|
|
256
|
-
### 🚀 **v0.48: MongoDB-Style Metadata Filtering**
|
|
122
|
+
// High-throughput writer
|
|
123
|
+
const writer = new BrainyData({
|
|
124
|
+
writeOnly: true,
|
|
125
|
+
allowDirectReads: true // For deduplication
|
|
126
|
+
})
|
|
257
127
|
|
|
258
|
-
|
|
128
|
+
// Read-only search service
|
|
129
|
+
const reader = new BrainyData({
|
|
130
|
+
readOnly: true,
|
|
131
|
+
frozen: true // No stats updates
|
|
132
|
+
})
|
|
259
133
|
|
|
260
|
-
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
134
|
+
// Custom storage
|
|
135
|
+
const custom = new BrainyData({
|
|
136
|
+
storage: {
|
|
137
|
+
type: 's3',
|
|
138
|
+
s3Storage: { bucketName: 'my-vectors' }
|
|
139
|
+
},
|
|
140
|
+
hnsw: {
|
|
141
|
+
maxConnections: 32 // Higher quality
|
|
267
142
|
}
|
|
268
143
|
})
|
|
269
144
|
```
|
|
270
145
|
|
|
271
|
-
|
|
272
|
-
- ✅ **Automatic Indexing**: Zero configuration, maximum performance
|
|
273
|
-
- ✅ **Nested Fields**: Use dot notation for complex objects
|
|
274
|
-
- ✅ **100% Backward Compatible**: Your existing code works unchanged
|
|
275
|
-
|
|
276
|
-
### ⚡ **v0.46: Transformers.js Migration**
|
|
277
|
-
|
|
278
|
-
**Replaced TensorFlow.js for better performance and true offline operation!**
|
|
146
|
+
</details>
|
|
279
147
|
|
|
280
|
-
|
|
281
|
-
- ✅ **84% Smaller Models**: 87 MB vs 525 MB models
|
|
282
|
-
- ✅ **True Offline**: Zero network calls after initial download
|
|
283
|
-
- ✅ **5x Fewer Dependencies**: Clean tree, no peer dependency issues
|
|
284
|
-
- ✅ **Same API**: Drop-in replacement, existing code works unchanged
|
|
148
|
+
## 🎮 Cortex CLI - Command Center for Everything
|
|
285
149
|
|
|
286
|
-
|
|
150
|
+
```bash
|
|
151
|
+
# Talk to your data
|
|
152
|
+
cortex chat "What patterns do you see?"
|
|
287
153
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
- **⚡ Scary Fast** - Handles millions of vectors with sub-millisecond search. GPU acceleration for embeddings, optimized CPU for distance calculations
|
|
291
|
-
- **🎯 Self-Learning** - Like having a database that goes to the gym. Gets faster and smarter the more you use it
|
|
292
|
-
- **🔮 AI-First Design** - Built for the age of embeddings, RAG, and semantic search. Your LLMs will thank you
|
|
293
|
-
- **🎮 Actually Fun to Use** - Clean API, great DX, and it does the heavy lifting so you can build cool stuff
|
|
154
|
+
# AI-powered data import
|
|
155
|
+
cortex neural import data.csv --confidence 0.8
|
|
294
156
|
|
|
295
|
-
|
|
157
|
+
# Real-time monitoring
|
|
158
|
+
cortex monitor --dashboard
|
|
296
159
|
|
|
297
|
-
|
|
160
|
+
# Start premium trials
|
|
161
|
+
cortex license trial notion
|
|
162
|
+
```
|
|
298
163
|
|
|
299
|
-
|
|
300
|
-
- **⚡ Smart Result Caching** - Repeated queries return in <1ms with automatic cache invalidation
|
|
301
|
-
- **📄 Cursor-Based Pagination** - Navigate millions of results with constant O(k) performance
|
|
302
|
-
- **🔄 Real-Time Data Sync** - Cache automatically updates when data changes, even in distributed scenarios
|
|
303
|
-
- **📊 Performance Monitoring** - Built-in hit rate and memory usage tracking with adaptive optimization
|
|
304
|
-
- **🎯 Zero Breaking Changes** - All existing code works unchanged, just faster and smarter
|
|
164
|
+
[📖 **Full Cortex Documentation**](/docs/cortex.md)
|
|
305
165
|
|
|
306
|
-
##
|
|
166
|
+
## ⚙️ Configuration (Optional)
|
|
307
167
|
|
|
308
|
-
|
|
309
|
-
- 🌍 **Runs Everywhere** - Same code: React, Node.js, serverless, edge
|
|
310
|
-
- ⚡ **Zero Config** - Auto-detects environment, optimizes itself
|
|
311
|
-
- 🔄 **Always Synced** - No data consistency nightmares between systems
|
|
312
|
-
- 📦 **Truly Offline** - Works without internet after initial setup
|
|
313
|
-
- 🔒 **Your Data** - Run locally, in browser, or your own cloud
|
|
168
|
+
Brainy works with **zero configuration**, but you can customize
|
|
314
169
|
|
|
315
|
-
## 🔮 Coming Soon
|
|
316
170
|
|
|
317
|
-
|
|
318
|
-
- **⚡ LLM Generation** - Built-in content generation powered by your knowledge graph
|
|
319
|
-
- **🌊 Real-time Sync** - Live updates across distributed instances
|
|
171
|
+
## 🆚 Why Not Just Use...?
|
|
320
172
|
|
|
321
|
-
|
|
173
|
+
### vs. Multiple Databases
|
|
174
|
+
❌ **Pinecone + Neo4j + Elasticsearch** - 3 databases, sync nightmares, 3x the cost
|
|
175
|
+
✅ **Brainy** - One database, always synced, built-in intelligence
|
|
322
176
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
**🧬 Knowledge Graphs** - Connect everything to everything. Wikipedia meets Neo4j meets magic
|
|
327
|
-
**👁️ Computer Vision Apps** - Store and search image embeddings. "Find all photos with dogs wearing hats"
|
|
328
|
-
**🎵 Music Discovery** - Find songs that "feel" similar. Spotify's Discover Weekly in your app
|
|
329
|
-
**📚 Smart Documentation** - Docs that answer questions. "How do I deploy to production?" → relevant guides
|
|
330
|
-
**🛡️ Fraud Detection** - Find patterns humans can't see. Anomaly detection on steroids
|
|
331
|
-
**🌐 Real-Time Collaboration** - Sync vector data across devices. Figma for AI data
|
|
332
|
-
**🏥 Medical Diagnosis Tools** - Match symptoms to conditions using embedding similarity
|
|
177
|
+
### vs. Cloud-Only Vector DBs
|
|
178
|
+
❌ **Pinecone/Weaviate/Qdrant** - Vendor lock-in, expensive, cloud-only
|
|
179
|
+
✅ **Brainy** - Run anywhere, your data stays yours, cost-effective
|
|
333
180
|
|
|
334
|
-
|
|
181
|
+
### vs. Graph DBs with "Vector Features"
|
|
182
|
+
❌ **Neo4j + vector plugin** - Bolt-on solution, not native, limited
|
|
183
|
+
✅ **Brainy** - Native vector+graph architecture from the ground up
|
|
335
184
|
|
|
336
|
-
|
|
185
|
+
## 💎 Premium Features (Optional)
|
|
337
186
|
|
|
338
|
-
|
|
187
|
+
**Core Brainy is FREE forever. Premium features for enterprise needs:**
|
|
339
188
|
|
|
340
|
-
|
|
341
|
-
|
|
189
|
+
### 🔗 Enterprise Connectors (14-day trials)
|
|
190
|
+
- **Notion** ($49/mo) - Bidirectional workspace sync
|
|
191
|
+
- **Salesforce** ($99/mo) - CRM integration
|
|
192
|
+
- **Slack** ($49/mo) - Team collaboration
|
|
193
|
+
- **Asana** ($44/mo) - Project management
|
|
342
194
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
195
|
+
```bash
|
|
196
|
+
cortex license trial notion # Start free trial
|
|
197
|
+
```
|
|
346
198
|
|
|
347
|
-
|
|
348
|
-
const john = await brainy.add("John is a software engineer", { type: "person" })
|
|
349
|
-
const jane = await brainy.add("Jane is a data scientist", { type: "person" })
|
|
350
|
-
const ai = await brainy.add("AI Project", { type: "project" })
|
|
199
|
+
**No vendor lock-in. Your data stays yours.**
|
|
351
200
|
|
|
352
|
-
|
|
353
|
-
await brainy.relate(jane, ai, "leads")
|
|
201
|
+
## 🎨 What You Can Build
|
|
354
202
|
|
|
355
|
-
|
|
356
|
-
|
|
203
|
+
- **🤖 AI Chat Applications** - ChatGPT-like apps with long-term memory
|
|
204
|
+
- **🔍 Semantic Search** - Search by meaning, not keywords
|
|
205
|
+
- **🎯 Recommendation Engines** - "Users who liked this also liked..."
|
|
206
|
+
- **🧬 Knowledge Graphs** - Connect everything to everything
|
|
207
|
+
- **🛡️ Fraud Detection** - Find patterns humans can't see
|
|
208
|
+
- **📚 Smart Documentation** - Docs that answer questions
|
|
357
209
|
|
|
358
|
-
// Traverse relationships
|
|
359
|
-
const team = await brainy.getVerbsByTarget(ai) // Who works on AI Project?
|
|
360
|
-
```
|
|
361
210
|
|
|
362
211
|
<details>
|
|
363
|
-
<summary>📦 <strong>
|
|
212
|
+
<summary>📦 <strong>Framework Examples</strong></summary>
|
|
364
213
|
|
|
214
|
+
### React
|
|
365
215
|
```jsx
|
|
366
216
|
import { BrainyData } from '@soulcraft/brainy'
|
|
367
|
-
import { useEffect, useState } from 'react'
|
|
368
|
-
|
|
369
|
-
function Search() {
|
|
370
|
-
const [brainy, setBrainy] = useState(null)
|
|
371
|
-
const [results, setResults] = useState([])
|
|
372
|
-
|
|
373
|
-
useEffect(() => {
|
|
374
|
-
const init = async () => {
|
|
375
|
-
const db = new BrainyData()
|
|
376
|
-
await db.init()
|
|
377
|
-
// Add your data...
|
|
378
|
-
setBrainy(db)
|
|
379
|
-
}
|
|
380
|
-
init()
|
|
381
|
-
}, [])
|
|
382
217
|
|
|
218
|
+
function App() {
|
|
219
|
+
const [brainy] = useState(() => new BrainyData())
|
|
220
|
+
useEffect(() => brainy.init(), [])
|
|
221
|
+
|
|
383
222
|
const search = async (query) => {
|
|
384
|
-
|
|
385
|
-
setResults(results)
|
|
223
|
+
return await brainy.search(query, 10)
|
|
386
224
|
}
|
|
387
|
-
|
|
388
|
-
return <input onChange={(e) => search(e.target.value)} placeholder="Search..." />
|
|
389
225
|
}
|
|
390
226
|
```
|
|
391
227
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
<
|
|
395
|
-
|
|
228
|
+
### Vue 3
|
|
229
|
+
```vue
|
|
230
|
+
<script setup>
|
|
231
|
+
const brainy = new BrainyData()
|
|
232
|
+
await brainy.init()
|
|
233
|
+
</script>
|
|
234
|
+
```
|
|
396
235
|
|
|
236
|
+
### Angular
|
|
397
237
|
```typescript
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
@Component({
|
|
402
|
-
selector: 'app-search',
|
|
403
|
-
template: `<input (input)="search($event.target.value)" placeholder="Search...">`
|
|
404
|
-
})
|
|
405
|
-
export class SearchComponent implements OnInit {
|
|
238
|
+
@Component({})
|
|
239
|
+
export class AppComponent {
|
|
406
240
|
brainy = new BrainyData()
|
|
407
|
-
|
|
408
241
|
async ngOnInit() {
|
|
409
242
|
await this.brainy.init()
|
|
410
|
-
// Add your data...
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
async search(query: string) {
|
|
414
|
-
const results = await this.brainy.search(query, 5)
|
|
415
|
-
// Display results...
|
|
416
243
|
}
|
|
417
244
|
}
|
|
418
245
|
```
|
|
419
246
|
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
<details>
|
|
423
|
-
<summary>📦 <strong>Full Vue Example</strong></summary>
|
|
424
|
-
|
|
425
|
-
```vue
|
|
426
|
-
<script setup>
|
|
427
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
428
|
-
import { ref, onMounted } from 'vue'
|
|
429
|
-
|
|
430
|
-
const brainy = ref(null)
|
|
431
|
-
const results = ref([])
|
|
432
|
-
|
|
433
|
-
onMounted(async () => {
|
|
434
|
-
const db = new BrainyData()
|
|
435
|
-
await db.init()
|
|
436
|
-
// Add your data...
|
|
437
|
-
brainy.value = db
|
|
438
|
-
})
|
|
439
|
-
|
|
440
|
-
const search = async (query) => {
|
|
441
|
-
const results = await brainy.value?.search(query, 5) || []
|
|
442
|
-
setResults(results)
|
|
443
|
-
}
|
|
444
|
-
</script>
|
|
445
|
-
|
|
446
|
-
<template>
|
|
447
|
-
<input @input="search($event.target.value)" placeholder="Search..." />
|
|
448
|
-
</template>
|
|
449
|
-
```
|
|
450
|
-
|
|
451
|
-
</details>
|
|
452
|
-
|
|
453
|
-
### 🟢 Node.js / Serverless / Edge
|
|
454
|
-
|
|
247
|
+
### Node.js
|
|
455
248
|
```javascript
|
|
456
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
457
|
-
|
|
458
|
-
// SAME CODE works in Node.js, Vercel, Netlify, Cloudflare Workers, Deno, Bun
|
|
459
249
|
const brainy = new BrainyData()
|
|
460
|
-
await brainy.init() // Auto-detects environment and optimizes
|
|
461
|
-
|
|
462
|
-
// Add entities and relationships
|
|
463
|
-
await brainy.add("Python is great for data science", { type: "fact" })
|
|
464
|
-
await brainy.add("JavaScript rules the web", { type: "fact" })
|
|
465
|
-
|
|
466
|
-
// Search by meaning
|
|
467
|
-
const results = await brainy.search("programming languages", 5)
|
|
468
|
-
|
|
469
|
-
// Optional: Production with S3/R2 storage (auto-detected in cloud environments)
|
|
470
|
-
const productionBrainy = new BrainyData({
|
|
471
|
-
storage: {
|
|
472
|
-
s3Storage: { bucketName: process.env.BUCKET_NAME }
|
|
473
|
-
}
|
|
474
|
-
})
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
**That's it! Same code, everywhere. Zero-to-Smart™**
|
|
478
|
-
|
|
479
|
-
Brainy automatically detects and optimizes for your environment:
|
|
480
|
-
|
|
481
|
-
| Environment | Storage | Optimization |
|
|
482
|
-
|-------------|---------|-------------|
|
|
483
|
-
| 🌐 Browser | OPFS | Web Workers, Memory Cache |
|
|
484
|
-
| 🟢 Node.js | FileSystem / S3 | Worker Threads, Clustering |
|
|
485
|
-
| ⚡ Serverless | S3 / Memory | Cold Start Optimization |
|
|
486
|
-
| 🔥 Edge | Memory / KV | Minimal Footprint |
|
|
487
|
-
|
|
488
|
-
## 🌐 Distributed Mode (NEW!)
|
|
489
|
-
|
|
490
|
-
**Scale horizontally with zero configuration!** Brainy now supports distributed deployments with automatic coordination:
|
|
491
|
-
|
|
492
|
-
- **🌐 Multi-Instance Coordination** - Multiple readers and writers working in harmony
|
|
493
|
-
- **🏷️ Smart Domain Detection** - Automatically categorizes data (medical, legal, product, etc.)
|
|
494
|
-
- **📊 Real-Time Health Monitoring** - Track performance across all instances
|
|
495
|
-
- **🔄 Automatic Role Optimization** - Readers optimize for cache, writers for throughput
|
|
496
|
-
- **🗂️ Intelligent Partitioning** - Hash-based partitioning for perfect load distribution
|
|
497
|
-
|
|
498
|
-
```javascript
|
|
499
|
-
// Writer Instance - Ingests data from multiple sources
|
|
500
|
-
const writer = new BrainyData({
|
|
501
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
502
|
-
distributed: { role: 'writer' } // Explicit role for safety
|
|
503
|
-
})
|
|
504
|
-
|
|
505
|
-
// Reader Instance - Optimized for search queries
|
|
506
|
-
const reader = new BrainyData({
|
|
507
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
508
|
-
distributed: { role: 'reader' } // 80% memory for cache
|
|
509
|
-
})
|
|
510
|
-
|
|
511
|
-
// Data automatically gets domain tags
|
|
512
|
-
await writer.add("Patient shows symptoms of...", {
|
|
513
|
-
diagnosis: "flu" // Auto-tagged as 'medical' domain
|
|
514
|
-
})
|
|
515
|
-
|
|
516
|
-
// Domain-aware search across all partitions
|
|
517
|
-
const results = await reader.search("medical symptoms", 10, {
|
|
518
|
-
filter: { domain: 'medical' } // Only search medical data
|
|
519
|
-
})
|
|
520
|
-
|
|
521
|
-
// Monitor health across all instances
|
|
522
|
-
const health = reader.getHealthStatus()
|
|
523
|
-
console.log(`Instance ${health.instanceId}: ${health.status}`)
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
### 🐳 NEW: Zero-Config Docker Deployment
|
|
527
|
-
|
|
528
|
-
**Deploy to any cloud with embedded models - no runtime downloads needed!**
|
|
529
|
-
|
|
530
|
-
```dockerfile
|
|
531
|
-
# One line extracts models automatically during build
|
|
532
|
-
RUN npm run download-models
|
|
533
|
-
|
|
534
|
-
# Deploy anywhere: Google Cloud, AWS, Azure, Cloudflare, etc.
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
- **⚡ 7x Faster Cold Starts** - Models embedded in container, no downloads
|
|
538
|
-
- **🌐 Universal Cloud Support** - Same Dockerfile works everywhere
|
|
539
|
-
- **🔒 Offline Ready** - No external dependencies at runtime
|
|
540
|
-
- **📦 Zero Configuration** - Automatic model detection and loading
|
|
541
|
-
|
|
542
|
-
```javascript
|
|
543
|
-
// Zero configuration - everything optimized automatically!
|
|
544
|
-
const brainy = new BrainyData() // Auto-detects environment & optimizes
|
|
545
250
|
await brainy.init()
|
|
546
|
-
|
|
547
|
-
// Caching happens automatically - no setup needed!
|
|
548
|
-
const results1 = await brainy.search('query', 10) // ~50ms first time
|
|
549
|
-
const results2 = await brainy.search('query', 10) // <1ms cached hit!
|
|
550
|
-
|
|
551
|
-
// Advanced pagination works instantly
|
|
552
|
-
const page1 = await brainy.searchWithCursor('query', 100)
|
|
553
|
-
const page2 = await brainy.searchWithCursor('query', 100, {
|
|
554
|
-
cursor: page1.cursor // Constant time, no matter how deep!
|
|
555
|
-
})
|
|
556
|
-
|
|
557
|
-
// Monitor auto-optimized performance
|
|
558
|
-
const stats = brainy.getCacheStats()
|
|
559
|
-
console.log(`Auto-tuned cache hit rate: ${(stats.search.hitRate * 100).toFixed(1)}%`)
|
|
560
251
|
```
|
|
561
252
|
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
### Core Capabilities
|
|
565
|
-
|
|
566
|
-
- **Vector Search** - Find semantically similar content using embeddings
|
|
567
|
-
- **MongoDB-Style Metadata Filtering** 🆕 - Advanced filtering with `$gt`, `$in`, `$regex`, `$and`, `$or` operators
|
|
568
|
-
- **Graph Relationships** - Connect data with meaningful relationships
|
|
569
|
-
- **JSON Document Search** - Search within specific fields with prioritization
|
|
570
|
-
- **Distributed Mode** - Scale horizontally with automatic coordination between instances
|
|
571
|
-
- **Real-Time Syncing** - WebSocket and WebRTC for distributed instances
|
|
572
|
-
- **Streaming Pipeline** - Process data in real-time as it flows through
|
|
573
|
-
- **Model Control Protocol** - Let AI models access your data
|
|
574
|
-
|
|
575
|
-
### Developer Experience
|
|
576
|
-
|
|
577
|
-
- **TypeScript Support** - Fully typed API with generics
|
|
578
|
-
- **Extensible Augmentations** - Customize and extend functionality
|
|
579
|
-
- **REST API** - Web service wrapper for HTTP endpoints
|
|
580
|
-
- **Auto-Complete** - IntelliSense for all APIs and types
|
|
581
|
-
|
|
582
|
-
## 🆚 Why Not Just Use...?
|
|
583
|
-
|
|
584
|
-
### vs. Multiple Databases
|
|
585
|
-
❌ **Pinecone + Neo4j + Elasticsearch** - 3 databases, sync nightmares, 3x the cost
|
|
586
|
-
✅ **Brainy** - One database, always synced, built-in intelligence
|
|
253
|
+
</details>
|
|
587
254
|
|
|
588
|
-
### vs. Traditional Solutions
|
|
589
|
-
❌ **PostgreSQL + pgvector + extensions** - Complex setup, performance issues
|
|
590
|
-
✅ **Brainy** - Zero config, purpose-built for AI, works everywhere
|
|
591
255
|
|
|
592
|
-
### vs. Cloud-Only Vector DBs
|
|
593
|
-
❌ **Pinecone/Weaviate/Qdrant** - Vendor lock-in, expensive, cloud-only
|
|
594
|
-
✅ **Brainy** - Run anywhere, your data stays yours, cost-effective
|
|
595
|
-
|
|
596
|
-
### vs. Graph Databases with "Vector Features"
|
|
597
|
-
❌ **Neo4j + vector plugin** - Bolt-on solution, not native, limited
|
|
598
|
-
✅ **Brainy** - Native vector+graph architecture from the ground up
|
|
599
256
|
|
|
600
257
|
## 📦 Advanced Features
|
|
601
258
|
|
|
@@ -605,229 +262,77 @@ console.log(`Auto-tuned cache hit rate: ${(stats.search.hitRate * 100).toFixed(1
|
|
|
605
262
|
```javascript
|
|
606
263
|
const results = await brainy.search("machine learning", 10, {
|
|
607
264
|
metadata: {
|
|
608
|
-
// Comparison operators
|
|
609
265
|
price: { $gte: 100, $lte: 1000 },
|
|
610
|
-
category: { $in: ["AI", "ML"
|
|
266
|
+
category: { $in: ["AI", "ML"] },
|
|
611
267
|
rating: { $gt: 4.5 },
|
|
612
|
-
|
|
613
|
-
// Logical operators
|
|
614
|
-
$and: [
|
|
615
|
-
{ status: "active" },
|
|
616
|
-
{ verified: true }
|
|
617
|
-
],
|
|
618
|
-
|
|
619
|
-
// Text operators
|
|
620
|
-
description: { $regex: "neural.*network", $options: "i" },
|
|
621
|
-
|
|
622
|
-
// Array operators
|
|
623
268
|
tags: { $includes: "tensorflow" }
|
|
624
269
|
}
|
|
625
270
|
})
|
|
626
271
|
```
|
|
627
272
|
|
|
628
|
-
**15+ operators
|
|
273
|
+
**15+ operators**: `$gt`, `$in`, `$regex`, `$and`, `$or`, etc.
|
|
629
274
|
|
|
630
275
|
</details>
|
|
631
276
|
|
|
632
277
|
<details>
|
|
633
|
-
<summary>🔗 <strong>Graph Relationships
|
|
278
|
+
<summary>🔗 <strong>Graph Relationships</strong></summary>
|
|
634
279
|
|
|
635
280
|
```javascript
|
|
636
|
-
// Create entities and relationships
|
|
637
281
|
const company = await brainy.add("OpenAI", { type: "company" })
|
|
638
282
|
const product = await brainy.add("GPT-4", { type: "product" })
|
|
639
|
-
const person = await brainy.add("Sam Altman", { type: "person" })
|
|
640
|
-
|
|
641
|
-
// Create meaningful relationships
|
|
642
283
|
await brainy.relate(company, product, "develops")
|
|
643
|
-
await brainy.relate(person, company, "leads")
|
|
644
|
-
await brainy.relate(product, person, "created_by")
|
|
645
|
-
|
|
646
|
-
// Traverse relationships
|
|
647
|
-
const products = await brainy.getVerbsBySource(company) // What OpenAI develops
|
|
648
|
-
const leaders = await brainy.getVerbsByTarget(company) // Who leads OpenAI
|
|
649
|
-
const connections = await brainy.findSimilar(product, {
|
|
650
|
-
relationType: "develops"
|
|
651
|
-
})
|
|
652
|
-
|
|
653
|
-
// Search with relationship context
|
|
654
|
-
const results = await brainy.search("AI models", 10, {
|
|
655
|
-
includeVerbs: true,
|
|
656
|
-
verbTypes: ["develops", "created_by"],
|
|
657
|
-
searchConnectedNouns: true
|
|
658
|
-
})
|
|
659
|
-
```
|
|
660
|
-
|
|
661
|
-
</details>
|
|
662
|
-
|
|
663
|
-
<details>
|
|
664
|
-
<summary>🌐 <strong>Universal Storage & Deployment</strong></summary>
|
|
665
284
|
|
|
666
|
-
|
|
667
|
-
// Development: File system
|
|
668
|
-
const dev = new BrainyData({
|
|
669
|
-
storage: { fileSystem: { path: './data' } }
|
|
670
|
-
})
|
|
671
|
-
|
|
672
|
-
// Production: S3/R2
|
|
673
|
-
const prod = new BrainyData({
|
|
674
|
-
storage: { s3Storage: { bucketName: 'my-vectors' } }
|
|
675
|
-
})
|
|
676
|
-
|
|
677
|
-
// Browser: OPFS
|
|
678
|
-
const browser = new BrainyData() // Auto-detects OPFS
|
|
679
|
-
|
|
680
|
-
// Edge: Memory
|
|
681
|
-
const edge = new BrainyData({
|
|
682
|
-
storage: { memory: {} }
|
|
683
|
-
})
|
|
684
|
-
|
|
685
|
-
// Redis: High performance
|
|
686
|
-
const redis = new BrainyData({
|
|
687
|
-
storage: { redis: { connectionString: 'redis://...' } }
|
|
688
|
-
})
|
|
285
|
+
const products = await brainy.getVerbsBySource(company)
|
|
689
286
|
```
|
|
690
287
|
|
|
691
|
-
**Extend with any storage**: MongoDB, PostgreSQL, DynamoDB - [see storage adapters guide](docs/api-reference/storage-adapters.md)
|
|
692
|
-
|
|
693
288
|
</details>
|
|
694
289
|
|
|
695
290
|
<details>
|
|
696
|
-
<summary>🐳 <strong>Docker
|
|
291
|
+
<summary>🐳 <strong>Docker Deployment</strong></summary>
|
|
697
292
|
|
|
698
293
|
```dockerfile
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
COPY package*.json ./
|
|
703
|
-
RUN npm ci
|
|
704
|
-
COPY . .
|
|
705
|
-
RUN npm run download-models # Embed models for offline operation
|
|
706
|
-
RUN npm run build
|
|
707
|
-
|
|
708
|
-
FROM node:24-slim AS production
|
|
709
|
-
WORKDIR /app
|
|
710
|
-
COPY package*.json ./
|
|
711
|
-
RUN npm ci --only=production
|
|
712
|
-
COPY --from=builder /app/dist ./dist
|
|
713
|
-
COPY --from=builder /app/models ./models # Offline models included
|
|
714
|
-
CMD ["node", "dist/server.js"]
|
|
294
|
+
FROM node:24-slim
|
|
295
|
+
RUN npm run download-models # Embed models
|
|
296
|
+
CMD ["node", "server.js"]
|
|
715
297
|
```
|
|
716
298
|
|
|
717
|
-
Deploy
|
|
299
|
+
Deploy anywhere: AWS, GCP, Azure, Cloudflare
|
|
718
300
|
|
|
719
301
|
</details>
|
|
720
302
|
|
|
721
|
-
## 🚀 Getting Started in 30 Seconds
|
|
722
303
|
|
|
723
|
-
|
|
304
|
+
## 📚 Documentation
|
|
724
305
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
await brainy.init()
|
|
306
|
+
- [Quick Start](docs/getting-started/)
|
|
307
|
+
- [API Reference](docs/api-reference/)
|
|
308
|
+
- [Examples](docs/examples/)
|
|
309
|
+
- [Cortex CLI](docs/cortex.md)
|
|
310
|
+
- [Performance Guide](docs/optimization-guides/)
|
|
731
311
|
|
|
732
|
-
|
|
733
|
-
const openai = await brainy.add("OpenAI", { type: "company" })
|
|
734
|
-
const gpt4 = await brainy.add("GPT-4", { type: "product" })
|
|
312
|
+
## ❓ Does Brainy Impact Performance?
|
|
735
313
|
|
|
736
|
-
|
|
737
|
-
await brainy.relate(openai, gpt4, "develops")
|
|
314
|
+
**NO - Brainy actually IMPROVES performance:**
|
|
738
315
|
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
316
|
+
✅ **Zero runtime overhead** - Premium features are lazy-loaded only when used
|
|
317
|
+
✅ **Smaller than alternatives** - 643KB vs 12.5MB for TensorFlow.js
|
|
318
|
+
✅ **Built-in caching** - 95%+ cache hit rates reduce compute
|
|
319
|
+
✅ **Automatic optimization** - Gets faster as it learns your patterns
|
|
320
|
+
✅ **No network calls** - Works completely offline after setup
|
|
743
321
|
|
|
744
|
-
|
|
745
|
-
<summary>🔍 <strong>See Framework Examples</strong></summary>
|
|
746
|
-
|
|
747
|
-
### React
|
|
748
|
-
|
|
749
|
-
```jsx
|
|
750
|
-
function App() {
|
|
751
|
-
const [brainy] = useState(() => new BrainyData())
|
|
752
|
-
useEffect(() => brainy.init(), [])
|
|
753
|
-
|
|
754
|
-
const search = async (query) => {
|
|
755
|
-
return await brainy.search(query, 10)
|
|
756
|
-
}
|
|
757
|
-
// Same API as above
|
|
758
|
-
}
|
|
759
|
-
```
|
|
760
|
-
|
|
761
|
-
### Vue 3
|
|
762
|
-
|
|
763
|
-
```vue
|
|
764
|
-
<script setup>
|
|
765
|
-
const brainy = new BrainyData()
|
|
766
|
-
await brainy.init()
|
|
767
|
-
// Same API as above
|
|
768
|
-
</script>
|
|
769
|
-
```
|
|
770
|
-
|
|
771
|
-
### Angular
|
|
772
|
-
|
|
773
|
-
```typescript
|
|
774
|
-
@Component({})
|
|
775
|
-
export class AppComponent {
|
|
776
|
-
brainy = new BrainyData()
|
|
777
|
-
|
|
778
|
-
async ngOnInit() {
|
|
779
|
-
await this.brainy.init()
|
|
780
|
-
// Same API as above
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
```
|
|
784
|
-
|
|
785
|
-
### Node.js / Deno / Bun
|
|
786
|
-
|
|
787
|
-
```javascript
|
|
788
|
-
const brainy = new BrainyData()
|
|
789
|
-
await brainy.init()
|
|
790
|
-
// Same API as above
|
|
791
|
-
```
|
|
792
|
-
|
|
793
|
-
</details>
|
|
794
|
-
|
|
795
|
-
### 🌍 Framework-First, Runs Everywhere
|
|
796
|
-
|
|
797
|
-
**Brainy automatically detects your environment and optimizes everything:**
|
|
798
|
-
|
|
799
|
-
| Environment | Storage | Optimization |
|
|
800
|
-
|-----------------|-----------------|----------------------------|
|
|
801
|
-
| 🌐 Browser | OPFS | Web Workers, Memory Cache |
|
|
802
|
-
| 🟢 Node.js | FileSystem / S3 | Worker Threads, Clustering |
|
|
803
|
-
| ⚡ Serverless | S3 / Memory | Cold Start Optimization |
|
|
804
|
-
| 🔥 Edge Workers | Memory / KV | Minimal Footprint |
|
|
805
|
-
| 🦕 Deno/Bun | FileSystem / S3 | Native Performance |
|
|
806
|
-
|
|
807
|
-
## 📚 Documentation & Resources
|
|
808
|
-
|
|
809
|
-
- **[🚀 Quick Start Guide](docs/getting-started/)** - Get up and running in minutes
|
|
810
|
-
- **[📖 API Reference](docs/api-reference/)** - Complete method documentation
|
|
811
|
-
- **[💡 Examples](docs/examples/)** - Real-world usage patterns
|
|
812
|
-
- **[⚡ Performance Guide](docs/optimization-guides/)** - Scale to millions of vectors
|
|
813
|
-
- **[🔧 Storage Adapters](docs/api-reference/storage-adapters.md)** - Universal storage compatibility
|
|
322
|
+
**The augmentation system and premium features are 100% optional and have ZERO impact unless explicitly activated.**
|
|
814
323
|
|
|
815
324
|
## 🤝 Contributing
|
|
816
325
|
|
|
817
|
-
We welcome contributions!
|
|
818
|
-
|
|
819
|
-
- [Contributing Guidelines](CONTRIBUTING.md)
|
|
820
|
-
- [Developer Documentation](docs/development/DEVELOPERS.md)
|
|
821
|
-
- [Code of Conduct](CODE_OF_CONDUCT.md)
|
|
326
|
+
We welcome contributions! See [Contributing Guidelines](CONTRIBUTING.md)
|
|
822
327
|
|
|
823
328
|
## 📄 License
|
|
824
329
|
|
|
825
|
-
[MIT](LICENSE)
|
|
330
|
+
[MIT](LICENSE) - Core Brainy is FREE forever
|
|
826
331
|
|
|
827
332
|
---
|
|
828
333
|
|
|
829
334
|
<div align="center">
|
|
830
|
-
<strong>Ready to build the future of search
|
|
335
|
+
<strong>Ready to build the future of search?</strong>
|
|
831
336
|
|
|
832
|
-
**[Get Started →](docs/getting-started/) | [
|
|
337
|
+
**[Get Started →](docs/getting-started/) | [Examples →](docs/examples/) | [Discord →](https://discord.gg/brainy)**
|
|
833
338
|
</div>
|