@soulcraft/brainy 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -13,10 +13,14 @@
13
13
 
14
14
  ## ✨ What is Brainy?
15
15
 
16
- Imagine a database that thinks like you do - connecting ideas, finding patterns, and getting smarter over time. Brainy is the **AI-native database** that brings vector search and knowledge graphs together in one powerful, ridiculously easy-to-use package.
16
+ Imagine a database that thinks like you do - connecting ideas, finding patterns, and getting smarter over time. Brainy
17
+ is the **AI-native database** that brings vector search and knowledge graphs together in one powerful, ridiculously
18
+ easy-to-use package.
17
19
 
18
20
  ### 🆕 NEW: Distributed Mode (v0.38+)
21
+
19
22
  **Scale horizontally with zero configuration!** Brainy now supports distributed deployments with automatic coordination:
23
+
20
24
  - **🌐 Multi-Instance Coordination** - Multiple readers and writers working in harmony
21
25
  - **🏷️ Smart Domain Detection** - Automatically categorizes data (medical, legal, product, etc.)
22
26
  - **📊 Real-Time Health Monitoring** - Track performance across all instances
@@ -25,43 +29,78 @@ Imagine a database that thinks like you do - connecting ideas, finding patterns,
25
29
 
26
30
  ### 🚀 Why Developers Love Brainy
27
31
 
28
- - **🧠 It Just Works™** - No config files, no tuning parameters, no DevOps headaches. Brainy auto-detects your environment and optimizes itself
29
- - **🌍 True Write-Once, Run-Anywhere** - Same code runs in React, Angular, Vue, Node.js, Deno, Bun, serverless, edge workers, and even vanilla HTML
32
+ - **🧠 Zero-to-Smart™** - No config files, no tuning parameters, no DevOps headaches. Brainy auto-detects your
33
+ environment and optimizes itself
34
+ - **🌍 True Write-Once, Run-Anywhere** - Same code runs in React, Angular, Vue, Node.js, Deno, Bun, serverless, edge
35
+ workers, and even vanilla HTML
30
36
  - **⚡ Scary Fast** - Handles millions of vectors with sub-millisecond search. Built-in GPU acceleration when available
31
37
  - **🎯 Self-Learning** - Like having a database that goes to the gym. Gets faster and smarter the more you use it
32
38
  - **🔮 AI-First Design** - Built for the age of embeddings, RAG, and semantic search. Your LLMs will thank you
33
39
  - **🎮 Actually Fun to Use** - Clean API, great DX, and it does the heavy lifting so you can build cool stuff
34
40
 
41
+ ### 🚀 NEW: Ultra-Fast Search Performance + Auto-Configuration
42
+
43
+ **Your searches just got 100x faster AND Brainy now configures itself!** Advanced performance with zero setup:
44
+
45
+ - **🤖 Intelligent Auto-Configuration** - Detects environment and usage patterns, optimizes automatically
46
+ - **⚡ Smart Result Caching** - Repeated queries return in <1ms with automatic cache invalidation
47
+ - **📄 Cursor-Based Pagination** - Navigate millions of results with constant O(k) performance
48
+ - **🔄 Real-Time Data Sync** - Cache automatically updates when data changes, even in distributed scenarios
49
+ - **📊 Performance Monitoring** - Built-in hit rate and memory usage tracking with adaptive optimization
50
+ - **🎯 Zero Breaking Changes** - All existing code works unchanged, just faster and smarter
51
+
52
+ ```javascript
53
+ // Zero configuration - everything optimized automatically!
54
+ const brainy = new BrainyData() // Auto-detects environment & optimizes
55
+ await brainy.init()
56
+
57
+ // Caching happens automatically - no setup needed!
58
+ const results1 = await brainy.search('query', 10) // ~50ms first time
59
+ const results2 = await brainy.search('query', 10) // <1ms cached hit!
60
+
61
+ // Advanced pagination works instantly
62
+ const page1 = await brainy.searchWithCursor('query', 100)
63
+ const page2 = await brainy.searchWithCursor('query', 100, {
64
+ cursor: page1.cursor // Constant time, no matter how deep!
65
+ })
66
+
67
+ // Monitor auto-optimized performance
68
+ const stats = brainy.getCacheStats()
69
+ console.log(`Auto-tuned cache hit rate: ${(stats.search.hitRate * 100).toFixed(1)}%`)
70
+ ```
71
+
35
72
  ## 🚀 Quick Start (30 seconds!)
36
73
 
37
74
  ### Node.js TLDR
75
+
38
76
  ```bash
39
77
  # Install
40
78
  npm install brainy
41
79
 
42
80
  # Use it
43
81
  ```
82
+
44
83
  ```javascript
45
84
  import { createAutoBrainy, NounType, VerbType } from 'brainy'
46
85
 
47
86
  const brainy = createAutoBrainy()
48
87
 
49
88
  // Add data with Nouns (entities)
50
- const catId = await brainy.add("Siamese cats are elegant and vocal", {
89
+ const catId = await brainy.add("Siamese cats are elegant and vocal", {
51
90
  noun: NounType.Thing,
52
91
  breed: "Siamese",
53
- category: "animal"
92
+ category: "animal"
54
93
  })
55
94
 
56
- const ownerId = await brainy.add("John loves his pets", {
95
+ const ownerId = await brainy.add("John loves his pets", {
57
96
  noun: NounType.Person,
58
- name: "John Smith"
97
+ name: "John Smith"
59
98
  })
60
99
 
61
100
  // Connect with Verbs (relationships)
62
- await brainy.addVerb(ownerId, catId, {
101
+ await brainy.addVerb(ownerId, catId, {
63
102
  verb: VerbType.Owns,
64
- since: "2020-01-01"
103
+ since: "2020-01-01"
65
104
  })
66
105
 
67
106
  // Search by meaning
@@ -78,24 +117,25 @@ const docs = await brainy.searchDocuments("Siamese", {
78
117
  const johnsPets = await brainy.getVerbsBySource(ownerId, VerbType.Owns)
79
118
  ```
80
119
 
81
- That's it! No config, no setup, it just works
120
+ That's it! No config, no setup, Zero-to-Smart
82
121
 
83
122
  ### 🌐 Distributed Mode Example (NEW!)
123
+
84
124
  ```javascript
85
125
  // Writer Instance - Ingests data from multiple sources
86
126
  const writer = createAutoBrainy({
87
- storage: { type: 's3', bucket: 'my-bucket' },
127
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
88
128
  distributed: { role: 'writer' } // Explicit role for safety
89
129
  })
90
130
 
91
131
  // Reader Instance - Optimized for search queries
92
132
  const reader = createAutoBrainy({
93
- storage: { type: 's3', bucket: 'my-bucket' },
133
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
94
134
  distributed: { role: 'reader' } // 80% memory for cache
95
135
  })
96
136
 
97
137
  // Data automatically gets domain tags
98
- await writer.add("Patient shows symptoms of...", {
138
+ await writer.add("Patient shows symptoms of...", {
99
139
  diagnosis: "flu" // Auto-tagged as 'medical' domain
100
140
  })
101
141
 
@@ -112,6 +152,7 @@ console.log(`Instance ${health.instanceId}: ${health.status}`)
112
152
  ## 🎭 Key Features
113
153
 
114
154
  ### Core Capabilities
155
+
115
156
  - **Vector Search** - Find semantically similar content using embeddings
116
157
  - **Graph Relationships** - Connect data with meaningful relationships
117
158
  - **JSON Document Search** - Search within specific fields with prioritization
@@ -121,15 +162,20 @@ console.log(`Instance ${health.instanceId}: ${health.status}`)
121
162
  - **Model Control Protocol** - Let AI models access your data
122
163
 
123
164
  ### Smart Optimizations
124
- - **Auto-Configuration** - Detects environment and optimizes automatically
125
- - **Adaptive Learning** - Gets smarter with usage, optimizes itself over time
126
- - **Intelligent Partitioning** - Hash-based partitioning for perfect load distribution
127
- - **Role-Based Optimization** - Readers maximize cache, writers optimize throughput
128
- - **Domain-Aware Indexing** - Automatic categorization improves search relevance
129
- - **Multi-Level Caching** - Hot/warm/cold caching with predictive prefetching
130
- - **Memory Optimization** - 75% reduction with compression for large datasets
165
+
166
+ - **🤖 Intelligent Auto-Configuration** - Detects environment, usage patterns, and optimizes everything automatically
167
+ - **⚡ Runtime Performance Adaptation** - Continuously monitors and self-tunes based on real usage
168
+ - **🌐 Distributed Mode Detection** - Automatically enables real-time updates for shared storage scenarios
169
+ - **📊 Workload-Aware Optimization** - Adapts cache size and TTL based on read/write patterns
170
+ - **🧠 Adaptive Learning** - Gets smarter with usage, learns from your data access patterns
171
+ - **#️⃣ Intelligent Partitioning** - Hash-based partitioning for perfect load distribution
172
+ - **🎯 Role-Based Optimization** - Readers maximize cache, writers optimize throughput
173
+ - **🏷️ Domain-Aware Indexing** - Automatic categorization improves search relevance
174
+ - **🗂️ Multi-Level Caching** - Hot/warm/cold caching with predictive prefetching
175
+ - **💾 Memory Optimization** - 75% reduction with compression for large datasets
131
176
 
132
177
  ### Developer Experience
178
+
133
179
  - **TypeScript Support** - Fully typed API with generics
134
180
  - **Extensible Augmentations** - Customize and extend functionality
135
181
  - **REST API** - Web service wrapper for HTTP endpoints
@@ -138,16 +184,20 @@ console.log(`Instance ${health.instanceId}: ${health.status}`)
138
184
  ## 📦 Installation
139
185
 
140
186
  ### Main Package
187
+
141
188
  ```bash
142
189
  npm install brainy
143
190
  ```
144
191
 
145
192
  ### Optional: Offline Models Package
193
+
146
194
  ```bash
147
195
  npm install @soulcraft/brainy-models
148
196
  ```
149
197
 
150
- The `@soulcraft/brainy-models` package provides **offline access** to the Universal Sentence Encoder model, eliminating network dependencies and ensuring consistent performance. Perfect for:
198
+ The `@soulcraft/brainy-models` package provides **offline access** to the Universal Sentence Encoder model, eliminating
199
+ network dependencies and ensuring consistent performance. Perfect for:
200
+
151
201
  - **Air-gapped environments** - No internet? No problem
152
202
  - **Consistent performance** - No network latency or throttling
153
203
  - **Privacy-focused apps** - Keep everything local
@@ -166,7 +216,8 @@ const brainy = createAutoBrainy({
166
216
  ## 🎨 Build Amazing Things
167
217
 
168
218
  **🤖 AI Chat Applications** - Build ChatGPT-like apps with long-term memory and context awareness
169
- **🔍 Semantic Search Engines** - Search by meaning, not keywords. Find "that thing that's like a cat but bigger" → returns "tiger"
219
+ **🔍 Semantic Search Engines** - Search by meaning, not keywords. Find "that thing that's like a cat but bigger" →
220
+ returns "tiger"
170
221
  **🎯 Recommendation Engines** - "Users who liked this also liked..." but actually good
171
222
  **🧬 Knowledge Graphs** - Connect everything to everything. Wikipedia meets Neo4j meets magic
172
223
  **👁️ Computer Vision Apps** - Store and search image embeddings. "Find all photos with dogs wearing hats"
@@ -178,11 +229,13 @@ const brainy = createAutoBrainy({
178
229
 
179
230
  ## 🧬 The Power of Nouns & Verbs
180
231
 
181
- Brainy uses a **graph-based data model** that mirrors how humans think - with **Nouns** (entities) connected by **Verbs** (relationships). This isn't just vectors in a void; it's structured, meaningful data.
232
+ Brainy uses a **graph-based data model** that mirrors how humans think - with **Nouns** (entities) connected by **Verbs
233
+ ** (relationships). This isn't just vectors in a void; it's structured, meaningful data.
182
234
 
183
235
  ### 📝 Nouns (What Things Are)
184
236
 
185
237
  Nouns are your entities - the "things" in your data. Each noun has:
238
+
186
239
  - A unique ID
187
240
  - A vector representation (for similarity search)
188
241
  - A type (Person, Document, Concept, etc.)
@@ -190,28 +243,29 @@ Nouns are your entities - the "things" in your data. Each noun has:
190
243
 
191
244
  **Available Noun Types:**
192
245
 
193
- | Category | Types | Use For |
194
- |----------|-------|---------|
195
- | **Core Entities** | `Person`, `Organization`, `Location`, `Thing`, `Concept`, `Event` | People, companies, places, objects, ideas, happenings |
196
- | **Digital Content** | `Document`, `Media`, `File`, `Message`, `Content` | PDFs, images, videos, emails, posts, generic content |
197
- | **Collections** | `Collection`, `Dataset` | Groups of items, structured data sets |
198
- | **Business** | `Product`, `Service`, `User`, `Task`, `Project` | E-commerce, SaaS, project management |
199
- | **Descriptive** | `Process`, `State`, `Role` | Workflows, conditions, responsibilities |
246
+ | Category | Types | Use For |
247
+ |---------------------|-------------------------------------------------------------------|-------------------------------------------------------|
248
+ | **Core Entities** | `Person`, `Organization`, `Location`, `Thing`, `Concept`, `Event` | People, companies, places, objects, ideas, happenings |
249
+ | **Digital Content** | `Document`, `Media`, `File`, `Message`, `Content` | PDFs, images, videos, emails, posts, generic content |
250
+ | **Collections** | `Collection`, `Dataset` | Groups of items, structured data sets |
251
+ | **Business** | `Product`, `Service`, `User`, `Task`, `Project` | E-commerce, SaaS, project management |
252
+ | **Descriptive** | `Process`, `State`, `Role` | Workflows, conditions, responsibilities |
200
253
 
201
254
  ### 🔗 Verbs (How Things Connect)
202
255
 
203
- Verbs are your relationships - they give meaning to connections. Not just "these vectors are similar" but "this OWNS that" or "this CAUSES that".
256
+ Verbs are your relationships - they give meaning to connections. Not just "these vectors are similar" but "this OWNS
257
+ that" or "this CAUSES that".
204
258
 
205
259
  **Available Verb Types:**
206
260
 
207
- | Category | Types | Examples |
208
- |----------|-------|----------|
209
- | **Core** | `RelatedTo`, `Contains`, `PartOf`, `LocatedAt`, `References` | Generic relations, containment, location |
210
- | **Temporal** | `Precedes`, `Succeeds`, `Causes`, `DependsOn`, `Requires` | Time sequences, causality, dependencies |
211
- | **Creation** | `Creates`, `Transforms`, `Becomes`, `Modifies`, `Consumes` | Creation, change, consumption |
212
- | **Ownership** | `Owns`, `AttributedTo`, `CreatedBy`, `BelongsTo` | Ownership, authorship, belonging |
213
- | **Social** | `MemberOf`, `WorksWith`, `FriendOf`, `Follows`, `Likes`, `ReportsTo` | Social networks, organizations |
214
- | **Functional** | `Describes`, `Implements`, `Validates`, `Triggers`, `Serves` | Functions, implementations, services |
261
+ | Category | Types | Examples |
262
+ |----------------|----------------------------------------------------------------------|------------------------------------------|
263
+ | **Core** | `RelatedTo`, `Contains`, `PartOf`, `LocatedAt`, `References` | Generic relations, containment, location |
264
+ | **Temporal** | `Precedes`, `Succeeds`, `Causes`, `DependsOn`, `Requires` | Time sequences, causality, dependencies |
265
+ | **Creation** | `Creates`, `Transforms`, `Becomes`, `Modifies`, `Consumes` | Creation, change, consumption |
266
+ | **Ownership** | `Owns`, `AttributedTo`, `CreatedBy`, `BelongsTo` | Ownership, authorship, belonging |
267
+ | **Social** | `MemberOf`, `WorksWith`, `FriendOf`, `Follows`, `Likes`, `ReportsTo` | Social networks, organizations |
268
+ | **Functional** | `Describes`, `Implements`, `Validates`, `Triggers`, `Serves` | Functions, implementations, services |
215
269
 
216
270
  ### 💡 Why This Matters
217
271
 
@@ -221,16 +275,16 @@ const similar = await vectorDB.search(embedding, 10)
221
275
  // Result: [vector1, vector2, ...] - What do these mean? 🤷
222
276
 
223
277
  // Brainy: Similarity + Meaning + Relationships
224
- const catId = await brainy.add("Siamese cat", {
278
+ const catId = await brainy.add("Siamese cat", {
225
279
  noun: NounType.Thing,
226
- breed: "Siamese"
280
+ breed: "Siamese"
227
281
  })
228
- const ownerId = await brainy.add("John Smith", {
229
- noun: NounType.Person
282
+ const ownerId = await brainy.add("John Smith", {
283
+ noun: NounType.Person
230
284
  })
231
- await brainy.addVerb(ownerId, catId, {
285
+ await brainy.addVerb(ownerId, catId, {
232
286
  verb: VerbType.Owns,
233
- since: "2020-01-01"
287
+ since: "2020-01-01"
234
288
  })
235
289
 
236
290
  // Now you can search with context!
@@ -240,44 +294,45 @@ const catOwners = await brainy.getVerbsByTarget(catId, VerbType.Owns)
240
294
 
241
295
  ## 🌍 Distributed Mode (New!)
242
296
 
243
- Brainy now supports **distributed deployments** with multiple specialized instances sharing the same data. Perfect for scaling your AI applications across multiple servers.
297
+ Brainy now supports **distributed deployments** with multiple specialized instances sharing the same data. Perfect for
298
+ scaling your AI applications across multiple servers.
244
299
 
245
300
  ### Distributed Setup
246
301
 
247
302
  ```javascript
248
303
  // Single instance (no change needed!)
249
304
  const brainy = createAutoBrainy({
250
- storage: { type: 's3', bucket: 'my-bucket' }
305
+ storage: { s3Storage: { bucketName: 'my-bucket' } }
251
306
  })
252
307
 
253
308
  // Distributed mode requires explicit role configuration
254
309
  // Option 1: Via environment variable
255
310
  process.env.BRAINY_ROLE = 'writer' // or 'reader' or 'hybrid'
256
311
  const brainy = createAutoBrainy({
257
- storage: { type: 's3', bucket: 'my-bucket' },
312
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
258
313
  distributed: true
259
314
  })
260
315
 
261
316
  // Option 2: Via configuration
262
317
  const writer = createAutoBrainy({
263
- storage: { type: 's3', bucket: 'my-bucket' },
318
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
264
319
  distributed: { role: 'writer' } // Handles data ingestion
265
320
  })
266
321
 
267
322
  const reader = createAutoBrainy({
268
- storage: { type: 's3', bucket: 'my-bucket' },
323
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
269
324
  distributed: { role: 'reader' } // Optimized for queries
270
325
  })
271
326
 
272
327
  // Option 3: Via read/write mode (role auto-inferred)
273
328
  const writer = createAutoBrainy({
274
- storage: { type: 's3', bucket: 'my-bucket' },
329
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
275
330
  writeOnly: true, // Automatically becomes 'writer' role
276
331
  distributed: true
277
332
  })
278
333
 
279
334
  const reader = createAutoBrainy({
280
- storage: { type: 's3', bucket: 'my-bucket' },
335
+ storage: { s3Storage: { bucketName: 'my-bucket' } },
281
336
  readOnly: true, // Automatically becomes 'reader' role
282
337
  distributed: true
283
338
  })
@@ -286,25 +341,28 @@ const reader = createAutoBrainy({
286
341
  ### Key Distributed Features
287
342
 
288
343
  **🎯 Explicit Role Configuration**
344
+
289
345
  - Roles must be explicitly set (no dangerous auto-assignment)
290
346
  - Can use environment variables, config, or read/write modes
291
347
  - Clear separation between writers and readers
292
348
 
293
349
  **#️⃣ Hash-Based Partitioning**
350
+
294
351
  - Handles multiple writers with different data types
295
352
  - Even distribution across partitions
296
353
  - No semantic conflicts with mixed data
297
354
 
298
355
  **🏷️ Domain Tagging**
356
+
299
357
  - Automatic domain detection (medical, legal, product, etc.)
300
358
  - Filter searches by domain
301
359
  - Logical separation without complexity
302
360
 
303
361
  ```javascript
304
362
  // Data is automatically tagged with domains
305
- await brainy.add({
306
- symptoms: "fever",
307
- diagnosis: "flu"
363
+ await brainy.add({
364
+ symptoms: "fever",
365
+ diagnosis: "flu"
308
366
  }, metadata) // Auto-tagged as 'medical'
309
367
 
310
368
  // Search within specific domains
@@ -314,6 +372,7 @@ const medicalResults = await brainy.search(query, 10, {
314
372
  ```
315
373
 
316
374
  **📊 Health Monitoring**
375
+
317
376
  - Real-time health metrics
318
377
  - Automatic dead instance cleanup
319
378
  - Performance tracking
@@ -331,6 +390,7 @@ const health = brainy.getHealthStatus()
331
390
  ```
332
391
 
333
392
  **⚡ Role-Optimized Performance**
393
+
334
394
  - **Readers**: 80% memory for cache, aggressive prefetching
335
395
  - **Writers**: Optimized write batching, minimal cache
336
396
  - **Hybrid**: Adaptive based on workload
@@ -338,13 +398,14 @@ const health = brainy.getHealthStatus()
338
398
  ### Deployment Examples
339
399
 
340
400
  **Docker Compose**
401
+
341
402
  ```yaml
342
403
  services:
343
404
  writer:
344
405
  image: myapp
345
406
  environment:
346
407
  BRAINY_ROLE: writer # Optional - auto-detects
347
-
408
+
348
409
  reader:
349
410
  image: myapp
350
411
  environment:
@@ -353,6 +414,7 @@ services:
353
414
  ```
354
415
 
355
416
  **Kubernetes**
417
+
356
418
  ```yaml
357
419
  # Automatically detects role from deployment type
358
420
  apiVersion: apps/v1
@@ -364,12 +426,13 @@ spec:
364
426
  template:
365
427
  spec:
366
428
  containers:
367
- - name: app
368
- image: myapp
369
- # Role auto-detected as 'reader' (multiple replicas)
429
+ - name: app
430
+ image: myapp
431
+ # Role auto-detected as 'reader' (multiple replicas)
370
432
  ```
371
433
 
372
434
  **Benefits**
435
+
373
436
  - ✅ **50-70% faster searches** with parallel readers
374
437
  - ✅ **No coordination complexity** - Shared JSON config in S3
375
438
  - ✅ **Zero downtime scaling** - Add/remove instances anytime
@@ -378,18 +441,22 @@ spec:
378
441
  ## 🤔 Why Choose Brainy?
379
442
 
380
443
  ### vs. Traditional Databases
444
+
381
445
  ❌ **PostgreSQL with pgvector** - Requires complex setup, tuning, and DevOps expertise
382
446
  ✅ **Brainy** - Zero config, auto-optimizes, works everywhere from browser to cloud
383
447
 
384
448
  ### vs. Vector Databases
449
+
385
450
  ❌ **Pinecone/Weaviate/Qdrant** - Cloud-only, expensive, vendor lock-in
386
451
  ✅ **Brainy** - Run locally, in browser, or cloud. Your choice, your data
387
452
 
388
453
  ### vs. Graph Databases
454
+
389
455
  ❌ **Neo4j** - Great for graphs, no vector support
390
456
  ✅ **Brainy** - Vectors + graphs in one. Best of both worlds
391
457
 
392
458
  ### vs. DIY Solutions
459
+
393
460
  ❌ **Building your own** - Months of work, optimization nightmares
394
461
  ✅ **Brainy** - Production-ready in 30 seconds
395
462
 
@@ -411,7 +478,7 @@ function SemanticSearch() {
411
478
  }
412
479
 
413
480
  return (
414
- <input onChange={(e) => search(e.target.value)}
481
+ <input onChange={(e) => search(e.target.value)}
415
482
  placeholder="Search by meaning..." />
416
483
  )
417
484
  }
@@ -446,20 +513,21 @@ export class SearchComponent implements OnInit {
446
513
  ### Vue 3
447
514
 
448
515
  ```vue
516
+
449
517
  <script setup>
450
- import { createAutoBrainy } from 'brainy'
451
- import { ref } from 'vue'
518
+ import { createAutoBrainy } from 'brainy'
519
+ import { ref } from 'vue'
452
520
 
453
- const brainy = createAutoBrainy()
454
- const results = ref([])
521
+ const brainy = createAutoBrainy()
522
+ const results = ref([])
455
523
 
456
- const search = async (query) => {
457
- results.value = await brainy.searchText(query, 10)
458
- }
524
+ const search = async (query) => {
525
+ results.value = await brainy.searchText(query, 10)
526
+ }
459
527
  </script>
460
528
 
461
529
  <template>
462
- <input @input="search($event.target.value)"
530
+ <input @input="search($event.target.value)"
463
531
  placeholder="Find similar content...">
464
532
  <div v-for="result in results" :key="result.id">
465
533
  {{ result.text }}
@@ -535,19 +603,19 @@ console.log(results)
535
603
  <head>
536
604
  <script type="module">
537
605
  import { createAutoBrainy } from 'https://unpkg.com/brainy/dist/unified.min.js'
538
-
606
+
539
607
  window.brainy = createAutoBrainy()
540
-
608
+
541
609
  window.search = async function(query) {
542
610
  const results = await brainy.searchText(query, 10)
543
- document.getElementById('results').innerHTML =
611
+ document.getElementById('results').innerHTML =
544
612
  results.map(r => `<div>${r.text}</div>`).join('')
545
613
  }
546
614
  </script>
547
615
  </head>
548
616
  <body>
549
- <input onkeyup="search(this.value)" placeholder="Search...">
550
- <div id="results"></div>
617
+ <input onkeyup="search(this.value)" placeholder="Search...">
618
+ <div id="results"></div>
551
619
  </body>
552
620
  </html>
553
621
  ```
@@ -559,13 +627,13 @@ import { createAutoBrainy } from 'brainy'
559
627
 
560
628
  export default {
561
629
  async fetch(request, env) {
562
- const brainy = createAutoBrainy({
563
- bucketName: env.R2_BUCKET
630
+ const brainy = createAutoBrainy({
631
+ bucketName: env.R2_BUCKET
564
632
  })
565
-
633
+
566
634
  const url = new URL(request.url)
567
635
  const query = url.searchParams.get('q')
568
-
636
+
569
637
  const results = await brainy.searchText(query, 10)
570
638
  return Response.json(results)
571
639
  }
@@ -578,12 +646,12 @@ export default {
578
646
  import { createAutoBrainy } from 'brainy'
579
647
 
580
648
  export const handler = async (event) => {
581
- const brainy = createAutoBrainy({
582
- bucketName: process.env.S3_BUCKET
649
+ const brainy = createAutoBrainy({
650
+ bucketName: process.env.S3_BUCKET
583
651
  })
584
-
652
+
585
653
  const results = await brainy.searchText(event.query, 10)
586
-
654
+
587
655
  return {
588
656
  statusCode: 200,
589
657
  body: JSON.stringify(results)
@@ -596,13 +664,13 @@ export const handler = async (event) => {
596
664
  ```javascript
597
665
  import { createAutoBrainy } from 'brainy'
598
666
 
599
- module.exports = async function (context, req) {
667
+ module.exports = async function(context, req) {
600
668
  const brainy = createAutoBrainy({
601
669
  bucketName: process.env.AZURE_STORAGE_CONTAINER
602
670
  })
603
-
671
+
604
672
  const results = await brainy.searchText(req.query.q, 10)
605
-
673
+
606
674
  context.res = {
607
675
  body: results
608
676
  }
@@ -618,7 +686,7 @@ export const searchHandler = async (req, res) => {
618
686
  const brainy = createAutoBrainy({
619
687
  bucketName: process.env.GCS_BUCKET
620
688
  })
621
-
689
+
622
690
  const results = await brainy.searchText(req.query.q, 10)
623
691
  res.json(results)
624
692
  }
@@ -678,7 +746,7 @@ export default async function handler(request) {
678
746
  const brainy = createAutoBrainy()
679
747
  const { searchParams } = new URL(request.url)
680
748
  const query = searchParams.get('q')
681
-
749
+
682
750
  const results = await brainy.searchText(query, 10)
683
751
  return Response.json(results)
684
752
  }
@@ -692,9 +760,9 @@ import { createAutoBrainy } from 'brainy'
692
760
  export async function handler(event, context) {
693
761
  const brainy = createAutoBrainy()
694
762
  const query = event.queryStringParameters.q
695
-
763
+
696
764
  const results = await brainy.searchText(query, 10)
697
-
765
+
698
766
  return {
699
767
  statusCode: 200,
700
768
  body: JSON.stringify(results)
@@ -712,9 +780,9 @@ serve(async (req) => {
712
780
  const brainy = createAutoBrainy()
713
781
  const url = new URL(req.url)
714
782
  const query = url.searchParams.get('q')
715
-
783
+
716
784
  const results = await brainy.searchText(query, 10)
717
-
785
+
718
786
  return new Response(JSON.stringify(results), {
719
787
  headers: { 'Content-Type': 'application/json' }
720
788
  })
@@ -762,11 +830,11 @@ spec:
762
830
  template:
763
831
  spec:
764
832
  containers:
765
- - name: brainy
766
- image: your-registry/brainy-api:latest
767
- env:
768
- - name: S3_BUCKET
769
- value: "your-vector-bucket"
833
+ - name: brainy
834
+ image: your-registry/brainy-api:latest
835
+ env:
836
+ - name: S3_BUCKET
837
+ value: "your-vector-bucket"
770
838
  ```
771
839
 
772
840
  ### Railway.app
@@ -861,52 +929,60 @@ const brainy = createAutoBrainy({
861
929
  })
862
930
 
863
931
  // Works exactly the same, but 100% offline
864
- await brainy.add("This works without internet!", {
865
- noun: NounType.Content
932
+ await brainy.add("This works without internet!", {
933
+ noun: NounType.Content
866
934
  })
867
935
  ```
868
936
 
869
937
  ## 🌐 Live Demo
870
938
 
871
- **[Try the interactive demo](https://soulcraft-research.github.io/brainy/demo/index.html)** - See Brainy in action with animations and examples.
939
+ **[Try the interactive demo](https://soulcraft-research.github.io/brainy/demo/index.html)** - See Brainy in action with
940
+ animations and examples.
872
941
 
873
942
  ## 🔧 Environment Support
874
943
 
875
- | Environment | Storage | Threading | Auto-Configured |
876
- |-------------|---------|-----------|-----------------|
877
- | Browser | OPFS | Web Workers | ✅ |
878
- | Node.js | FileSystem/S3 | Worker Threads | ✅ |
879
- | Serverless | Memory/S3 | Limited | ✅ |
880
- | Edge Functions | Memory/KV | Limited | ✅ |
944
+ | Environment | Storage | Threading | Auto-Configured |
945
+ |----------------|---------------|----------------|-----------------|
946
+ | Browser | OPFS | Web Workers | ✅ |
947
+ | Node.js | FileSystem/S3 | Worker Threads | ✅ |
948
+ | Serverless | Memory/S3 | Limited | ✅ |
949
+ | Edge Functions | Memory/KV | Limited | ✅ |
881
950
 
882
951
  ## 📚 Documentation
883
952
 
884
953
  ### Getting Started
954
+
885
955
  - [**Quick Start Guide**](docs/getting-started/) - Get up and running in minutes
886
956
  - [**Installation**](docs/getting-started/installation.md) - Detailed setup instructions
887
957
  - [**Environment Setup**](docs/getting-started/environment-setup.md) - Platform-specific configuration
888
958
 
889
959
  ### User Guides
960
+
890
961
  - [**Search and Metadata**](docs/user-guides/) - Advanced search techniques
891
962
  - [**JSON Document Search**](docs/guides/json-document-search.md) - Field-based searching
892
963
  - [**Production Migration**](docs/guides/production-migration-guide.md) - Deployment best practices
893
964
 
894
965
  ### API Reference
966
+
895
967
  - [**Core API**](docs/api-reference/) - Complete method reference
896
968
  - [**Configuration Options**](docs/api-reference/configuration.md) - All configuration parameters
897
- - [**Auto-Configuration API**](docs/api-reference/auto-configuration-api.md) - Intelligent setup
898
969
 
899
970
  ### Optimization & Scaling
971
+
972
+ - [**Performance Features Guide**](docs/PERFORMANCE_FEATURES.md) - Advanced caching, auto-configuration, and
973
+ optimization
900
974
  - [**Large-Scale Optimizations**](docs/optimization-guides/) - Handle millions of vectors
901
975
  - [**Memory Management**](docs/optimization-guides/memory-optimization.md) - Efficient resource usage
902
976
  - [**S3 Migration Guide**](docs/optimization-guides/s3-migration-guide.md) - Cloud storage setup
903
977
 
904
978
  ### Examples & Patterns
979
+
905
980
  - [**Code Examples**](docs/examples/) - Real-world usage patterns
906
981
  - [**Integrations**](docs/examples/integrations.md) - Third-party services
907
982
  - [**Performance Patterns**](docs/examples/performance.md) - Optimization techniques
908
983
 
909
984
  ### Technical Documentation
985
+
910
986
  - [**Architecture Overview**](docs/technical/) - System design and internals
911
987
  - [**Testing Guide**](docs/technical/TESTING.md) - Testing strategies
912
988
  - [**Statistics & Monitoring**](docs/technical/STATISTICS.md) - Performance tracking
@@ -914,6 +990,7 @@ await brainy.add("This works without internet!", {
914
990
  ## 🤝 Contributing
915
991
 
916
992
  We welcome contributions! Please see:
993
+
917
994
  - [Contributing Guidelines](CONTRIBUTING.md)
918
995
  - [Developer Documentation](docs/development/DEVELOPERS.md)
919
996
  - [Code of Conduct](CODE_OF_CONDUCT.md)