@soulcraft/brainy 0.51.0 โ†’ 0.51.2

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 +407 -10
  2. 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
 
@@ -69,6 +69,86 @@ const results = await brainy.search("AI language models", 5, {
69
69
 
70
70
  **That's it. You just built a knowledge graph with semantic search and faceted filtering in 8 lines.**
71
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
82
+
83
+ ### ๐ŸŽฏ **v0.49: Filter Discovery & Performance Improvements**
84
+
85
+ **Discover available filters and scale to millions of items!**
86
+
87
+ ```javascript
88
+ // Discover what filters are available - O(1) field lookup
89
+ const categories = await brainy.getFilterValues('category')
90
+ // Returns: ['electronics', 'books', 'clothing', ...]
91
+
92
+ const fields = await brainy.getFilterFields() // O(1) operation
93
+ // Returns: ['category', 'price', 'brand', 'rating', ...]
94
+ ```
95
+
96
+ - โœ… **Filter Discovery API**: O(1) field discovery for instant filter UI generation
97
+ - โœ… **Improved Performance**: Removed deprecated methods, now uses pagination everywhere
98
+ - โœ… **Better Scalability**: Hybrid indexing with O(1) field access scales to millions
99
+ - โœ… **Smart Caching**: LRU cache for frequently accessed filters
100
+ - โœ… **Zero Configuration**: Everything auto-optimizes based on usage patterns
101
+
102
+ ### ๐Ÿš€ **v0.48: MongoDB-Style Metadata Filtering**
103
+
104
+ **Powerful querying with familiar syntax - filter DURING search for maximum performance!**
105
+
106
+ ```javascript
107
+ const results = await brainy.search("wireless headphones", 10, {
108
+ metadata: {
109
+ category: { $in: ["electronics", "audio"] },
110
+ price: { $lte: 200 },
111
+ rating: { $gte: 4.0 },
112
+ brand: { $ne: "Generic" }
113
+ }
114
+ })
115
+ ```
116
+
117
+ - โœ… **15+ MongoDB Operators**: `$gt`, `$in`, `$regex`, `$and`, `$or`, `$includes`, etc.
118
+ - โœ… **Automatic Indexing**: Zero configuration, maximum performance
119
+ - โœ… **Nested Fields**: Use dot notation for complex objects
120
+ - โœ… **100% Backward Compatible**: Your existing code works unchanged
121
+
122
+ ### โšก **v0.46: Transformers.js Migration**
123
+
124
+ **Replaced TensorFlow.js for better performance and true offline operation!**
125
+
126
+ - โœ… **95% Smaller Package**: 643 kB vs 12.5 MB
127
+ - โœ… **84% Smaller Models**: 87 MB vs 525 MB models
128
+ - โœ… **True Offline**: Zero network calls after initial download
129
+ - โœ… **5x Fewer Dependencies**: Clean tree, no peer dependency issues
130
+ - โœ… **Same API**: Drop-in replacement, existing code works unchanged
131
+
132
+ ### ๐Ÿš€ Why Developers Love Brainy
133
+
134
+ - **๐Ÿง  Zero-to-Smartโ„ข** - No config files, no tuning parameters, no DevOps headaches. Brainy auto-detects your environment and optimizes itself
135
+ - **๐ŸŒ True Write-Once, Run-Anywhere** - Same code runs in Angular, React, Vue, Node.js, Deno, Bun, serverless, edge workers, and web workers with automatic environment detection
136
+ - **โšก Scary Fast** - Handles millions of vectors with sub-millisecond search. GPU acceleration for embeddings, optimized CPU for distance calculations
137
+ - **๐ŸŽฏ Self-Learning** - Like having a database that goes to the gym. Gets faster and smarter the more you use it
138
+ - **๐Ÿ”ฎ AI-First Design** - Built for the age of embeddings, RAG, and semantic search. Your LLMs will thank you
139
+ - **๐ŸŽฎ Actually Fun to Use** - Clean API, great DX, and it does the heavy lifting so you can build cool stuff
140
+
141
+ ### ๐Ÿš€ NEW: Ultra-Fast Search Performance + Auto-Configuration
142
+
143
+ **Your searches just got 100x faster AND Brainy now configures itself!** Advanced performance with zero setup:
144
+
145
+ - **๐Ÿค– Intelligent Auto-Configuration** - Detects environment and usage patterns, optimizes automatically
146
+ - **โšก Smart Result Caching** - Repeated queries return in <1ms with automatic cache invalidation
147
+ - **๐Ÿ“„ Cursor-Based Pagination** - Navigate millions of results with constant O(k) performance
148
+ - **๐Ÿ”„ Real-Time Data Sync** - Cache automatically updates when data changes, even in distributed scenarios
149
+ - **๐Ÿ“Š Performance Monitoring** - Built-in hit rate and memory usage tracking with adaptive optimization
150
+ - **๐ŸŽฏ Zero Breaking Changes** - All existing code works unchanged, just faster and smarter
151
+
72
152
  ## ๐Ÿ† Why Brainy Wins
73
153
 
74
154
  - ๐Ÿง  **Triple Search Power** - Vector + Graph + Faceted filtering in one query
@@ -84,27 +164,164 @@ const results = await brainy.search("AI language models", 5, {
84
164
  - **โšก LLM Generation** - Built-in content generation powered by your knowledge graph
85
165
  - **๐ŸŒŠ Real-time Sync** - Live updates across distributed instances
86
166
 
87
- ## ๐ŸŽฏ Perfect For
167
+ ## ๐ŸŽจ Build Amazing Things
88
168
 
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
169
+ **๐Ÿค– AI Chat Applications** - Build ChatGPT-like apps with long-term memory and context awareness
170
+ **๐Ÿ” Semantic Search Engines** - Search by meaning, not keywords. Find "that thing that's like a cat but bigger" โ†’ returns "tiger"
92
171
  **๐ŸŽฏ Recommendation Engines** - "Users who liked this also liked..." but actually good
93
- **๐Ÿ“š Smart Documentation** - Docs that answer questions before you ask them
172
+ **๐Ÿงฌ Knowledge Graphs** - Connect everything to everything. Wikipedia meets Neo4j meets magic
173
+ **๐Ÿ‘๏ธ Computer Vision Apps** - Store and search image embeddings. "Find all photos with dogs wearing hats"
174
+ **๐ŸŽต Music Discovery** - Find songs that "feel" similar. Spotify's Discover Weekly in your app
175
+ **๐Ÿ“š Smart Documentation** - Docs that answer questions. "How do I deploy to production?" โ†’ relevant guides
176
+ **๐Ÿ›ก๏ธ Fraud Detection** - Find patterns humans can't see. Anomaly detection on steroids
177
+ **๐ŸŒ Real-Time Collaboration** - Sync vector data across devices. Figma for AI data
178
+ **๐Ÿฅ Medical Diagnosis Tools** - Match symptoms to conditions using embedding similarity
94
179
 
95
180
  ## ๐ŸŒ Works Everywhere - Same Code
96
181
 
182
+ **Write once, run anywhere.** Brainy auto-detects your environment and optimizes automatically:
183
+
184
+ ### ๐ŸŒ Browser Frameworks (React, Angular, Vue)
185
+
97
186
  ```javascript
98
- // This EXACT code works in ALL environments
99
187
  import { BrainyData } from '@soulcraft/brainy'
100
188
 
189
+ // SAME CODE in React, Angular, Vue, Svelte, etc.
101
190
  const brainy = new BrainyData()
102
- await brainy.init()
191
+ await brainy.init() // Auto-uses OPFS in browsers
192
+
193
+ // Add entities and relationships
194
+ const john = await brainy.add("John is a software engineer", { type: "person" })
195
+ const jane = await brainy.add("Jane is a data scientist", { type: "person" })
196
+ const ai = await brainy.add("AI Project", { type: "project" })
197
+
198
+ await brainy.relate(john, ai, "works_on")
199
+ await brainy.relate(jane, ai, "leads")
103
200
 
104
- // Works in: React, Vue, Angular, Node.js, Deno, Bun,
105
- // Cloudflare Workers, Vercel Edge, AWS Lambda, browsers, anywhere
201
+ // Search by meaning
202
+ const engineers = await brainy.search("software developers", 5)
203
+
204
+ // Traverse relationships
205
+ const team = await brainy.getVerbsByTarget(ai) // Who works on AI Project?
106
206
  ```
107
207
 
208
+ <details>
209
+ <summary>๐Ÿ“ฆ <strong>Full React Component Example</strong></summary>
210
+
211
+ ```jsx
212
+ import { BrainyData } from '@soulcraft/brainy'
213
+ import { useEffect, useState } from 'react'
214
+
215
+ function Search() {
216
+ const [brainy, setBrainy] = useState(null)
217
+ const [results, setResults] = useState([])
218
+
219
+ useEffect(() => {
220
+ const init = async () => {
221
+ const db = new BrainyData()
222
+ await db.init()
223
+ // Add your data...
224
+ setBrainy(db)
225
+ }
226
+ init()
227
+ }, [])
228
+
229
+ const search = async (query) => {
230
+ const results = await brainy?.search(query, 5) || []
231
+ setResults(results)
232
+ }
233
+
234
+ return <input onChange={(e) => search(e.target.value)} placeholder="Search..." />
235
+ }
236
+ ```
237
+
238
+ </details>
239
+
240
+ <details>
241
+ <summary>๐Ÿ“ฆ <strong>Full Angular Component Example</strong></summary>
242
+
243
+ ```typescript
244
+ import { Component, signal, OnInit } from '@angular/core'
245
+ import { BrainyData } from '@soulcraft/brainy'
246
+
247
+ @Component({
248
+ selector: 'app-search',
249
+ template: `<input (input)="search($event.target.value)" placeholder="Search...">`
250
+ })
251
+ export class SearchComponent implements OnInit {
252
+ brainy = new BrainyData()
253
+
254
+ async ngOnInit() {
255
+ await this.brainy.init()
256
+ // Add your data...
257
+ }
258
+
259
+ async search(query: string) {
260
+ const results = await this.brainy.search(query, 5)
261
+ // Display results...
262
+ }
263
+ }
264
+ ```
265
+
266
+ </details>
267
+
268
+ <details>
269
+ <summary>๐Ÿ“ฆ <strong>Full Vue Example</strong></summary>
270
+
271
+ ```vue
272
+ <script setup>
273
+ import { BrainyData } from '@soulcraft/brainy'
274
+ import { ref, onMounted } from 'vue'
275
+
276
+ const brainy = ref(null)
277
+ const results = ref([])
278
+
279
+ onMounted(async () => {
280
+ const db = new BrainyData()
281
+ await db.init()
282
+ // Add your data...
283
+ brainy.value = db
284
+ })
285
+
286
+ const search = async (query) => {
287
+ const results = await brainy.value?.search(query, 5) || []
288
+ setResults(results)
289
+ }
290
+ </script>
291
+
292
+ <template>
293
+ <input @input="search($event.target.value)" placeholder="Search..." />
294
+ </template>
295
+ ```
296
+
297
+ </details>
298
+
299
+ ### ๐ŸŸข Node.js / Serverless / Edge
300
+
301
+ ```javascript
302
+ import { BrainyData } from '@soulcraft/brainy'
303
+
304
+ // SAME CODE works in Node.js, Vercel, Netlify, Cloudflare Workers, Deno, Bun
305
+ const brainy = new BrainyData()
306
+ await brainy.init() // Auto-detects environment and optimizes
307
+
308
+ // Add entities and relationships
309
+ await brainy.add("Python is great for data science", { type: "fact" })
310
+ await brainy.add("JavaScript rules the web", { type: "fact" })
311
+
312
+ // Search by meaning
313
+ const results = await brainy.search("programming languages", 5)
314
+
315
+ // Optional: Production with S3/R2 storage (auto-detected in cloud environments)
316
+ const productionBrainy = new BrainyData({
317
+ storage: {
318
+ s3Storage: { bucketName: process.env.BUCKET_NAME }
319
+ }
320
+ })
321
+ ```
322
+
323
+ **That's it! Same code, everywhere. Zero-to-Smartโ„ข**
324
+
108
325
  Brainy automatically detects and optimizes for your environment:
109
326
 
110
327
  | Environment | Storage | Optimization |
@@ -114,6 +331,100 @@ Brainy automatically detects and optimizes for your environment:
114
331
  | โšก Serverless | S3 / Memory | Cold Start Optimization |
115
332
  | ๐Ÿ”ฅ Edge | Memory / KV | Minimal Footprint |
116
333
 
334
+ ## ๐ŸŒ Distributed Mode (NEW!)
335
+
336
+ **Scale horizontally with zero configuration!** Brainy now supports distributed deployments with automatic coordination:
337
+
338
+ - **๐ŸŒ Multi-Instance Coordination** - Multiple readers and writers working in harmony
339
+ - **๐Ÿท๏ธ Smart Domain Detection** - Automatically categorizes data (medical, legal, product, etc.)
340
+ - **๐Ÿ“Š Real-Time Health Monitoring** - Track performance across all instances
341
+ - **๐Ÿ”„ Automatic Role Optimization** - Readers optimize for cache, writers for throughput
342
+ - **๐Ÿ—‚๏ธ Intelligent Partitioning** - Hash-based partitioning for perfect load distribution
343
+
344
+ ```javascript
345
+ // Writer Instance - Ingests data from multiple sources
346
+ const writer = new BrainyData({
347
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
348
+ distributed: { role: 'writer' } // Explicit role for safety
349
+ })
350
+
351
+ // Reader Instance - Optimized for search queries
352
+ const reader = new BrainyData({
353
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
354
+ distributed: { role: 'reader' } // 80% memory for cache
355
+ })
356
+
357
+ // Data automatically gets domain tags
358
+ await writer.add("Patient shows symptoms of...", {
359
+ diagnosis: "flu" // Auto-tagged as 'medical' domain
360
+ })
361
+
362
+ // Domain-aware search across all partitions
363
+ const results = await reader.search("medical symptoms", 10, {
364
+ filter: { domain: 'medical' } // Only search medical data
365
+ })
366
+
367
+ // Monitor health across all instances
368
+ const health = reader.getHealthStatus()
369
+ console.log(`Instance ${health.instanceId}: ${health.status}`)
370
+ ```
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
+ ```javascript
389
+ // Zero configuration - everything optimized automatically!
390
+ const brainy = new BrainyData() // Auto-detects environment & optimizes
391
+ await brainy.init()
392
+
393
+ // Caching happens automatically - no setup needed!
394
+ const results1 = await brainy.search('query', 10) // ~50ms first time
395
+ const results2 = await brainy.search('query', 10) // <1ms cached hit!
396
+
397
+ // Advanced pagination works instantly
398
+ const page1 = await brainy.searchWithCursor('query', 100)
399
+ const page2 = await brainy.searchWithCursor('query', 100, {
400
+ cursor: page1.cursor // Constant time, no matter how deep!
401
+ })
402
+
403
+ // Monitor auto-optimized performance
404
+ const stats = brainy.getCacheStats()
405
+ console.log(`Auto-tuned cache hit rate: ${(stats.search.hitRate * 100).toFixed(1)}%`)
406
+ ```
407
+
408
+ ## ๐ŸŽญ Key Features
409
+
410
+ ### Core Capabilities
411
+
412
+ - **Vector Search** - Find semantically similar content using embeddings
413
+ - **MongoDB-Style Metadata Filtering** ๐Ÿ†• - Advanced filtering with `$gt`, `$in`, `$regex`, `$and`, `$or` operators
414
+ - **Graph Relationships** - Connect data with meaningful relationships
415
+ - **JSON Document Search** - Search within specific fields with prioritization
416
+ - **Distributed Mode** - Scale horizontally with automatic coordination between instances
417
+ - **Real-Time Syncing** - WebSocket and WebRTC for distributed instances
418
+ - **Streaming Pipeline** - Process data in real-time as it flows through
419
+ - **Model Control Protocol** - Let AI models access your data
420
+
421
+ ### Developer Experience
422
+
423
+ - **TypeScript Support** - Fully typed API with generics
424
+ - **Extensible Augmentations** - Customize and extend functionality
425
+ - **REST API** - Web service wrapper for HTTP endpoints
426
+ - **Auto-Complete** - IntelliSense for all APIs and types
427
+
117
428
  ## ๐Ÿ†š Why Not Just Use...?
118
429
 
119
430
  ### vs. Multiple Databases
@@ -253,6 +564,92 @@ Deploy to: Google Cloud Run, AWS Lambda/ECS, Azure Container Instances, Cloudfla
253
564
 
254
565
  </details>
255
566
 
567
+ ## ๐Ÿš€ Getting Started in 30 Seconds
568
+
569
+ **The same Brainy code works everywhere - React, Vue, Angular, Node.js, Serverless, Edge Workers.**
570
+
571
+ ```javascript
572
+ // This EXACT code works in ALL environments
573
+ import { BrainyData } from '@soulcraft/brainy'
574
+
575
+ const brainy = new BrainyData()
576
+ await brainy.init()
577
+
578
+ // Add nouns (entities)
579
+ const openai = await brainy.add("OpenAI", { type: "company" })
580
+ const gpt4 = await brainy.add("GPT-4", { type: "product" })
581
+
582
+ // Add verbs (relationships)
583
+ await brainy.relate(openai, gpt4, "develops")
584
+
585
+ // Vector search + Graph traversal
586
+ const similar = await brainy.search("AI companies", 5)
587
+ const products = await brainy.getVerbsBySource(openai)
588
+ ```
589
+
590
+ <details>
591
+ <summary>๐Ÿ” <strong>See Framework Examples</strong></summary>
592
+
593
+ ### React
594
+
595
+ ```jsx
596
+ function App() {
597
+ const [brainy] = useState(() => new BrainyData())
598
+ useEffect(() => brainy.init(), [])
599
+
600
+ const search = async (query) => {
601
+ return await brainy.search(query, 10)
602
+ }
603
+ // Same API as above
604
+ }
605
+ ```
606
+
607
+ ### Vue 3
608
+
609
+ ```vue
610
+ <script setup>
611
+ const brainy = new BrainyData()
612
+ await brainy.init()
613
+ // Same API as above
614
+ </script>
615
+ ```
616
+
617
+ ### Angular
618
+
619
+ ```typescript
620
+ @Component({})
621
+ export class AppComponent {
622
+ brainy = new BrainyData()
623
+
624
+ async ngOnInit() {
625
+ await this.brainy.init()
626
+ // Same API as above
627
+ }
628
+ }
629
+ ```
630
+
631
+ ### Node.js / Deno / Bun
632
+
633
+ ```javascript
634
+ const brainy = new BrainyData()
635
+ await brainy.init()
636
+ // Same API as above
637
+ ```
638
+
639
+ </details>
640
+
641
+ ### ๐ŸŒ Framework-First, Runs Everywhere
642
+
643
+ **Brainy automatically detects your environment and optimizes everything:**
644
+
645
+ | Environment | Storage | Optimization |
646
+ |-----------------|-----------------|----------------------------|
647
+ | ๐ŸŒ Browser | OPFS | Web Workers, Memory Cache |
648
+ | ๐ŸŸข Node.js | FileSystem / S3 | Worker Threads, Clustering |
649
+ | โšก Serverless | S3 / Memory | Cold Start Optimization |
650
+ | ๐Ÿ”ฅ Edge Workers | Memory / KV | Minimal Footprint |
651
+ | ๐Ÿฆ• Deno/Bun | FileSystem / S3 | Native Performance |
652
+
256
653
  ## ๐Ÿ“š Documentation & Resources
257
654
 
258
655
  - **[๐Ÿš€ Quick Start Guide](docs/getting-started/)** - Get up and running in minutes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soulcraft/brainy",
3
- "version": "0.51.0",
3
+ "version": "0.51.2",
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",