@soulcraft/brainy 0.50.0 → 0.51.1
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 +227 -925
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<div align="center>
|
|
1
|
+
<div align="center">
|
|
2
2
|
<img src="./brainy.png" alt="Brainy Logo" width="200"/>
|
|
3
3
|
<br/><br/>
|
|
4
4
|
|
|
@@ -11,7 +11,74 @@
|
|
|
11
11
|
|
|
12
12
|
</div>
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# The Search Problem Every Developer Faces
|
|
17
|
+
|
|
18
|
+
**"I need to find similar content, explore relationships, AND filter by metadata - but that means juggling 3+ databases"**
|
|
19
|
+
|
|
20
|
+
❌ **Current Reality**: Pinecone + Neo4j + Elasticsearch + Custom Sync Logic
|
|
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
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm install @soulcraft/brainy
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import { BrainyData } from '@soulcraft/brainy'
|
|
54
|
+
|
|
55
|
+
const brainy = new BrainyData() // Auto-detects your environment
|
|
56
|
+
await brainy.init() // Auto-configures everything
|
|
57
|
+
|
|
58
|
+
// Add data with relationships
|
|
59
|
+
const openai = await brainy.add("OpenAI", { type: "company", funding: 11000000 })
|
|
60
|
+
const gpt4 = await brainy.add("GPT-4", { type: "product", users: 100000000 })
|
|
61
|
+
await brainy.relate(openai, gpt4, "develops")
|
|
62
|
+
|
|
63
|
+
// Search across all dimensions
|
|
64
|
+
const results = await brainy.search("AI language models", 5, {
|
|
65
|
+
metadata: { funding: { $gte: 10000000 } },
|
|
66
|
+
includeVerbs: true
|
|
67
|
+
})
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**That's it. You just built a knowledge graph with semantic search and faceted filtering in 8 lines.**
|
|
71
|
+
|
|
72
|
+
## 🔥 MAJOR UPDATES: What's New in v0.51, v0.49 & v0.48
|
|
73
|
+
|
|
74
|
+
### 🎯 **v0.51: Revolutionary Developer Experience**
|
|
75
|
+
|
|
76
|
+
**Problem-focused approach that gets you productive in seconds!**
|
|
77
|
+
|
|
78
|
+
- ✅ **Problem-Solution Narrative** - Immediately understand why Brainy exists
|
|
79
|
+
- ✅ **8-Line Quickstart** - Three search types in one simple demo
|
|
80
|
+
- ✅ **Streamlined Documentation** - Focus on what matters most
|
|
81
|
+
- ✅ **Clear Positioning** - The only true Vector + Graph database
|
|
15
82
|
|
|
16
83
|
### 🎯 **v0.49: Filter Discovery & Performance Improvements**
|
|
17
84
|
|
|
@@ -62,177 +129,25 @@ const results = await brainy.search("wireless headphones", 10, {
|
|
|
62
129
|
- ✅ **5x Fewer Dependencies**: Clean tree, no peer dependency issues
|
|
63
130
|
- ✅ **Same API**: Drop-in replacement, existing code works unchanged
|
|
64
131
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
// Your existing code works unchanged!
|
|
69
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
70
|
-
|
|
71
|
-
const db = new BrainyData({
|
|
72
|
-
embedding: { type: 'transformer' } // Now uses Transformers.js automatically
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// Dimensions changed from 512 → 384 (handled automatically)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**For Docker/Production or No Egress:**
|
|
79
|
-
|
|
80
|
-
```dockerfile
|
|
81
|
-
RUN npm install @soulcraft/brainy
|
|
82
|
-
RUN npm run download-models # Download during build for offline production
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## 🏆 Industry First: True Vector + Graph Database
|
|
88
|
-
|
|
89
|
-
**Brainy is the only database that natively combines vector search and graph relationships in a single, unified system.**
|
|
90
|
-
|
|
91
|
-
Unlike other solutions that bolt vector search onto traditional databases or require multiple systems:
|
|
92
|
-
|
|
93
|
-
✅ **Native Vector + Graph Architecture** - Purpose-built for both semantic search AND knowledge graphs
|
|
94
|
-
✅ **Single API, Dual Power** - Vector similarity search AND graph traversal in one database
|
|
95
|
-
✅ **True Semantic Relationships** - Not just "similar vectors" but meaningful connections like "develops", "owns", "causes"
|
|
96
|
-
✅ **Zero Integration Complexity** - No need to sync between Pinecone + Neo4j or pgvector + graph databases
|
|
97
|
-
|
|
98
|
-
**Why This Matters:**
|
|
99
|
-
```javascript
|
|
100
|
-
// Other solutions: Manage 2+ databases
|
|
101
|
-
const vectors = await pinecone.search(query) // Vector search
|
|
102
|
-
const graph = await neo4j.run("MATCH (a)-[r]->(b)") // Graph traversal
|
|
103
|
-
// How do you keep them in sync? 😢
|
|
104
|
-
|
|
105
|
-
// Brainy: One database, both capabilities
|
|
106
|
-
const results = await brainy.search("AI models", 10, {
|
|
107
|
-
includeVerbs: true, // Include relationships
|
|
108
|
-
verbTypes: ["develops"] // Filter by relationship type
|
|
109
|
-
})
|
|
110
|
-
// Everything stays perfectly synchronized! 🎉
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
This revolutionary architecture enables entirely new classes of AI applications that were previously impossible or prohibitively complex.
|
|
114
|
-
|
|
115
|
-
## ✨ What is Brainy?
|
|
116
|
-
|
|
117
|
-
**One API. Every environment. Zero configuration.**
|
|
118
|
-
|
|
119
|
-
Brainy is the **AI-native database** that combines vector search and knowledge graphs in one unified API. Write your
|
|
120
|
-
code once, and it runs everywhere - browsers, Node.js, serverless, edge workers - with automatic optimization for each
|
|
121
|
-
environment.
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
// This same code works EVERYWHERE
|
|
125
|
-
const brainy = new BrainyData()
|
|
126
|
-
await brainy.init()
|
|
127
|
-
|
|
128
|
-
// Vector search (like Pinecone) + Graph database (like Neo4j)
|
|
129
|
-
await brainy.add("OpenAI", { type: "company" }) // Nouns
|
|
130
|
-
await brainy.relate(openai, gpt4, "develops") // Verbs
|
|
131
|
-
const results = await brainy.search("AI", 10) // Semantic search
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### 🆕 NEW: Distributed Mode (v0.38+)
|
|
135
|
-
|
|
136
|
-
**Scale horizontally with zero configuration!** Brainy now supports distributed deployments with automatic coordination:
|
|
137
|
-
|
|
138
|
-
- **🌐 Multi-Instance Coordination** - Multiple readers and writers working in harmony
|
|
139
|
-
- **🏷️ Smart Domain Detection** - Automatically categorizes data (medical, legal, product, etc.)
|
|
140
|
-
- **📊 Real-Time Health Monitoring** - Track performance across all instances
|
|
141
|
-
- **🔄 Automatic Role Optimization** - Readers optimize for cache, writers for throughput
|
|
142
|
-
- **🗂️ Intelligent Partitioning** - Hash-based partitioning for perfect load distribution
|
|
143
|
-
|
|
144
|
-
### 🚀 Why Developers Love Brainy
|
|
145
|
-
|
|
146
|
-
- **🧠 Zero-to-Smart™** - No config files, no tuning parameters, no DevOps headaches. Brainy auto-detects your
|
|
147
|
-
environment and optimizes itself
|
|
148
|
-
- **🌍 True Write-Once, Run-Anywhere** - Same code runs in Angular, React, Vue, Node.js, Deno, Bun, serverless, edge
|
|
149
|
-
workers, and web workers with automatic environment detection
|
|
150
|
-
- **⚡ Scary Fast** - Handles millions of vectors with sub-millisecond search. GPU acceleration for embeddings, optimized
|
|
151
|
-
CPU for distance calculations
|
|
152
|
-
- **🎯 Self-Learning** - Like having a database that goes to the gym. Gets faster and smarter the more you use it
|
|
153
|
-
- **🔮 AI-First Design** - Built for the age of embeddings, RAG, and semantic search. Your LLMs will thank you
|
|
154
|
-
- **🎮 Actually Fun to Use** - Clean API, great DX, and it does the heavy lifting so you can build cool stuff
|
|
155
|
-
|
|
156
|
-
### 🚀 NEW: Ultra-Fast Search Performance + Auto-Configuration
|
|
157
|
-
|
|
158
|
-
**Your searches just got 100x faster AND Brainy now configures itself!** Advanced performance with zero setup:
|
|
159
|
-
|
|
160
|
-
- **🤖 Intelligent Auto-Configuration** - Detects environment and usage patterns, optimizes automatically
|
|
161
|
-
- **⚡ Smart Result Caching** - Repeated queries return in <1ms with automatic cache invalidation
|
|
162
|
-
- **📄 Cursor-Based Pagination** - Navigate millions of results with constant O(k) performance
|
|
163
|
-
- **🔄 Real-Time Data Sync** - Cache automatically updates when data changes, even in distributed scenarios
|
|
164
|
-
- **📊 Performance Monitoring** - Built-in hit rate and memory usage tracking with adaptive optimization
|
|
165
|
-
- **🎯 Zero Breaking Changes** - All existing code works unchanged, just faster and smarter
|
|
166
|
-
|
|
167
|
-
## 📦 Get Started in 30 Seconds
|
|
168
|
-
|
|
169
|
-
```bash
|
|
170
|
-
npm install @soulcraft/brainy
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
```javascript
|
|
174
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
175
|
-
|
|
176
|
-
// Same code works EVERYWHERE - browser, Node.js, cloud, edge
|
|
177
|
-
const brainy = new BrainyData()
|
|
178
|
-
await brainy.init() // Auto-detects your environment
|
|
179
|
-
|
|
180
|
-
// 1️⃣ Simple vector search (like Pinecone)
|
|
181
|
-
await brainy.add("The quick brown fox jumps over the lazy dog", { type: "sentence" })
|
|
182
|
-
await brainy.add("Cats are independent and mysterious animals", { type: "sentence" })
|
|
132
|
+
## 🏆 Why Brainy Wins
|
|
183
133
|
|
|
184
|
-
|
|
185
|
-
|
|
134
|
+
- 🧠 **Triple Search Power** - Vector + Graph + Faceted filtering in one query
|
|
135
|
+
- 🌍 **Runs Everywhere** - Same code: React, Node.js, serverless, edge
|
|
136
|
+
- ⚡ **Zero Config** - Auto-detects environment, optimizes itself
|
|
137
|
+
- 🔄 **Always Synced** - No data consistency nightmares between systems
|
|
138
|
+
- 📦 **Truly Offline** - Works without internet after initial setup
|
|
139
|
+
- 🔒 **Your Data** - Run locally, in browser, or your own cloud
|
|
186
140
|
|
|
187
|
-
|
|
188
|
-
const openai = await brainy.add("OpenAI", { type: "company", founded: 2015 })
|
|
189
|
-
const gpt4 = await brainy.add("GPT-4", { type: "product", released: 2023 })
|
|
190
|
-
const sam = await brainy.add("Sam Altman", { type: "person", role: "CEO" })
|
|
141
|
+
## 🔮 Coming Soon
|
|
191
142
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
await brainy.relate(gpt4, sam, "created_by")
|
|
196
|
-
|
|
197
|
-
// 3️⃣ Combined power: Vector search + Graph traversal
|
|
198
|
-
const similar = await brainy.search("AI language models", 10) // Find by meaning
|
|
199
|
-
const products = await brainy.getVerbsBySource(openai) // Get relationships
|
|
200
|
-
const graph = await brainy.findSimilar(gpt4, { relationType: "develops" })
|
|
201
|
-
|
|
202
|
-
// 4️⃣ Advanced: Search with context
|
|
203
|
-
const contextual = await brainy.search("Who leads AI companies?", 5, {
|
|
204
|
-
includeVerbs: true, // Include relationships in results
|
|
205
|
-
nounTypes: ["person"], // Filter to specific entity types
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
// 5️⃣ NEW! MongoDB-style metadata filtering
|
|
209
|
-
const filtered = await brainy.search("AI research", 10, {
|
|
210
|
-
metadata: {
|
|
211
|
-
type: "academic",
|
|
212
|
-
year: { $gte: 2020 },
|
|
213
|
-
status: { $in: ["published", "peer-reviewed"] },
|
|
214
|
-
impact: { $gt: 100 }
|
|
215
|
-
}
|
|
216
|
-
})
|
|
217
|
-
// Filters DURING search for maximum performance!
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
**🎯 That's it!** Vector search + graph database + works everywhere. No config needed.
|
|
221
|
-
|
|
222
|
-
### 🔍 Want More Power?
|
|
223
|
-
|
|
224
|
-
- **Advanced graph traversal** - Complex relationship queries and multi-hop searches
|
|
225
|
-
- **Distributed clustering** - Scale across multiple instances with automatic coordination
|
|
226
|
-
- **Real-time syncing** - WebSocket and WebRTC for live data updates
|
|
227
|
-
- **Custom augmentations** - Extend Brainy with your own functionality
|
|
228
|
-
|
|
229
|
-
*[See full API documentation below](#-installation) for advanced features*
|
|
143
|
+
- **🤖 MCP Integration** - Let Claude, GPT, and other AI models query your data directly
|
|
144
|
+
- **⚡ LLM Generation** - Built-in content generation powered by your knowledge graph
|
|
145
|
+
- **🌊 Real-time Sync** - Live updates across distributed instances
|
|
230
146
|
|
|
231
147
|
## 🎨 Build Amazing Things
|
|
232
148
|
|
|
233
149
|
**🤖 AI Chat Applications** - Build ChatGPT-like apps with long-term memory and context awareness
|
|
234
|
-
**🔍 Semantic Search Engines** - Search by meaning, not keywords. Find "that thing that's like a cat but bigger" →
|
|
235
|
-
returns "tiger"
|
|
150
|
+
**🔍 Semantic Search Engines** - Search by meaning, not keywords. Find "that thing that's like a cat but bigger" → returns "tiger"
|
|
236
151
|
**🎯 Recommendation Engines** - "Users who liked this also liked..." but actually good
|
|
237
152
|
**🧬 Knowledge Graphs** - Connect everything to everything. Wikipedia meets Neo4j meets magic
|
|
238
153
|
**👁️ Computer Vision Apps** - Store and search image embeddings. "Find all photos with dogs wearing hats"
|
|
@@ -242,7 +157,7 @@ returns "tiger"
|
|
|
242
157
|
**🌐 Real-Time Collaboration** - Sync vector data across devices. Figma for AI data
|
|
243
158
|
**🏥 Medical Diagnosis Tools** - Match symptoms to conditions using embedding similarity
|
|
244
159
|
|
|
245
|
-
##
|
|
160
|
+
## 🌍 Works Everywhere - Same Code
|
|
246
161
|
|
|
247
162
|
**Write once, run anywhere.** Brainy auto-detects your environment and optimizes automatically:
|
|
248
163
|
|
|
@@ -271,35 +186,7 @@ const team = await brainy.getVerbsByTarget(ai) // Who works on AI Project?
|
|
|
271
186
|
```
|
|
272
187
|
|
|
273
188
|
<details>
|
|
274
|
-
<summary>📦 Full
|
|
275
|
-
|
|
276
|
-
```typescript
|
|
277
|
-
import { Component, signal, OnInit } from '@angular/core'
|
|
278
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
279
|
-
|
|
280
|
-
@Component({
|
|
281
|
-
selector: 'app-search',
|
|
282
|
-
template: `<input (input)="search($event.target.value)" placeholder="Search...">`
|
|
283
|
-
})
|
|
284
|
-
export class SearchComponent implements OnInit {
|
|
285
|
-
brainy = new BrainyData()
|
|
286
|
-
|
|
287
|
-
async ngOnInit() {
|
|
288
|
-
await this.brainy.init()
|
|
289
|
-
// Add your data...
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
async search(query: string) {
|
|
293
|
-
const results = await this.brainy.search(query, 5)
|
|
294
|
-
// Display results...
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
```
|
|
298
|
-
|
|
299
|
-
</details>
|
|
300
|
-
|
|
301
|
-
<details>
|
|
302
|
-
<summary>📦 Full React Example</summary>
|
|
189
|
+
<summary>📦 <strong>Full React Component Example</strong></summary>
|
|
303
190
|
|
|
304
191
|
```jsx
|
|
305
192
|
import { BrainyData } from '@soulcraft/brainy'
|
|
@@ -331,10 +218,37 @@ function Search() {
|
|
|
331
218
|
</details>
|
|
332
219
|
|
|
333
220
|
<details>
|
|
334
|
-
<summary>📦 Full
|
|
221
|
+
<summary>📦 <strong>Full Angular Component Example</strong></summary>
|
|
335
222
|
|
|
336
|
-
```
|
|
223
|
+
```typescript
|
|
224
|
+
import { Component, signal, OnInit } from '@angular/core'
|
|
225
|
+
import { BrainyData } from '@soulcraft/brainy'
|
|
226
|
+
|
|
227
|
+
@Component({
|
|
228
|
+
selector: 'app-search',
|
|
229
|
+
template: `<input (input)="search($event.target.value)" placeholder="Search...">`
|
|
230
|
+
})
|
|
231
|
+
export class SearchComponent implements OnInit {
|
|
232
|
+
brainy = new BrainyData()
|
|
233
|
+
|
|
234
|
+
async ngOnInit() {
|
|
235
|
+
await this.brainy.init()
|
|
236
|
+
// Add your data...
|
|
237
|
+
}
|
|
337
238
|
|
|
239
|
+
async search(query: string) {
|
|
240
|
+
const results = await this.brainy.search(query, 5)
|
|
241
|
+
// Display results...
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
</details>
|
|
247
|
+
|
|
248
|
+
<details>
|
|
249
|
+
<summary>📦 <strong>Full Vue Example</strong></summary>
|
|
250
|
+
|
|
251
|
+
```vue
|
|
338
252
|
<script setup>
|
|
339
253
|
import { BrainyData } from '@soulcraft/brainy'
|
|
340
254
|
import { ref, onMounted } from 'vue'
|
|
@@ -388,64 +302,34 @@ const productionBrainy = new BrainyData({
|
|
|
388
302
|
|
|
389
303
|
**That's it! Same code, everywhere. Zero-to-Smart™**
|
|
390
304
|
|
|
391
|
-
Brainy automatically detects and optimizes for:
|
|
392
|
-
|
|
393
|
-
- 🌐 **Browser frameworks** → OPFS storage, Web Workers, memory optimization
|
|
394
|
-
- 🟢 **Node.js servers** → FileSystem or S3/R2 storage, Worker threads, cluster support
|
|
395
|
-
- ⚡ **Serverless functions** → S3/R2 or Memory storage, cold start optimization
|
|
396
|
-
- 🔥 **Edge workers** → Memory or KV storage, minimal footprint
|
|
397
|
-
- 🧵 **Web/Worker threads** → Shared storage, thread-safe operations
|
|
398
|
-
- 🦕 **Deno/Bun runtimes** → FileSystem or S3-compatible storage, native performance
|
|
399
|
-
|
|
400
|
-
### 🐳 NEW: Zero-Config Docker Deployment
|
|
401
|
-
|
|
402
|
-
**Deploy to any cloud with embedded models - no runtime downloads needed!**
|
|
403
|
-
|
|
404
|
-
```dockerfile
|
|
405
|
-
# One line extracts models automatically during build
|
|
406
|
-
RUN npm run download-models
|
|
407
|
-
|
|
408
|
-
# Deploy anywhere: Google Cloud, AWS, Azure, Cloudflare, etc.
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
- **⚡ 7x Faster Cold Starts** - Models embedded in container, no downloads
|
|
412
|
-
- **🌐 Universal Cloud Support** - Same Dockerfile works everywhere
|
|
413
|
-
- **🔒 Offline Ready** - No external dependencies at runtime
|
|
414
|
-
- **📦 Zero Configuration** - Automatic model detection and loading
|
|
305
|
+
Brainy automatically detects and optimizes for your environment:
|
|
415
306
|
|
|
416
|
-
|
|
307
|
+
| Environment | Storage | Optimization |
|
|
308
|
+
|-------------|---------|-------------|
|
|
309
|
+
| 🌐 Browser | OPFS | Web Workers, Memory Cache |
|
|
310
|
+
| 🟢 Node.js | FileSystem / S3 | Worker Threads, Clustering |
|
|
311
|
+
| ⚡ Serverless | S3 / Memory | Cold Start Optimization |
|
|
312
|
+
| 🔥 Edge | Memory / KV | Minimal Footprint |
|
|
417
313
|
|
|
418
|
-
|
|
419
|
-
// Zero configuration - everything optimized automatically!
|
|
420
|
-
const brainy = new BrainyData() // Auto-detects environment & optimizes
|
|
421
|
-
await brainy.init()
|
|
422
|
-
|
|
423
|
-
// Caching happens automatically - no setup needed!
|
|
424
|
-
const results1 = await brainy.search('query', 10) // ~50ms first time
|
|
425
|
-
const results2 = await brainy.search('query', 10) // <1ms cached hit!
|
|
426
|
-
|
|
427
|
-
// Advanced pagination works instantly
|
|
428
|
-
const page1 = await brainy.searchWithCursor('query', 100)
|
|
429
|
-
const page2 = await brainy.searchWithCursor('query', 100, {
|
|
430
|
-
cursor: page1.cursor // Constant time, no matter how deep!
|
|
431
|
-
})
|
|
314
|
+
## 🌐 Distributed Mode (NEW!)
|
|
432
315
|
|
|
433
|
-
|
|
434
|
-
const stats = brainy.getCacheStats()
|
|
435
|
-
console.log(`Auto-tuned cache hit rate: ${(stats.search.hitRate * 100).toFixed(1)}%`)
|
|
436
|
-
```
|
|
316
|
+
**Scale horizontally with zero configuration!** Brainy now supports distributed deployments with automatic coordination:
|
|
437
317
|
|
|
438
|
-
|
|
318
|
+
- **🌐 Multi-Instance Coordination** - Multiple readers and writers working in harmony
|
|
319
|
+
- **🏷️ Smart Domain Detection** - Automatically categorizes data (medical, legal, product, etc.)
|
|
320
|
+
- **📊 Real-Time Health Monitoring** - Track performance across all instances
|
|
321
|
+
- **🔄 Automatic Role Optimization** - Readers optimize for cache, writers for throughput
|
|
322
|
+
- **🗂️ Intelligent Partitioning** - Hash-based partitioning for perfect load distribution
|
|
439
323
|
|
|
440
324
|
```javascript
|
|
441
325
|
// Writer Instance - Ingests data from multiple sources
|
|
442
|
-
const writer =
|
|
326
|
+
const writer = new BrainyData({
|
|
443
327
|
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
444
328
|
distributed: { role: 'writer' } // Explicit role for safety
|
|
445
329
|
})
|
|
446
330
|
|
|
447
331
|
// Reader Instance - Optimized for search queries
|
|
448
|
-
const reader =
|
|
332
|
+
const reader = new BrainyData({
|
|
449
333
|
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
450
334
|
distributed: { role: 'reader' } // 80% memory for cache
|
|
451
335
|
})
|
|
@@ -465,736 +349,152 @@ const health = reader.getHealthStatus()
|
|
|
465
349
|
console.log(`Instance ${health.instanceId}: ${health.status}`)
|
|
466
350
|
```
|
|
467
351
|
|
|
468
|
-
##
|
|
469
|
-
|
|
470
|
-
### Core Capabilities
|
|
352
|
+
## 🆚 Why Not Just Use...?
|
|
471
353
|
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
- **JSON Document Search** - Search within specific fields with prioritization
|
|
476
|
-
- **Distributed Mode** - Scale horizontally with automatic coordination between instances
|
|
477
|
-
- **Real-Time Syncing** - WebSocket and WebRTC for distributed instances
|
|
478
|
-
- **Streaming Pipeline** - Process data in real-time as it flows through
|
|
479
|
-
- **Model Control Protocol** - Let AI models access your data
|
|
354
|
+
### vs. Multiple Databases
|
|
355
|
+
❌ **Pinecone + Neo4j + Elasticsearch** - 3 databases, sync nightmares, 3x the cost
|
|
356
|
+
✅ **Brainy** - One database, always synced, built-in intelligence
|
|
480
357
|
|
|
481
|
-
###
|
|
358
|
+
### vs. Traditional Solutions
|
|
359
|
+
❌ **PostgreSQL + pgvector + extensions** - Complex setup, performance issues
|
|
360
|
+
✅ **Brainy** - Zero config, purpose-built for AI, works everywhere
|
|
482
361
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
- **Auto-Complete** - IntelliSense for all APIs and types
|
|
362
|
+
### vs. Cloud-Only Vector DBs
|
|
363
|
+
❌ **Pinecone/Weaviate/Qdrant** - Vendor lock-in, expensive, cloud-only
|
|
364
|
+
✅ **Brainy** - Run anywhere, your data stays yours, cost-effective
|
|
487
365
|
|
|
488
|
-
|
|
366
|
+
### vs. Graph Databases with "Vector Features"
|
|
367
|
+
❌ **Neo4j + vector plugin** - Bolt-on solution, not native, limited
|
|
368
|
+
✅ **Brainy** - Native vector+graph architecture from the ground up
|
|
489
369
|
|
|
490
|
-
|
|
370
|
+
## 📦 Advanced Features
|
|
491
371
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
### ✨ Write-Once, Run-Anywhere Architecture
|
|
497
|
-
|
|
498
|
-
**Same code, every environment.** Brainy auto-detects and optimizes for your runtime:
|
|
372
|
+
<details>
|
|
373
|
+
<summary>🔧 <strong>MongoDB-Style Metadata Filtering</strong></summary>
|
|
499
374
|
|
|
500
375
|
```javascript
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
//
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
376
|
+
const results = await brainy.search("machine learning", 10, {
|
|
377
|
+
metadata: {
|
|
378
|
+
// Comparison operators
|
|
379
|
+
price: { $gte: 100, $lte: 1000 },
|
|
380
|
+
category: { $in: ["AI", "ML", "Data"] },
|
|
381
|
+
rating: { $gt: 4.5 },
|
|
382
|
+
|
|
383
|
+
// Logical operators
|
|
384
|
+
$and: [
|
|
385
|
+
{ status: "active" },
|
|
386
|
+
{ verified: true }
|
|
387
|
+
],
|
|
388
|
+
|
|
389
|
+
// Text operators
|
|
390
|
+
description: { $regex: "neural.*network", $options: "i" },
|
|
391
|
+
|
|
392
|
+
// Array operators
|
|
393
|
+
tags: { $includes: "tensorflow" }
|
|
394
|
+
}
|
|
514
395
|
})
|
|
396
|
+
```
|
|
515
397
|
|
|
516
|
-
|
|
517
|
-
await brainy.addVerb(companyId, productId, undefined, { type: "develops" })
|
|
518
|
-
|
|
519
|
-
// Vector search finds semantically similar content
|
|
520
|
-
const similar = await brainy.search("AI language models", 5)
|
|
398
|
+
**15+ operators supported**: `$gt`, `$gte`, `$lt`, `$lte`, `$eq`, `$ne`, `$in`, `$nin`, `$and`, `$or`, `$not`, `$regex`, `$includes`, `$exists`, `$size`
|
|
521
399
|
|
|
522
|
-
|
|
523
|
-
const relationships = await brainy.getVerbsBySource(companyId)
|
|
524
|
-
const allProducts = await brainy.getVerbsByType("develops")
|
|
525
|
-
```
|
|
400
|
+
</details>
|
|
526
401
|
|
|
527
|
-
|
|
402
|
+
<details>
|
|
403
|
+
<summary>🔗 <strong>Graph Relationships & Traversal</strong></summary>
|
|
528
404
|
|
|
529
405
|
```javascript
|
|
530
|
-
//
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
searchConnectedNouns: true, // Find entities connected by relationships
|
|
535
|
-
verbDirection: "outgoing" // Direction: outgoing, incoming, or both
|
|
536
|
-
})
|
|
406
|
+
// Create entities and relationships
|
|
407
|
+
const company = await brainy.add("OpenAI", { type: "company" })
|
|
408
|
+
const product = await brainy.add("GPT-4", { type: "product" })
|
|
409
|
+
const person = await brainy.add("Sam Altman", { type: "person" })
|
|
537
410
|
|
|
538
|
-
//
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
411
|
+
// Create meaningful relationships
|
|
412
|
+
await brainy.relate(company, product, "develops")
|
|
413
|
+
await brainy.relate(person, company, "leads")
|
|
414
|
+
await brainy.relate(product, person, "created_by")
|
|
542
415
|
|
|
543
|
-
//
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
416
|
+
// Traverse relationships
|
|
417
|
+
const products = await brainy.getVerbsBySource(company) // What OpenAI develops
|
|
418
|
+
const leaders = await brainy.getVerbsByTarget(company) // Who leads OpenAI
|
|
419
|
+
const connections = await brainy.findSimilar(product, {
|
|
420
|
+
relationType: "develops"
|
|
547
421
|
})
|
|
548
422
|
|
|
549
|
-
//
|
|
550
|
-
const
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
- ✅ **Auto-detects everything** - Environment, storage, threading, optimization
|
|
556
|
-
- ✅ **Framework-optimized** - Best experience with Angular, React, Vue bundlers
|
|
557
|
-
- ✅ **Runtime-agnostic** - Node.js, Deno, Bun, browsers, serverless, edge
|
|
558
|
-
- ✅ **TypeScript-first** - Full types everywhere, IntelliSense support
|
|
559
|
-
- ✅ **Tree-shaking ready** - Modern bundlers import only what you need
|
|
560
|
-
- ✅ **ES Modules architecture** - Individual modules for better optimization by modern frameworks
|
|
561
|
-
|
|
562
|
-
### Production: Add Offline Model Reliability
|
|
563
|
-
|
|
564
|
-
```bash
|
|
565
|
-
# For development (online model loading)
|
|
566
|
-
npm install @soulcraft/brainy
|
|
567
|
-
|
|
568
|
-
# For production (offline reliability)
|
|
569
|
-
npm install @soulcraft/brainy @soulcraft/brainy-models
|
|
423
|
+
// Search with relationship context
|
|
424
|
+
const results = await brainy.search("AI models", 10, {
|
|
425
|
+
includeVerbs: true,
|
|
426
|
+
verbTypes: ["develops", "created_by"],
|
|
427
|
+
searchConnectedNouns: true
|
|
428
|
+
})
|
|
570
429
|
```
|
|
571
430
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
- **🛡️ 100% Reliability** - No network timeouts or blocked URLs
|
|
575
|
-
- **⚡ Instant Startup** - Models load in ~100ms vs 5-30 seconds
|
|
576
|
-
- **🐳 Docker Ready** - Perfect for Cloud Run, Lambda, Kubernetes
|
|
577
|
-
- **🔒 Zero Dependencies** - No external network calls required
|
|
578
|
-
- **🎯 Zero Configuration** - Automatic detection with graceful fallback
|
|
579
|
-
- **🔐 Enhanced Security** - Complete air-gapping support for sensitive environments
|
|
580
|
-
- **🏢 Enterprise Ready** - Works behind corporate firewalls and restricted networks
|
|
581
|
-
- **⚖️ Compliance & Forensics** - Frozen mode for audit trails and legal discovery
|
|
431
|
+
</details>
|
|
582
432
|
|
|
583
|
-
|
|
584
|
-
|
|
433
|
+
<details>
|
|
434
|
+
<summary>🌐 <strong>Universal Storage & Deployment</strong></summary>
|
|
585
435
|
|
|
586
436
|
```javascript
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
// Use the bundled model for offline operation
|
|
591
|
-
const brainy = createAutoBrainy({
|
|
592
|
-
embeddingModel: BundledUniversalSentenceEncoder
|
|
437
|
+
// Development: File system
|
|
438
|
+
const dev = new BrainyData({
|
|
439
|
+
storage: { fileSystem: { path: './data' } }
|
|
593
440
|
})
|
|
594
|
-
```
|
|
595
441
|
|
|
596
|
-
|
|
442
|
+
// Production: S3/R2
|
|
443
|
+
const prod = new BrainyData({
|
|
444
|
+
storage: { s3Storage: { bucketName: 'my-vectors' } }
|
|
445
|
+
})
|
|
597
446
|
|
|
598
|
-
|
|
447
|
+
// Browser: OPFS
|
|
448
|
+
const browser = new BrainyData() // Auto-detects OPFS
|
|
599
449
|
|
|
600
|
-
|
|
450
|
+
// Edge: Memory
|
|
451
|
+
const edge = new BrainyData({
|
|
452
|
+
storage: { memory: {} }
|
|
453
|
+
})
|
|
601
454
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
455
|
+
// Redis: High performance
|
|
456
|
+
const redis = new BrainyData({
|
|
457
|
+
storage: { redis: { connectionString: 'redis://...' } }
|
|
458
|
+
})
|
|
459
|
+
```
|
|
606
460
|
|
|
607
|
-
|
|
608
|
-
```dockerfile
|
|
609
|
-
# Extract models during build (zero configuration!)
|
|
610
|
-
RUN npm run download-models
|
|
611
|
-
|
|
612
|
-
# Include models in final image
|
|
613
|
-
COPY --from=builder /app/models ./models
|
|
614
|
-
```
|
|
461
|
+
**Extend with any storage**: MongoDB, PostgreSQL, DynamoDB - [see storage adapters guide](docs/api-reference/storage-adapters.md)
|
|
615
462
|
|
|
616
|
-
|
|
617
|
-
```bash
|
|
618
|
-
# Works on all cloud providers
|
|
619
|
-
gcloud run deploy --source . # Google Cloud Run
|
|
620
|
-
aws ecs create-service ... # AWS ECS/Fargate
|
|
621
|
-
az container create ... # Azure Container Instances
|
|
622
|
-
wrangler publish # Cloudflare Workers
|
|
623
|
-
```
|
|
463
|
+
</details>
|
|
624
464
|
|
|
625
|
-
|
|
465
|
+
<details>
|
|
466
|
+
<summary>🐳 <strong>Docker & Cloud Deployment</strong></summary>
|
|
626
467
|
|
|
627
468
|
```dockerfile
|
|
469
|
+
# Production-ready Dockerfile
|
|
628
470
|
FROM node:24-slim AS builder
|
|
629
471
|
WORKDIR /app
|
|
630
472
|
COPY package*.json ./
|
|
631
473
|
RUN npm ci
|
|
632
474
|
COPY . .
|
|
633
|
-
RUN npm run download-models #
|
|
475
|
+
RUN npm run download-models # Embed models for offline operation
|
|
634
476
|
RUN npm run build
|
|
635
477
|
|
|
636
478
|
FROM node:24-slim AS production
|
|
637
479
|
WORKDIR /app
|
|
638
480
|
COPY package*.json ./
|
|
639
|
-
RUN npm ci --only=production
|
|
481
|
+
RUN npm ci --only=production
|
|
640
482
|
COPY --from=builder /app/dist ./dist
|
|
641
|
-
COPY --from=builder /app/models ./models #
|
|
483
|
+
COPY --from=builder /app/models ./models # Offline models included
|
|
642
484
|
CMD ["node", "dist/server.js"]
|
|
643
485
|
```
|
|
644
486
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
- **⚡ 7x Faster Cold Starts** - No model download delays
|
|
648
|
-
- **🌐 Universal Compatibility** - Same Dockerfile works on all clouds
|
|
649
|
-
- **🔒 Offline Ready** - No external dependencies at runtime
|
|
650
|
-
- **📦 Zero Configuration** - Automatic model detection
|
|
651
|
-
- **🛡️ Enhanced Security** - No network calls for model loading
|
|
652
|
-
|
|
653
|
-
**📖 Complete Guide:** See [docs/docker-deployment.md](./docs/docker-deployment.md) for detailed examples covering Google
|
|
654
|
-
Cloud Run, AWS Lambda/ECS, Azure Container Instances, Cloudflare Workers, and more.
|
|
655
|
-
|
|
656
|
-
### 📦 Modern ES Modules Architecture
|
|
657
|
-
|
|
658
|
-
Brainy now uses individual ES modules instead of large bundles, providing better optimization for modern frameworks:
|
|
659
|
-
|
|
660
|
-
- **Better tree-shaking**: Frameworks import only the specific functions you use
|
|
661
|
-
- **Smaller final apps**: Your bundled application only includes what you actually need
|
|
662
|
-
- **Faster development builds**: No complex bundling during development
|
|
663
|
-
- **Better debugging**: Source maps point to individual files, not large bundles
|
|
664
|
-
|
|
665
|
-
This change reduced the package size significantly while improving compatibility with Angular, React, Vue, and other
|
|
666
|
-
modern framework build systems.
|
|
667
|
-
|
|
668
|
-
## 🧬 The Power of Nouns & Verbs
|
|
669
|
-
|
|
670
|
-
Brainy uses a **graph-based data model** that mirrors how humans think - with **Nouns** (entities) connected by **Verbs
|
|
671
|
-
** (relationships). This isn't just vectors in a void; it's structured, meaningful data.
|
|
672
|
-
|
|
673
|
-
### 📝 Nouns (What Things Are)
|
|
674
|
-
|
|
675
|
-
Nouns are your entities - the "things" in your data. Each noun has:
|
|
676
|
-
|
|
677
|
-
- A unique ID
|
|
678
|
-
- A vector representation (for similarity search)
|
|
679
|
-
- A type (Person, Document, Concept, etc.)
|
|
680
|
-
- Custom metadata
|
|
681
|
-
|
|
682
|
-
**Available Noun Types:**
|
|
683
|
-
|
|
684
|
-
| Category | Types | Use For |
|
|
685
|
-
|---------------------|-------------------------------------------------------------------|-------------------------------------------------------|
|
|
686
|
-
| **Core Entities** | `Person`, `Organization`, `Location`, `Thing`, `Concept`, `Event` | People, companies, places, objects, ideas, happenings |
|
|
687
|
-
| **Digital Content** | `Document`, `Media`, `File`, `Message`, `Content` | PDFs, images, videos, emails, posts, generic content |
|
|
688
|
-
| **Collections** | `Collection`, `Dataset` | Groups of items, structured data sets |
|
|
689
|
-
| **Business** | `Product`, `Service`, `User`, `Task`, `Project` | E-commerce, SaaS, project management |
|
|
690
|
-
| **Descriptive** | `Process`, `State`, `Role` | Workflows, conditions, responsibilities |
|
|
691
|
-
|
|
692
|
-
### 🔗 Verbs (How Things Connect)
|
|
693
|
-
|
|
694
|
-
Verbs are your relationships - they give meaning to connections. Not just "these vectors are similar" but "this OWNS
|
|
695
|
-
that" or "this CAUSES that".
|
|
696
|
-
|
|
697
|
-
**Available Verb Types:**
|
|
698
|
-
|
|
699
|
-
| Category | Types | Examples |
|
|
700
|
-
|----------------|----------------------------------------------------------------------|------------------------------------------|
|
|
701
|
-
| **Core** | `RelatedTo`, `Contains`, `PartOf`, `LocatedAt`, `References` | Generic relations, containment, location |
|
|
702
|
-
| **Temporal** | `Precedes`, `Succeeds`, `Causes`, `DependsOn`, `Requires` | Time sequences, causality, dependencies |
|
|
703
|
-
| **Creation** | `Creates`, `Transforms`, `Becomes`, `Modifies`, `Consumes` | Creation, change, consumption |
|
|
704
|
-
| **Ownership** | `Owns`, `AttributedTo`, `CreatedBy`, `BelongsTo` | Ownership, authorship, belonging |
|
|
705
|
-
| **Social** | `MemberOf`, `WorksWith`, `FriendOf`, `Follows`, `Likes`, `ReportsTo` | Social networks, organizations |
|
|
706
|
-
| **Functional** | `Describes`, `Implements`, `Validates`, `Triggers`, `Serves` | Functions, implementations, services |
|
|
707
|
-
|
|
708
|
-
### 💡 Why This Matters
|
|
709
|
-
|
|
710
|
-
```javascript
|
|
711
|
-
// Traditional vector DB: Just similarity
|
|
712
|
-
const similar = await vectorDB.search(embedding, 10)
|
|
713
|
-
// Result: [vector1, vector2, ...] - What do these mean? 🤷
|
|
714
|
-
|
|
715
|
-
// Brainy: Similarity + Meaning + Relationships
|
|
716
|
-
const catId = await brainy.add("Siamese cat", {
|
|
717
|
-
noun: NounType.Thing,
|
|
718
|
-
breed: "Siamese"
|
|
719
|
-
})
|
|
720
|
-
const ownerId = await brainy.add("John Smith", {
|
|
721
|
-
noun: NounType.Person
|
|
722
|
-
})
|
|
723
|
-
await brainy.addVerb(ownerId, catId, {
|
|
724
|
-
verb: VerbType.Owns,
|
|
725
|
-
since: "2020-01-01"
|
|
726
|
-
})
|
|
727
|
-
|
|
728
|
-
// Now you can search with context!
|
|
729
|
-
const johnsPets = await brainy.getVerbsBySource(ownerId, VerbType.Owns)
|
|
730
|
-
const catOwners = await brainy.getVerbsByTarget(catId, VerbType.Owns)
|
|
731
|
-
```
|
|
732
|
-
|
|
733
|
-
## 🌍 Distributed Mode (New!)
|
|
734
|
-
|
|
735
|
-
Brainy now supports **distributed deployments** with multiple specialized instances sharing the same data. Perfect for
|
|
736
|
-
scaling your AI applications across multiple servers.
|
|
737
|
-
|
|
738
|
-
### Distributed Setup
|
|
739
|
-
|
|
740
|
-
```javascript
|
|
741
|
-
// Single instance (no change needed!)
|
|
742
|
-
const brainy = createAutoBrainy({
|
|
743
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } }
|
|
744
|
-
})
|
|
745
|
-
|
|
746
|
-
// Distributed mode requires explicit role configuration
|
|
747
|
-
// Option 1: Via environment variable
|
|
748
|
-
process.env.BRAINY_ROLE = 'writer' // or 'reader' or 'hybrid'
|
|
749
|
-
const brainy = createAutoBrainy({
|
|
750
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
751
|
-
distributed: true
|
|
752
|
-
})
|
|
753
|
-
|
|
754
|
-
// Option 2: Via configuration
|
|
755
|
-
const writer = createAutoBrainy({
|
|
756
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
757
|
-
distributed: { role: 'writer' } // Handles data ingestion
|
|
758
|
-
})
|
|
759
|
-
|
|
760
|
-
const reader = createAutoBrainy({
|
|
761
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
762
|
-
distributed: { role: 'reader' } // Optimized for queries
|
|
763
|
-
})
|
|
764
|
-
|
|
765
|
-
// Option 3: Via read/write mode (role auto-inferred)
|
|
766
|
-
const writer = createAutoBrainy({
|
|
767
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
768
|
-
writeOnly: true, // Automatically becomes 'writer' role
|
|
769
|
-
distributed: true
|
|
770
|
-
})
|
|
771
|
-
|
|
772
|
-
const reader = createAutoBrainy({
|
|
773
|
-
storage: { s3Storage: { bucketName: 'my-bucket' } },
|
|
774
|
-
readOnly: true, // Automatically becomes 'reader' role (allows optimizations)
|
|
775
|
-
// frozen: true, // Optional: Complete immutability for compliance/forensics
|
|
776
|
-
distributed: true
|
|
777
|
-
})
|
|
778
|
-
```
|
|
779
|
-
|
|
780
|
-
### Key Distributed Features
|
|
781
|
-
|
|
782
|
-
**🎯 Explicit Role Configuration**
|
|
783
|
-
|
|
784
|
-
- Roles must be explicitly set (no dangerous auto-assignment)
|
|
785
|
-
- Can use environment variables, config, or read/write modes
|
|
786
|
-
- Clear separation between writers and readers
|
|
787
|
-
|
|
788
|
-
**#️⃣ Hash-Based Partitioning**
|
|
789
|
-
|
|
790
|
-
- Handles multiple writers with different data types
|
|
791
|
-
- Even distribution across partitions
|
|
792
|
-
- No semantic conflicts with mixed data
|
|
793
|
-
|
|
794
|
-
**🏷️ Domain Tagging**
|
|
795
|
-
|
|
796
|
-
- Automatic domain detection (medical, legal, product, etc.)
|
|
797
|
-
- Filter searches by domain
|
|
798
|
-
- Logical separation without complexity
|
|
799
|
-
|
|
800
|
-
```javascript
|
|
801
|
-
// Data is automatically tagged with domains
|
|
802
|
-
await brainy.add({
|
|
803
|
-
symptoms: "fever",
|
|
804
|
-
diagnosis: "flu"
|
|
805
|
-
}, metadata) // Auto-tagged as 'medical'
|
|
806
|
-
|
|
807
|
-
// Search within specific domains
|
|
808
|
-
const medicalResults = await brainy.search(query, 10, {
|
|
809
|
-
filter: { domain: 'medical' }
|
|
810
|
-
})
|
|
811
|
-
```
|
|
812
|
-
|
|
813
|
-
**📊 Health Monitoring**
|
|
814
|
-
|
|
815
|
-
- Real-time health metrics
|
|
816
|
-
- Automatic dead instance cleanup
|
|
817
|
-
- Performance tracking
|
|
818
|
-
|
|
819
|
-
```javascript
|
|
820
|
-
// Get health status
|
|
821
|
-
const health = brainy.getHealthStatus()
|
|
822
|
-
// {
|
|
823
|
-
// status: 'healthy',
|
|
824
|
-
// role: 'reader',
|
|
825
|
-
// vectorCount: 1000000,
|
|
826
|
-
// cacheHitRate: 0.95,
|
|
827
|
-
// requestsPerSecond: 150
|
|
828
|
-
// }
|
|
829
|
-
```
|
|
830
|
-
|
|
831
|
-
**⚡ Role-Optimized Performance**
|
|
832
|
-
|
|
833
|
-
- **Readers**: 80% memory for cache, aggressive prefetching
|
|
834
|
-
- **Writers**: Optimized write batching, minimal cache
|
|
835
|
-
- **Hybrid**: Adaptive based on workload
|
|
836
|
-
|
|
837
|
-
## ⚖️ Compliance & Forensics Mode
|
|
838
|
-
|
|
839
|
-
For legal discovery, audit trails, and compliance requirements:
|
|
840
|
-
|
|
841
|
-
```javascript
|
|
842
|
-
// Create a completely immutable snapshot
|
|
843
|
-
const auditDb = new BrainyData({
|
|
844
|
-
storage: { s3Storage: { bucketName: 'audit-snapshots' } },
|
|
845
|
-
readOnly: true,
|
|
846
|
-
frozen: true // Complete immutability - no changes allowed
|
|
847
|
-
})
|
|
848
|
-
|
|
849
|
-
// Perfect for:
|
|
850
|
-
// - Legal discovery (data cannot be modified)
|
|
851
|
-
// - Compliance audits (guaranteed state)
|
|
852
|
-
// - Forensic analysis (preserved evidence)
|
|
853
|
-
// - Regulatory snapshots (unchanging records)
|
|
854
|
-
```
|
|
855
|
-
|
|
856
|
-
### Deployment Examples
|
|
857
|
-
|
|
858
|
-
**Docker Compose**
|
|
859
|
-
|
|
860
|
-
```yaml
|
|
861
|
-
services:
|
|
862
|
-
writer:
|
|
863
|
-
image: myapp
|
|
864
|
-
environment:
|
|
865
|
-
BRAINY_ROLE: writer # Optional - auto-detects
|
|
866
|
-
|
|
867
|
-
reader:
|
|
868
|
-
image: myapp
|
|
869
|
-
environment:
|
|
870
|
-
BRAINY_ROLE: reader # Optional - auto-detects
|
|
871
|
-
scale: 5
|
|
872
|
-
```
|
|
873
|
-
|
|
874
|
-
**Kubernetes**
|
|
875
|
-
|
|
876
|
-
```yaml
|
|
877
|
-
# Automatically detects role from deployment type
|
|
878
|
-
apiVersion: apps/v1
|
|
879
|
-
kind: Deployment
|
|
880
|
-
metadata:
|
|
881
|
-
name: brainy-readers
|
|
882
|
-
spec:
|
|
883
|
-
replicas: 10 # Multiple readers
|
|
884
|
-
template:
|
|
885
|
-
spec:
|
|
886
|
-
containers:
|
|
887
|
-
- name: app
|
|
888
|
-
image: myapp
|
|
889
|
-
# Role auto-detected as 'reader' (multiple replicas)
|
|
890
|
-
```
|
|
891
|
-
|
|
892
|
-
**Benefits**
|
|
893
|
-
|
|
894
|
-
- ✅ **50-70% faster searches** with parallel readers
|
|
895
|
-
- ✅ **No coordination complexity** - Shared JSON config in S3
|
|
896
|
-
- ✅ **Zero downtime scaling** - Add/remove instances anytime
|
|
897
|
-
- ✅ **Automatic failover** - Dead instances cleaned up automatically
|
|
898
|
-
|
|
899
|
-
## 🤔 Why Choose Brainy?
|
|
900
|
-
|
|
901
|
-
### vs. Traditional Databases
|
|
902
|
-
|
|
903
|
-
❌ **PostgreSQL with pgvector** - Requires complex setup, tuning, and DevOps expertise
|
|
904
|
-
✅ **Brainy** - Zero config, auto-optimizes, works everywhere from browser to cloud
|
|
905
|
-
|
|
906
|
-
### vs. Vector Databases
|
|
907
|
-
|
|
908
|
-
❌ **Pinecone/Weaviate/Qdrant** - Cloud-only, expensive, vendor lock-in
|
|
909
|
-
✅ **Brainy** - Run locally, in browser, or cloud. Your choice, your data
|
|
910
|
-
|
|
911
|
-
### vs. Graph Databases
|
|
912
|
-
|
|
913
|
-
❌ **Neo4j** - Great for graphs, no vector support
|
|
914
|
-
✅ **Brainy** - Vectors + graphs in one. Best of both worlds
|
|
915
|
-
|
|
916
|
-
### vs. "Vector + Graph" Solutions
|
|
917
|
-
|
|
918
|
-
❌ **Pinecone + Neo4j** - Two databases, sync nightmares, double the cost
|
|
919
|
-
❌ **pgvector + graph extension** - Hacked together, not native, performance issues
|
|
920
|
-
❌ **Weaviate "references"** - Limited graph capabilities, not true relationships
|
|
921
|
-
✅ **Brainy** - Purpose-built vector+graph architecture, single source of truth
|
|
922
|
-
|
|
923
|
-
### vs. DIY Solutions
|
|
924
|
-
|
|
925
|
-
❌ **Building your own** - Months of work, optimization nightmares
|
|
926
|
-
✅ **Brainy** - Production-ready in 30 seconds
|
|
927
|
-
|
|
928
|
-
## 🚀 Getting Started in 30 Seconds
|
|
929
|
-
|
|
930
|
-
**The same Brainy code works everywhere - React, Vue, Angular, Node.js, Serverless, Edge Workers.**
|
|
931
|
-
|
|
932
|
-
```javascript
|
|
933
|
-
// This EXACT code works in ALL environments
|
|
934
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
935
|
-
|
|
936
|
-
const brainy = new BrainyData()
|
|
937
|
-
await brainy.init()
|
|
938
|
-
|
|
939
|
-
// Add nouns (entities)
|
|
940
|
-
const openai = await brainy.add("OpenAI", { type: "company" })
|
|
941
|
-
const gpt4 = await brainy.add("GPT-4", { type: "product" })
|
|
942
|
-
|
|
943
|
-
// Add verbs (relationships)
|
|
944
|
-
await brainy.relate(openai, gpt4, "develops")
|
|
945
|
-
|
|
946
|
-
// Vector search + Graph traversal
|
|
947
|
-
const similar = await brainy.search("AI companies", 5)
|
|
948
|
-
const products = await brainy.getVerbsBySource(openai)
|
|
949
|
-
```
|
|
950
|
-
|
|
951
|
-
<details>
|
|
952
|
-
<summary>🔍 See Framework Examples</summary>
|
|
953
|
-
|
|
954
|
-
### React
|
|
955
|
-
|
|
956
|
-
```jsx
|
|
957
|
-
function App() {
|
|
958
|
-
const [brainy] = useState(() => new BrainyData())
|
|
959
|
-
useEffect(() => brainy.init(), [])
|
|
960
|
-
|
|
961
|
-
const search = async (query) => {
|
|
962
|
-
return await brainy.search(query, 10)
|
|
963
|
-
}
|
|
964
|
-
// Same API as above
|
|
965
|
-
}
|
|
966
|
-
```
|
|
967
|
-
|
|
968
|
-
### Vue 3
|
|
969
|
-
|
|
970
|
-
```vue
|
|
971
|
-
|
|
972
|
-
<script setup>
|
|
973
|
-
const brainy = new BrainyData()
|
|
974
|
-
await brainy.init()
|
|
975
|
-
// Same API as above
|
|
976
|
-
</script>
|
|
977
|
-
```
|
|
978
|
-
|
|
979
|
-
### Angular
|
|
980
|
-
|
|
981
|
-
```typescript
|
|
982
|
-
|
|
983
|
-
@Component({})
|
|
984
|
-
export class AppComponent {
|
|
985
|
-
brainy = new BrainyData()
|
|
986
|
-
|
|
987
|
-
async ngOnInit() {
|
|
988
|
-
await this.brainy.init()
|
|
989
|
-
// Same API as above
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
```
|
|
993
|
-
|
|
994
|
-
### Node.js / Deno / Bun
|
|
995
|
-
|
|
996
|
-
```javascript
|
|
997
|
-
const brainy = new BrainyData()
|
|
998
|
-
await brainy.init()
|
|
999
|
-
// Same API as above
|
|
1000
|
-
```
|
|
1001
|
-
|
|
1002
|
-
</details>
|
|
1003
|
-
|
|
1004
|
-
### 🌍 Framework-First, Runs Everywhere
|
|
1005
|
-
|
|
1006
|
-
**Brainy automatically detects your environment and optimizes everything:**
|
|
1007
|
-
|
|
1008
|
-
| Environment | Storage | Optimization |
|
|
1009
|
-
|-----------------|-----------------|----------------------------|
|
|
1010
|
-
| 🌐 Browser | OPFS | Web Workers, Memory Cache |
|
|
1011
|
-
| 🟢 Node.js | FileSystem / S3 | Worker Threads, Clustering |
|
|
1012
|
-
| ⚡ Serverless | S3 / Memory | Cold Start Optimization |
|
|
1013
|
-
| 🔥 Edge Workers | Memory / KV | Minimal Footprint |
|
|
1014
|
-
| 🦕 Deno/Bun | FileSystem / S3 | Native Performance |
|
|
1015
|
-
|
|
1016
|
-
## 🌐 Deploy to Any Cloud
|
|
1017
|
-
|
|
1018
|
-
<details>
|
|
1019
|
-
<summary>☁️ See Cloud Platform Examples</summary>
|
|
1020
|
-
|
|
1021
|
-
### Cloudflare Workers
|
|
1022
|
-
|
|
1023
|
-
```javascript
|
|
1024
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
1025
|
-
|
|
1026
|
-
export default {
|
|
1027
|
-
async fetch(request) {
|
|
1028
|
-
const brainy = new BrainyData()
|
|
1029
|
-
await brainy.init()
|
|
1030
|
-
|
|
1031
|
-
const url = new URL(request.url)
|
|
1032
|
-
const results = await brainy.search(url.searchParams.get('q'), 10)
|
|
1033
|
-
return Response.json(results)
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
```
|
|
1037
|
-
|
|
1038
|
-
### AWS Lambda
|
|
1039
|
-
|
|
1040
|
-
```javascript
|
|
1041
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
1042
|
-
|
|
1043
|
-
export const handler = async (event) => {
|
|
1044
|
-
const brainy = new BrainyData()
|
|
1045
|
-
await brainy.init()
|
|
1046
|
-
|
|
1047
|
-
const results = await brainy.search(event.query, 10)
|
|
1048
|
-
return { statusCode: 200, body: JSON.stringify(results) }
|
|
1049
|
-
}
|
|
1050
|
-
```
|
|
1051
|
-
|
|
1052
|
-
### Google Cloud Functions
|
|
1053
|
-
|
|
1054
|
-
```javascript
|
|
1055
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
1056
|
-
|
|
1057
|
-
export const searchHandler = async (req, res) => {
|
|
1058
|
-
const brainy = new BrainyData()
|
|
1059
|
-
await brainy.init()
|
|
1060
|
-
|
|
1061
|
-
const results = await brainy.search(req.query.q, 10)
|
|
1062
|
-
res.json(results)
|
|
1063
|
-
}
|
|
1064
|
-
```
|
|
1065
|
-
|
|
1066
|
-
### Vercel Edge Functions
|
|
1067
|
-
|
|
1068
|
-
```javascript
|
|
1069
|
-
import { BrainyData } from '@soulcraft/brainy'
|
|
1070
|
-
|
|
1071
|
-
export const config = { runtime: 'edge' }
|
|
1072
|
-
|
|
1073
|
-
export default async function handler(request) {
|
|
1074
|
-
const brainy = new BrainyData()
|
|
1075
|
-
await brainy.init()
|
|
1076
|
-
|
|
1077
|
-
const { searchParams } = new URL(request.url)
|
|
1078
|
-
const results = await brainy.search(searchParams.get('q'), 10)
|
|
1079
|
-
return Response.json(results)
|
|
1080
|
-
}
|
|
1081
|
-
```
|
|
487
|
+
Deploy to: Google Cloud Run, AWS Lambda/ECS, Azure Container Instances, Cloudflare Workers, Railway, Render, Vercel, anywhere Docker runs.
|
|
1082
488
|
|
|
1083
489
|
</details>
|
|
1084
490
|
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
```dockerfile
|
|
1088
|
-
FROM node:24-slim
|
|
1089
|
-
USER node
|
|
1090
|
-
WORKDIR /app
|
|
1091
|
-
COPY package*.json ./
|
|
1092
|
-
RUN npm install brainy
|
|
1093
|
-
COPY . .
|
|
1094
|
-
|
|
1095
|
-
CMD ["node", "server.js"]
|
|
1096
|
-
```
|
|
1097
|
-
|
|
1098
|
-
```javascript
|
|
1099
|
-
// server.js
|
|
1100
|
-
import { createAutoBrainy } from 'brainy'
|
|
1101
|
-
import express from 'express'
|
|
1102
|
-
|
|
1103
|
-
const app = express()
|
|
1104
|
-
const brainy = createAutoBrainy()
|
|
1105
|
-
|
|
1106
|
-
app.get('/search', async (req, res) => {
|
|
1107
|
-
const results = await brainy.searchText(req.query.q, 10)
|
|
1108
|
-
res.json(results)
|
|
1109
|
-
})
|
|
1110
|
-
|
|
1111
|
-
app.listen(3000, () => console.log('Brainy running on port 3000'))
|
|
1112
|
-
```
|
|
1113
|
-
|
|
1114
|
-
### Kubernetes
|
|
1115
|
-
|
|
1116
|
-
```yaml
|
|
1117
|
-
apiVersion: apps/v1
|
|
1118
|
-
kind: Deployment
|
|
1119
|
-
metadata:
|
|
1120
|
-
name: brainy-api
|
|
1121
|
-
spec:
|
|
1122
|
-
replicas: 3
|
|
1123
|
-
template:
|
|
1124
|
-
spec:
|
|
1125
|
-
containers:
|
|
1126
|
-
- name: brainy
|
|
1127
|
-
image: your-registry/brainy-api:latest
|
|
1128
|
-
env:
|
|
1129
|
-
- name: S3_BUCKET
|
|
1130
|
-
value: "your-vector-bucket"
|
|
1131
|
-
```
|
|
1132
|
-
|
|
1133
|
-
### Railway.app
|
|
1134
|
-
|
|
1135
|
-
```javascript
|
|
1136
|
-
// server.js
|
|
1137
|
-
import { createAutoBrainy } from 'brainy'
|
|
1138
|
-
|
|
1139
|
-
const brainy = createAutoBrainy({
|
|
1140
|
-
bucketName: process.env.RAILWAY_VOLUME_NAME
|
|
1141
|
-
})
|
|
1142
|
-
|
|
1143
|
-
// Railway automatically handles the rest!
|
|
1144
|
-
```
|
|
1145
|
-
|
|
1146
|
-
### Render.com
|
|
1147
|
-
|
|
1148
|
-
```yaml
|
|
1149
|
-
# render.yaml
|
|
1150
|
-
services:
|
|
1151
|
-
- type: web
|
|
1152
|
-
name: brainy-api
|
|
1153
|
-
env: node
|
|
1154
|
-
buildCommand: npm install brainy
|
|
1155
|
-
startCommand: node server.js
|
|
1156
|
-
envVars:
|
|
1157
|
-
- key: BRAINY_STORAGE
|
|
1158
|
-
value: persistent-disk
|
|
1159
|
-
```
|
|
491
|
+
## 📚 Documentation & Resources
|
|
1160
492
|
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
- [
|
|
1164
|
-
- [
|
|
1165
|
-
- [
|
|
1166
|
-
|
|
1167
|
-
### User Guides
|
|
1168
|
-
|
|
1169
|
-
- [**Search and Metadata**](docs/user-guides/) - Advanced search techniques
|
|
1170
|
-
- [**JSON Document Search**](docs/guides/json-document-search.md) - Field-based searching
|
|
1171
|
-
- [**Read-Only & Frozen Modes**](docs/guides/readonly-frozen-modes.md) - Immutability options for production
|
|
1172
|
-
- [**Production Migration**](docs/guides/production-migration-guide.md) - Deployment best practices
|
|
1173
|
-
|
|
1174
|
-
### API Reference
|
|
1175
|
-
|
|
1176
|
-
- [**Core API**](docs/api-reference/) - Complete method reference
|
|
1177
|
-
- [**Configuration Options**](docs/api-reference/configuration.md) - All configuration parameters
|
|
1178
|
-
|
|
1179
|
-
### Optimization & Scaling
|
|
1180
|
-
|
|
1181
|
-
- [**Performance Features Guide**](docs/PERFORMANCE_FEATURES.md) - Advanced caching, auto-configuration, and
|
|
1182
|
-
optimization
|
|
1183
|
-
- [**Large-Scale Optimizations**](docs/optimization-guides/) - Handle millions of vectors
|
|
1184
|
-
- [**Memory Management**](docs/optimization-guides/memory-optimization.md) - Efficient resource usage
|
|
1185
|
-
- [**S3 Migration Guide**](docs/optimization-guides/s3-migration-guide.md) - Cloud storage setup
|
|
1186
|
-
|
|
1187
|
-
### Examples & Patterns
|
|
1188
|
-
|
|
1189
|
-
- [**Code Examples**](docs/examples/) - Real-world usage patterns
|
|
1190
|
-
- [**Integrations**](docs/examples/integrations.md) - Third-party services
|
|
1191
|
-
- [**Performance Patterns**](docs/examples/performance.md) - Optimization techniques
|
|
1192
|
-
|
|
1193
|
-
### Technical Documentation
|
|
1194
|
-
|
|
1195
|
-
- [**Architecture Overview**](docs/technical/) - System design and internals
|
|
1196
|
-
- [**Testing Guide**](docs/technical/TESTING.md) - Testing strategies
|
|
1197
|
-
- [**Statistics & Monitoring**](docs/technical/STATISTICS.md) - Performance tracking
|
|
493
|
+
- **[🚀 Quick Start Guide](docs/getting-started/)** - Get up and running in minutes
|
|
494
|
+
- **[📖 API Reference](docs/api-reference/)** - Complete method documentation
|
|
495
|
+
- **[💡 Examples](docs/examples/)** - Real-world usage patterns
|
|
496
|
+
- **[⚡ Performance Guide](docs/optimization-guides/)** - Scale to millions of vectors
|
|
497
|
+
- **[🔧 Storage Adapters](docs/api-reference/storage-adapters.md)** - Universal storage compatibility
|
|
1198
498
|
|
|
1199
499
|
## 🤝 Contributing
|
|
1200
500
|
|
|
@@ -1211,5 +511,7 @@ We welcome contributions! Please see:
|
|
|
1211
511
|
---
|
|
1212
512
|
|
|
1213
513
|
<div align="center">
|
|
1214
|
-
<strong>Ready to build
|
|
1215
|
-
|
|
514
|
+
<strong>Ready to build the future of search? Get started with Brainy today!</strong>
|
|
515
|
+
|
|
516
|
+
**[Get Started →](docs/getting-started/) | [View Examples →](docs/examples/) | [Join Community →](https://github.com/soulcraft-research/brainy/discussions)**
|
|
517
|
+
</div>
|