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