@soulcraft/brainy 1.5.0 → 2.0.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 (141) hide show
  1. package/CHANGELOG.md +188 -0
  2. package/LICENSE +2 -2
  3. package/README.md +201 -596
  4. package/bin/brainy-interactive.js +564 -0
  5. package/bin/brainy-ts.js +18 -0
  6. package/bin/brainy.js +672 -81
  7. package/dist/augmentationPipeline.d.ts +48 -220
  8. package/dist/augmentationPipeline.js +60 -508
  9. package/dist/augmentationRegistry.d.ts +22 -31
  10. package/dist/augmentationRegistry.js +28 -79
  11. package/dist/augmentations/apiServerAugmentation.d.ts +108 -0
  12. package/dist/augmentations/apiServerAugmentation.js +502 -0
  13. package/dist/augmentations/batchProcessingAugmentation.d.ts +95 -0
  14. package/dist/augmentations/batchProcessingAugmentation.js +567 -0
  15. package/dist/augmentations/brainyAugmentation.d.ts +153 -0
  16. package/dist/augmentations/brainyAugmentation.js +145 -0
  17. package/dist/augmentations/cacheAugmentation.d.ts +105 -0
  18. package/dist/augmentations/cacheAugmentation.js +238 -0
  19. package/dist/augmentations/conduitAugmentations.d.ts +54 -156
  20. package/dist/augmentations/conduitAugmentations.js +156 -1082
  21. package/dist/augmentations/connectionPoolAugmentation.d.ts +62 -0
  22. package/dist/augmentations/connectionPoolAugmentation.js +316 -0
  23. package/dist/augmentations/defaultAugmentations.d.ts +53 -0
  24. package/dist/augmentations/defaultAugmentations.js +88 -0
  25. package/dist/augmentations/entityRegistryAugmentation.d.ts +126 -0
  26. package/dist/augmentations/entityRegistryAugmentation.js +386 -0
  27. package/dist/augmentations/indexAugmentation.d.ts +117 -0
  28. package/dist/augmentations/indexAugmentation.js +284 -0
  29. package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +152 -0
  30. package/dist/augmentations/intelligentVerbScoringAugmentation.js +554 -0
  31. package/dist/augmentations/metricsAugmentation.d.ts +202 -0
  32. package/dist/augmentations/metricsAugmentation.js +291 -0
  33. package/dist/augmentations/monitoringAugmentation.d.ts +94 -0
  34. package/dist/augmentations/monitoringAugmentation.js +227 -0
  35. package/dist/augmentations/neuralImport.d.ts +50 -117
  36. package/dist/augmentations/neuralImport.js +255 -629
  37. package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +52 -0
  38. package/dist/augmentations/requestDeduplicatorAugmentation.js +162 -0
  39. package/dist/augmentations/serverSearchAugmentations.d.ts +43 -22
  40. package/dist/augmentations/serverSearchAugmentations.js +125 -72
  41. package/dist/augmentations/storageAugmentation.d.ts +54 -0
  42. package/dist/augmentations/storageAugmentation.js +93 -0
  43. package/dist/augmentations/storageAugmentations.d.ts +96 -0
  44. package/dist/augmentations/storageAugmentations.js +182 -0
  45. package/dist/augmentations/synapseAugmentation.d.ts +156 -0
  46. package/dist/augmentations/synapseAugmentation.js +312 -0
  47. package/dist/augmentations/walAugmentation.d.ts +108 -0
  48. package/dist/augmentations/walAugmentation.js +515 -0
  49. package/dist/brainyData.d.ts +404 -130
  50. package/dist/brainyData.js +1331 -853
  51. package/dist/chat/BrainyChat.d.ts +16 -8
  52. package/dist/chat/BrainyChat.js +60 -32
  53. package/dist/chat/ChatCLI.d.ts +1 -1
  54. package/dist/chat/ChatCLI.js +6 -6
  55. package/dist/cli/catalog.d.ts +3 -3
  56. package/dist/cli/catalog.js +116 -70
  57. package/dist/cli/commands/core.d.ts +61 -0
  58. package/dist/cli/commands/core.js +348 -0
  59. package/dist/cli/commands/neural.d.ts +25 -0
  60. package/dist/cli/commands/neural.js +508 -0
  61. package/dist/cli/commands/utility.d.ts +37 -0
  62. package/dist/cli/commands/utility.js +276 -0
  63. package/dist/cli/index.d.ts +7 -0
  64. package/dist/cli/index.js +167 -0
  65. package/dist/cli/interactive.d.ts +164 -0
  66. package/dist/cli/interactive.js +542 -0
  67. package/dist/cortex/neuralImport.js +5 -5
  68. package/dist/critical/model-guardian.js +11 -4
  69. package/dist/embeddings/lightweight-embedder.d.ts +23 -0
  70. package/dist/embeddings/lightweight-embedder.js +136 -0
  71. package/dist/embeddings/universal-memory-manager.d.ts +38 -0
  72. package/dist/embeddings/universal-memory-manager.js +206 -0
  73. package/dist/embeddings/worker-embedding.d.ts +7 -0
  74. package/dist/embeddings/worker-embedding.js +77 -0
  75. package/dist/embeddings/worker-manager.d.ts +28 -0
  76. package/dist/embeddings/worker-manager.js +162 -0
  77. package/dist/examples/basicUsage.js +7 -7
  78. package/dist/graph/pathfinding.d.ts +78 -0
  79. package/dist/graph/pathfinding.js +393 -0
  80. package/dist/hnsw/hnswIndex.d.ts +13 -0
  81. package/dist/hnsw/hnswIndex.js +35 -0
  82. package/dist/hnsw/hnswIndexOptimized.d.ts +1 -0
  83. package/dist/hnsw/hnswIndexOptimized.js +3 -0
  84. package/dist/index.d.ts +9 -11
  85. package/dist/index.js +21 -11
  86. package/dist/indices/fieldIndex.d.ts +76 -0
  87. package/dist/indices/fieldIndex.js +357 -0
  88. package/dist/mcp/brainyMCPAdapter.js +3 -2
  89. package/dist/mcp/mcpAugmentationToolset.js +11 -17
  90. package/dist/neural/embeddedPatterns.d.ts +41 -0
  91. package/dist/neural/embeddedPatterns.js +4044 -0
  92. package/dist/neural/naturalLanguageProcessor.d.ts +94 -0
  93. package/dist/neural/naturalLanguageProcessor.js +317 -0
  94. package/dist/neural/naturalLanguageProcessorStatic.d.ts +64 -0
  95. package/dist/neural/naturalLanguageProcessorStatic.js +151 -0
  96. package/dist/neural/neuralAPI.d.ts +255 -0
  97. package/dist/neural/neuralAPI.js +612 -0
  98. package/dist/neural/patternLibrary.d.ts +101 -0
  99. package/dist/neural/patternLibrary.js +313 -0
  100. package/dist/neural/patterns.d.ts +27 -0
  101. package/dist/neural/patterns.js +68 -0
  102. package/dist/neural/staticPatternMatcher.d.ts +35 -0
  103. package/dist/neural/staticPatternMatcher.js +153 -0
  104. package/dist/scripts/precomputePatternEmbeddings.d.ts +19 -0
  105. package/dist/scripts/precomputePatternEmbeddings.js +100 -0
  106. package/dist/storage/adapters/fileSystemStorage.d.ts +5 -0
  107. package/dist/storage/adapters/fileSystemStorage.js +20 -0
  108. package/dist/storage/adapters/s3CompatibleStorage.d.ts +5 -0
  109. package/dist/storage/adapters/s3CompatibleStorage.js +16 -0
  110. package/dist/storage/enhancedClearOperations.d.ts +83 -0
  111. package/dist/storage/enhancedClearOperations.js +345 -0
  112. package/dist/storage/storageFactory.js +31 -27
  113. package/dist/triple/TripleIntelligence.d.ts +134 -0
  114. package/dist/triple/TripleIntelligence.js +548 -0
  115. package/dist/types/augmentations.d.ts +45 -344
  116. package/dist/types/augmentations.js +5 -2
  117. package/dist/types/brainyDataInterface.d.ts +20 -10
  118. package/dist/types/graphTypes.d.ts +46 -0
  119. package/dist/types/graphTypes.js +16 -2
  120. package/dist/utils/BoundedRegistry.d.ts +29 -0
  121. package/dist/utils/BoundedRegistry.js +54 -0
  122. package/dist/utils/embedding.js +20 -3
  123. package/dist/utils/hybridModelManager.js +10 -5
  124. package/dist/utils/metadataFilter.d.ts +33 -19
  125. package/dist/utils/metadataFilter.js +58 -23
  126. package/dist/utils/metadataIndex.d.ts +37 -6
  127. package/dist/utils/metadataIndex.js +427 -64
  128. package/dist/utils/requestDeduplicator.d.ts +10 -0
  129. package/dist/utils/requestDeduplicator.js +24 -0
  130. package/dist/utils/unifiedCache.d.ts +103 -0
  131. package/dist/utils/unifiedCache.js +311 -0
  132. package/package.json +43 -128
  133. package/scripts/ensure-models.js +108 -0
  134. package/scripts/prepare-models.js +387 -0
  135. package/OFFLINE_MODELS.md +0 -56
  136. package/dist/intelligence/neuralEngine.d.ts +0 -207
  137. package/dist/intelligence/neuralEngine.js +0 -706
  138. package/dist/utils/modelLoader.d.ts +0 -32
  139. package/dist/utils/modelLoader.js +0 -219
  140. package/dist/utils/modelManager.d.ts +0 -77
  141. package/dist/utils/modelManager.js +0 -219
package/README.md CHANGED
@@ -1,698 +1,303 @@
1
- <div align="center">
1
+ # Brainy
2
2
 
3
- ![Brainy Logo](brainy.png)
3
+ <p align="center">
4
+ <img src="brainy.png" alt="Brainy Logo" width="200">
5
+ </p>
4
6
 
5
- [![npm version](https://badge.fury.io/js/%40soulcraft%2Fbrainy.svg)](https://badge.fury.io/js/%40soulcraft%2Fbrainy)
6
- [![1.0](https://img.shields.io/badge/Version-1.0.0-brightgreen.svg)](https://github.com/soulcraftlabs/brainy/releases/tag/v1.0.0)
7
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
- [![Website](https://img.shields.io/badge/Website-soulcraft.com-green.svg)](https://soulcraft.com)
9
- [![Brain Cloud](https://img.shields.io/badge/Brain%20Cloud-Coming%20Soon-blue.svg)](https://soulcraft.com)
10
- [![Node.js](https://img.shields.io/badge/node-%3E%3D24.4.1-brightgreen.svg)](https://nodejs.org/)
11
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.4.5-blue.svg)](https://www.typescriptlang.org/)
7
+ [![npm version](https://badge.fury.io/js/brainy.svg)](https://www.npmjs.com/package/brainy)
8
+ [![npm downloads](https://img.shields.io/npm/dm/brainy.svg)](https://www.npmjs.com/package/brainy)
9
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
+ [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/)
12
11
 
13
- # The World's First Multi-Dimensional AI Database
12
+ **🧠 Brainy 2.0 - Zero-Configuration AI Database with Triple Intelligence™**
14
13
 
15
- *Vector similarity Graph relationships Metadata facets Neural understanding*
14
+ The industry's first truly zero-configuration AI database that combines vector similarity, metadata filtering, and graph relationships with O(log n) performance. Production-ready with 3ms search latency, 220 pre-computed NLP patterns, and only 24MB memory footprint.
16
15
 
17
- **Build AI apps that actually understand your data - in minutes, not months**
16
+ ## 🎉 What's New in 2.0
18
17
 
19
- </div>
18
+ - **Triple Intelligence™**: Unified Vector + Metadata + Graph queries in one API
19
+ - **API Consolidation**: 15+ methods → 2 clean APIs (`search()` and `find()`)
20
+ - **Natural Language**: Ask questions in plain English
21
+ - **Zero Configuration**: Works instantly, no setup required
22
+ - **O(log n) Performance**: Binary search on sorted indices
23
+ - **220+ NLP Patterns**: Pre-computed for instant understanding
24
+ - **Universal Compatibility**: Node.js, Browser, Edge, Workers
20
25
 
21
- ---
22
-
23
- ## 💖 **Support Brainy's Development**
24
-
25
- <div align="center">
26
-
27
- **Brainy is 100% open source and free forever!** Help us keep it that way:
28
-
29
- [![Sponsor](https://img.shields.io/badge/💖_Sponsor_Brainy-Support_Development-ff69b4?style=for-the-badge)](https://github.com/soulcraftlabs/brainy)
30
- [![Brain Cloud](https://img.shields.io/badge/☁️_Try_Brain_Cloud-Coming_Soon-4A90E2?style=for-the-badge)](https://soulcraft.com)
31
- [![Star](https://img.shields.io/badge/⭐_Star_on_GitHub-Show_Support-FFC107?style=for-the-badge)](https://github.com/soulcraftlabs/brainy)
32
-
33
- **Every sponsorship helps us:** Build more features • Fix bugs faster • Keep Brainy free
34
-
35
- </div>
36
-
37
- ---
38
-
39
- ## 🎉 **NEW: Brainy 1.0 - The Unified API**
40
-
41
- **The Great Cleanup is complete!** Brainy 1.0 introduces the **unified API** - ONE way to do everything with just **9 core methods**:
26
+ ## ⚡ Quick Start
42
27
 
43
28
  ```bash
44
- # Install Brainy 1.0
45
- npm install @soulcraft/brainy
29
+ npm install brainy
46
30
  ```
47
31
 
48
32
  ```javascript
49
- import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
33
+ import { BrainyData } from 'brainy'
50
34
 
51
35
  const brain = new BrainyData()
52
36
  await brain.init()
53
37
 
54
- // 🎯 THE 9 UNIFIED METHODS - One way to do everything!
55
- await brain.add("Smart data") // 1. Smart addition
56
- await brain.search("query", 10) // 2. Unified search
57
- await brain.import(["data1", "data2"]) // 3. Bulk import
58
- await brain.addNoun("John", NounType.Person) // 4. Typed entities
59
- await brain.addVerb(id1, id2, VerbType.Knows) // 5. Relationships
60
- await brain.update(id, "new data") // 6. Smart updates
61
- await brain.delete(id) // 7. Soft delete
62
- await brain.export({ format: 'json' }) // 8. Export data
63
- brain.augment(myAugmentation) // 9. Extend infinitely! ♾️
64
-
65
- // NEW: Type-safe augmentation management via brain.augmentations
66
- brain.augmentations.list() // See all augmentations
67
- brain.augmentations.enable(name) // Enable/disable dynamically
68
- ```
69
-
70
- ### ✨ **What's New in 1.0:**
71
- - **🔥 40+ methods consolidated** → 9 unified methods
72
- - **♾️ The 9th method** - `augment()` lets you extend Brainy infinitely!
73
- - **🧠 Smart by default** - `add()` auto-detects and processes intelligently
74
- - **🔐 Universal encryption** - Built-in encryption for sensitive data
75
- - **🐳 Container ready** - Model preloading for production deployments
76
- - **📦 16% smaller package** despite major new features
77
- - **🔄 Soft delete default** - Better performance, no reindexing needed
78
-
79
- **Breaking Changes:** See [MIGRATION.md](MIGRATION.md) for complete upgrade guide.
80
-
81
- ---
82
-
83
- ## ✅ 100% Free & Open Source
84
-
85
- **Brainy is completely free. No license keys. No limits. No catch.**
86
-
87
- Every feature you see here works without any payment or registration:
88
- - ✓ Full vector database
89
- - ✓ Graph relationships
90
- - ✓ Semantic search
91
- - ✓ All storage adapters
92
- - ✓ Complete API
93
- - ✓ Forever free
94
-
95
- > 🌩️ **Brain Cloud** is our optional cloud service that helps sustain Brainy's development. Currently in early access at [soulcraft.com](https://soulcraft.com).
96
-
97
- ---
98
-
99
- ## 💫 Why Brainy? The Problem We Solve
38
+ // Add data with automatic embedding
39
+ await brain.addNoun("JavaScript is a programming language", {
40
+ type: "language",
41
+ year: 1995
42
+ })
100
43
 
101
- ### **The Old Way: Database Frankenstein**
102
- ```
103
- Pinecone ($750/mo) + Neo4j ($500/mo) + Elasticsearch ($300/mo) +
104
- Sync nightmares + 3 different APIs + Vendor lock-in = 😱💸
105
- ```
44
+ // Natural language search
45
+ const results = await brain.find("programming languages from the 90s")
106
46
 
107
- ### **The Brainy Way: One Brain, All Dimensions**
108
- ```
109
- Vector + Graph + Search + AI = Brainy (Free & Open Source) = 🧠✨
47
+ // Vector similarity with metadata filtering
48
+ const filtered = await brain.search("JavaScript", {
49
+ metadata: { type: "language" },
50
+ limit: 5
51
+ })
110
52
  ```
111
53
 
112
- **Your data gets superpowers. Your wallet stays happy.**
54
+ ## 🚀 Key Features
113
55
 
114
- ### 🧠 **Why Developers Love Brainy 1.0**
56
+ ### Triple Intelligence Engine
57
+ Combines three search paradigms in one unified API:
58
+ - **Vector Search**: Semantic similarity with HNSW indexing
59
+ - **Metadata Filtering**: O(log n) field lookups with binary search
60
+ - **Graph Relationships**: Navigate connected knowledge
115
61
 
116
- #### **⚡ One API to Rule Them All**
62
+ ### Natural Language Understanding
117
63
  ```javascript
118
- // Before: Learning 10+ different database APIs
119
- pinecone.upsert(), neo4j.run(), elasticsearch.search()
120
- supabase.insert(), mongodb.find(), redis.set()
121
-
122
- // After: 9 methods handle EVERYTHING
123
- brain.add(), brain.search(), brain.import()
124
- brain.addNoun(), brain.addVerb(), brain.update()
125
- brain.delete(), brain.export(), brain.augment()
126
-
127
- // Why 9? The 9th method (augment) gives you methods 10 → ∞!
64
+ // Ask questions naturally
65
+ await brain.find("Show me recent React components with tests")
66
+ await brain.find("Popular JavaScript libraries similar to Vue")
67
+ await brain.find("Documentation about authentication from last month")
128
68
  ```
129
69
 
130
- #### **🤯 Mind-Blowing Features Out of the Box**
131
- - **Smart by Default**: `add()` automatically understands your data
132
- - **Graph + Vector**: Relationships AND semantic similarity in one query
133
- - **Zero Config**: Works instantly, optimizes itself
134
- - **Universal Encryption**: Secure everything with one flag
135
- - **Perfect Memory**: Nothing ever gets lost or forgotten
136
-
137
- #### **💰 Cost Comparison**
138
- | Traditional Stack | Monthly Cost | Brainy 1.0 |
139
- |------------------|--------------|-------------|
140
- | Pinecone + Neo4j + Search | $1,500+ | **$0** |
141
- | 3 different APIs to learn | Weeks | **Minutes** |
142
- | Sync complexity | High | **None** |
143
- | Vendor lock-in | Yes | **MIT License** |
70
+ ### Zero Configuration Philosophy
71
+ - **No API keys required** - Built-in embedding models
72
+ - **No external dependencies** - Everything included
73
+ - **No complex setup** - Works instantly
74
+ - **Smart defaults** - Optimized out of the box
144
75
 
145
- ---
146
-
147
- ## 🚀 What Can You Build?
148
-
149
- ### 💬 **AI Chat Apps** - That Actually Remember
150
- ```javascript
151
- // Your users' conversations persist across sessions
152
- const brain = new BrainyData()
153
- await brain.add("User prefers dark mode")
154
- await brain.add("User is learning Spanish")
76
+ ### Production Performance
77
+ - **3ms average search** - Lightning fast queries
78
+ - **24MB memory footprint** - Efficient resource usage
79
+ - **Worker-based embeddings** - Non-blocking operations
80
+ - **Automatic caching** - Intelligent result caching
155
81
 
156
- // Later sessions remember everything
157
- const context = await brain.search("user preferences")
158
- // AI knows: dark mode + Spanish learning preference
159
- ```
82
+ ## 📚 Core API
160
83
 
161
- ### 🤖 **Smart Assistants** - With Real Knowledge Graphs
84
+ ### `search()` - Vector Similarity
162
85
  ```javascript
163
- // Build assistants that understand relationships (NEW 1.0 API!)
164
- import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
165
-
166
- const brain = new BrainyData()
167
- await brain.init()
168
-
169
- // Create typed entities
170
- const sarahId = await brain.addNoun("Sarah Thompson", NounType.Person)
171
- const johnId = await brain.addNoun("John Davis", NounType.Person)
172
- const projectId = await brain.addNoun("Project Apollo", NounType.Project)
173
-
174
- // Create relationships with metadata
175
- await brain.addVerb(sarahId, johnId, VerbType.ReportsTo, {
176
- role: "Design Manager",
177
- startDate: "2024-01-15"
178
- })
179
- await brain.addVerb(sarahId, projectId, VerbType.WorksWith, {
180
- responsibility: "Lead Designer",
181
- allocation: "75%"
86
+ const results = await brain.search("machine learning", {
87
+ limit: 10, // Number of results
88
+ metadata: { type: "article" }, // Filter by metadata
89
+ includeContent: true // Include full content
182
90
  })
183
-
184
- // Query complex relationships with graph traversal
185
- const sarahData = await brain.getNounWithVerbs(sarahId)
186
- // Returns: complete graph view with all relationships and metadata
187
- ```
188
-
189
- ### 📊 **RAG Applications** - Without the Complexity
190
- ```javascript
191
- // Retrieval-Augmented Generation in 3 lines
192
- await brain.add(companyDocs) // Add your knowledge base
193
- const relevant = await brain.search(userQuery, 10) // Find relevant context
194
- const answer = await llm.generate(relevant + userQuery) // Generate with context
195
91
  ```
196
92
 
197
- ### 🔍 **Semantic Search** - That Just Works
93
+ ### `find()` - Natural Language Queries
198
94
  ```javascript
199
- // No embeddings API needed - it's built in!
200
- await brain.add("The iPhone 15 Pro has a titanium design")
201
- await brain.add("Samsung Galaxy S24 features AI photography")
202
-
203
- const results = await brain.search("smartphones with metal build")
204
- // Returns: iPhone (titanium matches "metal build" semantically)
95
+ // Simple natural language
96
+ const results = await brain.find("recent important documents")
97
+
98
+ // Structured query with Triple Intelligence
99
+ const results = await brain.find({
100
+ like: "JavaScript", // Vector similarity
101
+ where: { // Metadata filters
102
+ year: { greaterThan: 2020 },
103
+ important: true
104
+ },
105
+ related: { to: "React" } // Graph relationships
106
+ })
205
107
  ```
206
108
 
207
- ### 🎯 **Recommendation Engines** - With Graph Intelligence
109
+ ### CRUD Operations
208
110
  ```javascript
209
- // Netflix-style recommendations with 1.0 unified API
210
- import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'
111
+ // Create
112
+ const id = await brain.addNoun(data, metadata)
211
113
 
212
- const brain = new BrainyData()
213
- await brain.init()
114
+ // Read
115
+ const item = await brain.getNoun(id)
214
116
 
215
- // Create entities and relationships
216
- const userId = await brain.addNoun("User123", NounType.Person)
217
- const movieId = await brain.addNoun("Inception", NounType.Content)
117
+ // Update
118
+ await brain.updateNoun(id, newData, newMetadata)
218
119
 
219
- // Track user behavior with metadata
220
- await brain.addVerb(userId, movieId, VerbType.InteractedWith, {
221
- action: "watched",
222
- rating: 5,
223
- timestamp: new Date(),
224
- genre: "sci-fi"
225
- })
120
+ // Delete
121
+ await brain.deleteNoun(id)
226
122
 
227
- // Get intelligent recommendations based on relationships
228
- const recommendations = await brain.getNounWithVerbs(userId, {
229
- verbTypes: [VerbType.InteractedWith],
230
- depth: 2
231
- })
232
- // Returns: Similar movies based on rating patterns and genre preferences
123
+ // Bulk operations
124
+ await brain.import(arrayOfData)
125
+ const exported = await brain.export({ format: 'json' })
233
126
  ```
234
127
 
235
- ### 🤖 **Multi-Agent AI Systems** - With Shared Memory
128
+ ## 🎯 Use Cases
129
+
130
+ ### Knowledge Management
236
131
  ```javascript
237
- // Multiple AI agents sharing the same brain
238
- const sharedBrain = new BrainyData({ instance: 'multi-agent-brain' })
239
- await sharedBrain.init()
240
-
241
- // Sales Agent adds customer intelligence
242
- const customerId = await sharedBrain.addNoun("Acme Corp", NounType.Organization)
243
- await sharedBrain.addVerb(customerId, "business-plan", VerbType.InterestedIn, {
244
- priority: "high",
245
- timeline: "Q2 2025"
132
+ // Store and search documentation
133
+ await brain.addNoun(documentContent, {
134
+ title: "API Guide",
135
+ category: "documentation",
136
+ version: "2.0"
246
137
  })
247
138
 
248
- // Support Agent instantly sees the context
249
- const customerData = await sharedBrain.getNounWithVerbs(customerId)
250
- // Support knows: customer interested in business plan
251
-
252
- // Marketing Agent learns from both
253
- const insights = await sharedBrain.search("business customers Q2", 10)
254
- // Marketing can create targeted campaigns for similar prospects
139
+ const docs = await brain.find("API documentation for version 2")
255
140
  ```
256
141
 
257
- ### 🏥 **Customer Support Bots** - With Perfect Memory
142
+ ### Semantic Search
258
143
  ```javascript
259
- // Support bot that remembers every interaction
260
- const customerId = await brain.addNoun("Customer_456", NounType.Person)
261
-
262
- // Track support history with rich metadata
263
- await brain.addVerb(customerId, "password-reset", VerbType.RequestedHelp, {
264
- issue: "Password reset",
265
- resolved: true,
266
- date: "2025-01-10",
267
- satisfaction: 5,
268
- agent: "Sarah"
144
+ // Find similar content
145
+ const similar = await brain.search(existingContent, {
146
+ limit: 5,
147
+ threshold: 0.8
269
148
  })
270
-
271
- // Next conversation - bot instantly knows history
272
- const history = await brain.getNounWithVerbs(customerId)
273
- // Bot: "I see you had a password issue last week. Everything working smoothly now?"
274
-
275
- // Proactive insights
276
- const commonIssues = await brain.search("password reset common issues", 5)
277
- // Bot offers preventive tips before problems occur
278
- ```
279
-
280
- ### ❌ **The Old Way: Database Frankenstein**
281
- ```
282
- Pinecone ($750/mo) + Neo4j ($500/mo) + Elasticsearch ($300/mo) +
283
- Sync nightmares + 3 different APIs + Vendor lock-in = 😱💸
284
- ```
285
-
286
- ### ✅ **The Brainy Way: One Brain, All Dimensions**
287
- ```
288
- Vector + Graph + Search + AI = Brainy (Free & Open Source) = 🧠✨
289
- ```
290
-
291
- **Your data gets superpowers. Your wallet stays happy.**
292
-
293
-
294
- ## ⚡ Quick Start (60 Seconds)
295
-
296
- ### Open Source (Local Storage)
297
- ```bash
298
- npm install @soulcraft/brainy
299
149
  ```
300
150
 
151
+ ### AI Memory Layer
301
152
  ```javascript
302
- import { BrainyData } from '@soulcraft/brainy'
303
-
304
- // Zero configuration - it just works!
305
- const brain = new BrainyData()
306
- await brain.init()
307
-
308
- // Add any data - text, objects, relationships
309
- await brain.add("Satya Nadella became CEO of Microsoft in 2014")
310
- await brain.add({ company: "Anthropic", ceo: "Dario Amodei", founded: 2021 })
311
- await brain.addVerb("Sundar Pichai", "leads", "Google")
153
+ // Store conversation context
154
+ await brain.addNoun(userMessage, {
155
+ userId: "123",
156
+ timestamp: Date.now(),
157
+ session: "abc"
158
+ })
312
159
 
313
- // Search naturally
314
- const results = await brain.search("tech companies and their leaders")
160
+ // Retrieve relevant context
161
+ const context = await brain.find(`previous conversations with user 123`)
315
162
  ```
316
163
 
317
- ### ☁️ Brain Cloud (AI Memory + Agent Coordination)
318
- ```bash
319
- # Auto-setup with cloud instance provisioning (RECOMMENDED)
320
- brainy cloud setup --email your@email.com
164
+ ## 💾 Storage Options
321
165
 
322
- # Sign up at app.soulcraft.com (free trial)
323
- brainy cloud auth # Auto-configures based on your plan
324
- ```
166
+ Brainy supports multiple storage backends:
325
167
 
326
168
  ```javascript
327
- import { BrainyData, Cortex } from '@soulcraft/brainy'
328
- // After authentication, augmentations auto-load
329
- // No imports needed - they're managed by your account!
330
-
331
- const brain = new BrainyData()
332
- const cortex = new Cortex()
333
-
334
- // Add augmentations to extend functionality
335
- brain.register(new CustomAugmentation())
169
+ // Memory (default for testing)
170
+ const brain = new BrainyData({
171
+ storage: { type: 'memory' }
172
+ })
336
173
 
337
- // Now your AI remembers everything across all sessions!
338
- await brain.add("User prefers TypeScript over JavaScript")
339
- // This memory persists and syncs across all devices
340
- // Returns: Microsoft and Anthropic with relevance scores
174
+ // FileSystem (Node.js)
175
+ const brain = new BrainyData({
176
+ storage: {
177
+ type: 'filesystem',
178
+ path: './data'
179
+ }
180
+ })
341
181
 
342
- // Query relationships
343
- const companies = await brain.getRelated("Sundar Pichai", { verb: "leads" })
344
- // Returns: Google, Alphabet
182
+ // Browser Storage (OPFS)
183
+ const brain = new BrainyData({
184
+ storage: { type: 'opfs' }
185
+ })
345
186
 
346
- // Filter with metadata
347
- const recent = await brain.search("companies", 10, {
348
- filter: { founded: { $gte: 2000 } }
187
+ // S3 Compatible (Production)
188
+ const brain = new BrainyData({
189
+ storage: {
190
+ type: 's3',
191
+ bucket: 'my-bucket',
192
+ region: 'us-east-1'
193
+ }
349
194
  })
350
195
  ```
351
196
 
352
- ## 🧩 Augmentation System - Extend Your Brain
197
+ ## 🛠️ CLI
353
198
 
354
- Brainy is **100% open source** with a powerful augmentation system. Choose what you need:
199
+ Brainy includes a powerful CLI for testing and management:
355
200
 
356
- ### 🆓 **Built-in Augmentations** (Always Free)
357
- ```javascript
358
- import { NeuralImport } from '@soulcraft/brainy'
201
+ ```bash
202
+ # Install globally
203
+ npm install -g brainy
359
204
 
360
- // AI-powered data understanding - included in every install
361
- const neural = new NeuralImport(brain)
362
- await neural.neuralImport('data.csv') // Automatically extracts entities & relationships
363
- ```
205
+ # Add data
206
+ brainy add "JavaScript is awesome" --metadata '{"type":"opinion"}'
364
207
 
365
- **Included augmentations:**
366
- - **Neural Import** - AI understands your data structure
367
- - ✅ **Basic Memory** - Persistent storage
368
- - ✅ **Simple Search** - Text and vector search
369
- - ✅ **Graph Traversal** - Relationship queries
208
+ # Search
209
+ brainy search "programming"
370
210
 
371
- ### 🌟 **Community Augmentations** (Coming Soon!)
372
- ```javascript
373
- // 🚧 FUTURE: Community augmentations will be available soon!
374
- // These are examples of what the community could build:
211
+ # Natural language find
212
+ brainy find "awesome programming languages"
375
213
 
376
- // Example: Sentiment Analysis (not yet available)
377
- // npm install brainy-sentiment
378
- // brain.register(new SentimentAnalyzer())
214
+ # Interactive mode
215
+ brainy chat
379
216
 
380
- // Example: Translation (not yet available)
381
- // npm install brainy-translate
382
- // brain.register(new Translator())
217
+ # Export data
218
+ brainy export --format json > backup.json
383
219
  ```
384
220
 
385
- **Ideas for Community Augmentations:**
386
- *Want to build one of these? We'll help promote it!*
387
- - 🎭 Sentiment Analysis - Analyze emotional tone
388
- - 🌍 Translation - Multi-language support
389
- - 📧 Email Parser - Extract structured data from emails
390
- - 🔗 URL Extractor - Find and validate URLs
391
- - 📊 Data Visualizer - Generate charts from data
392
- - 🎨 Image Understanding - Analyze image content
393
-
394
- **Be the First!** Create an augmentation and we'll feature it here.
395
- [See how to build augmentations →](UNIFIED-API.md#creating-your-own-augmentation)
396
-
397
- ### ☁️ **Brain Cloud** - Optional Cloud Services (Early Access) 🎆
398
-
399
- **Currently in Early Access** - Join at [soulcraft.com](https://soulcraft.com)
400
-
401
- **Available Tiers:**
402
-
403
- #### 🆓 **Free Forever** - Local Database
404
- - ✓ Full multi-dimensional database
405
- - ✓ Works offline
406
- - ✓ No API keys required
407
- - ✓ Your data stays private
221
+ ## 🔌 Augmentations
408
222
 
409
- #### ☁️ **Cloud Sync** - $19/month
410
- - ✓ Everything in Free tier
411
- - ✓ Team collaboration
412
- - ✓ Cross-device synchronization
413
- - ✓ Automatic backups
414
- - ✓ Real-time sync
223
+ Extend Brainy with powerful augmentations:
415
224
 
416
- #### 🏢 **Enterprise** - $99/month
417
- - Everything in Cloud Sync
418
- - Dedicated infrastructure
419
- - ✓ Service Level Agreement (SLA)
420
- - ✓ Priority support
421
- - ✓ Custom integrations
225
+ ```bash
226
+ # List available augmentations
227
+ brainy augment list
422
228
 
423
- ```javascript
424
- // Brain Cloud integration (when available):
425
- const brain = new BrainyData({
426
- cloud: {
427
- enabled: true, // Enable cloud sync
428
- apiKey: process.env.BRAIN_CLOUD_KEY // Optional for premium features
429
- }
430
- })
229
+ # Install an augmentation
230
+ brainy augment install explorer
431
231
 
432
- // Works perfectly without cloud too:
433
- const brain = new BrainyData()
434
- await brain.init()
435
- // Full database functionality, locally!
232
+ # Connect to Brain Cloud
233
+ brainy cloud setup
436
234
  ```
437
235
 
236
+ ## 🏢 Enterprise Features - Included for Everyone
438
237
 
439
- ### 🌐 **Why Brain Cloud?**
238
+ Brainy includes enterprise-grade capabilities at no extra cost. **No premium tiers, no paywalls.**
440
239
 
441
- Brain Cloud adds optional cloud services to sustain Brainy's development:
240
+ - **Scales to 10M+ items** with consistent 3ms search latency
241
+ - **Write-Ahead Logging (WAL)** for zero data loss durability
242
+ - **Distributed architecture** with sharding and replication
243
+ - **Read/write separation** for horizontal scaling
244
+ - **Connection pooling** and request deduplication
245
+ - **Built-in monitoring** with metrics and health checks
246
+ - **Production ready** with circuit breakers and backpressure
442
247
 
443
- ```javascript
444
- // Connect to Brain Cloud - your brain in the cloud
445
- await brain.connect('brain-cloud.soulcraft.com', {
446
- instance: 'my-team-brain',
447
- apiKey: process.env.BRAIN_CLOUD_KEY
448
- })
248
+ 📖 **[Read the full Enterprise Features guide →](docs/ENTERPRISE-FEATURES.md)**
449
249
 
450
- // Now your brain persists across:
451
- // - Multiple developers
452
- // - Different environments
453
- // - AI agents
454
- // - Sessions
455
- ```
250
+ ## 📊 Benchmarks
456
251
 
457
- **Brain Cloud features:**
458
- - 🔄 Auto-sync across team
459
- - 💾 Managed backups
460
- - 🚀 Auto-scaling
461
- - 🔒 Enterprise security
462
- - 📊 Analytics dashboard
463
- - 🤖 Multi-agent coordination
464
-
465
- ## 📝 Create Your Own Augmentation
466
-
467
- ### We ❤️ Open Source
468
-
469
- **Brainy will ALWAYS be open source.** We believe in:
470
- - 🌍 Community first
471
- - 🔓 No vendor lock-in
472
- - 🎁 Free forever core
473
- - 🤝 Sustainable open source
474
-
475
- ### Build & Share Your Augmentation
476
-
477
- ```typescript
478
- import { IAugmentation } from '@soulcraft/brainy'
479
-
480
- export class MovieRecommender implements IAugmentation {
481
- name = 'movie-recommender'
482
- type = 'cognition' // sense|conduit|cognition|memory
483
- description = 'AI-powered movie recommendations'
484
- enabled = true
485
-
486
- async processRawData(data: any) {
487
- // Your recommendation logic
488
- const movies = await this.analyzePreferences(data)
489
-
490
- return {
491
- success: true,
492
- data: {
493
- recommendations: movies,
494
- confidence: 0.95
495
- }
496
- }
497
- }
498
- }
499
-
500
- // Register with Brainy
501
- const brain = new BrainyData()
502
- brain.register(new MovieRecommender())
503
- ```
252
+ | Operation | Performance | Memory |
253
+ |-----------|------------|--------|
254
+ | Initialize | 450ms | 24MB |
255
+ | Add Item | 12ms | +0.1MB |
256
+ | Vector Search (1k items) | 3ms | - |
257
+ | Metadata Filter (10k items) | 0.8ms | - |
258
+ | Natural Language Query | 15ms | - |
259
+ | Bulk Import (1000 items) | 2.3s | +8MB |
260
+ | **Production Scale (10M items)** | **5.8ms** | **12GB** |
504
261
 
505
- **Share with the community:**
506
- ```bash
507
- npm publish brainy-movie-recommender
508
- ```
262
+ ## 🔄 Migration from 1.x
509
263
 
510
- **Earn from your creation:**
511
- - 💚 Keep it free (we'll promote it!)
512
- - 💰 Sell licenses (we'll help distribute!)
513
- - 🤝 Join our partner program
514
-
515
- ## 🎯 Real-World Examples
516
-
517
- ### Customer Support Bot with Memory
518
- ```javascript
519
- // Your bot remembers every interaction
520
- await brain.add({
521
- customerId: "user_123",
522
- issue: "Password reset",
523
- resolved: true,
524
- date: new Date()
525
- })
264
+ See [MIGRATION.md](MIGRATION.md) for detailed upgrade instructions.
526
265
 
527
- // Next interaction knows the history
528
- const history = await brain.search(`customer user_123`, 10)
529
- // Bot says: "I see you had a password issue last week. All working now?"
530
- ```
266
+ Key changes:
267
+ - Search methods consolidated into `search()` and `find()`
268
+ - Result format now includes full objects with metadata
269
+ - New natural language capabilities
531
270
 
532
- ### Knowledge Base that Understands Context
533
- ```javascript
534
- // Add your documentation
535
- await brain.add("To deploy Brainy, run npm install @soulcraft/brainy")
536
- await brain.add("Brainy requires Node.js 24.4.1 or higher")
537
- await brain.add("For production, use Brain Cloud for scaling")
538
-
539
- // Natural language queries work
540
- const answer = await brain.search("how do I deploy to production?")
541
- // Returns relevant docs about Brain Cloud and scaling
542
- ```
271
+ ## 🤝 Contributing
543
272
 
544
- ### Multi-Agent AI Systems
545
- ```javascript
546
- // Agents share the same brain
547
- const agentBrain = new BrainyData({ instance: 'shared-brain' })
273
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
548
274
 
549
- // Sales Agent adds knowledge
550
- await agentBrain.add("Customer interested in enterprise plan")
275
+ ## 📖 Documentation
551
276
 
552
- // Support Agent sees it instantly
553
- const context = await agentBrain.search("customer plan interest")
277
+ - [Getting Started Guide](docs/guides/getting-started.md)
278
+ - [API Reference](docs/api/README.md)
279
+ - [Architecture Overview](docs/architecture/overview.md)
280
+ - [Natural Language Guide](docs/guides/natural-language.md)
281
+ - [Triple Intelligence](docs/architecture/triple-intelligence.md)
554
282
 
555
- // Marketing Agent learns from both
556
- const insights = await agentBrain.getRelated("enterprise plan")
557
- ```
283
+ ## 🏢 Enterprise & Cloud
558
284
 
559
- ## 🏗️ Architecture - Unified & Simple
285
+ **Brain Cloud** - Managed Brainy with team sync, persistent memory, and enterprise connectors.
560
286
 
561
- ```
562
- ┌─────────────────────────────────────────────┐
563
- │ 🎯 YOUR APP - One Simple API │
564
- │ brain.add() brain.search() brain.addVerb() │
565
- └─────────────────┬───────────────────────────┘
566
-
567
- ┌─────────────────▼───────────────────────────┐
568
- │ 🧠 BRAINY 1.0 - THE UNIFIED BRAIN │
569
- │ │
570
- │ ┌─────────────┐ ┌─────────────┐ ┌────────┐ │
571
- │ │ Vector │ │ Graph │ │ Facets │ │
572
- │ │ Search │ │Relationships│ │Metadata│ │
573
- │ └─────────────┘ └─────────────┘ └────────┘ │
574
- │ │
575
- │ ┌─────────────┐ ┌─────────────┐ ┌────────┐ │
576
- │ │ Encryption │ │ Memory │ │ Cache │ │
577
- │ │ Universal │ │ Management │ │ 3-Tier │ │
578
- │ └─────────────┘ └─────────────┘ └────────┘ │
579
- └─────────────────┬───────────────────────────┘
580
-
581
- ┌─────────────────▼───────────────────────────┐
582
- │ 💾 STORAGE - Universal Adapters │
583
- │ Memory • FileSystem • S3 • OPFS • Custom │
584
- └─────────────────────────────────────────────┘
287
+ ```bash
288
+ # Get started with free trial
289
+ brainy cloud setup
585
290
  ```
586
291
 
587
- ### **What Makes 1.0 Different:**
588
- - **🎯 One API**: 9 methods handle everything (was 40+ methods)
589
- - **🧠 Smart Core**: Automatic data understanding and processing
590
- - **🔗 Graph Built-in**: Relationships are first-class citizens
591
- - **🔐 Security Native**: Encryption integrated, not bolted-on
592
- - **🧩 Extensible**: Augment with custom capabilities
593
- - **📤 Portable**: Export in any format (json, csv, graph)
594
- - **⚡ Zero Config**: Works perfectly out of the box
595
-
596
- ### **The Magic:**
597
- 1. **You call** `brain.add("complex data")`
598
- 2. **Brainy understands** → detects type, extracts meaning
599
- 3. **Brainy stores** → vector + graph + metadata simultaneously
600
- 4. **Brainy optimizes** → indexes, caches, tunes performance
601
- 5. **You get superpowers** → semantic search + graph traversal + more
602
-
603
- ## 💡 Core Features
604
-
605
- ### 🔍 Multi-Dimensional Search
606
- - **Vector**: Semantic similarity (meaning-based)
607
- - **Graph**: Relationship traversal (connection-based)
608
- - **Faceted**: Metadata filtering (property-based)
609
- - **Hybrid**: All combined (maximum power)
610
-
611
- ### ⚡ Performance - Production Ready
612
- - **Speed**: 100,000+ ops/second (faster with 1.0 optimizations)
613
- - **Scale**: Millions of entities + relationships
614
- - **Memory**: ~100MB for 1M vectors (16% smaller than 0.x)
615
- - **Latency**: <10ms searches with 3-tier caching
616
- - **Intelligence**: Auto-tuning learns from your usage patterns
617
-
618
- ### 🔒 Production Ready
619
- - **Encryption**: End-to-end available
620
- - **Persistence**: Multiple storage backends
621
- - **Reliability**: 99.9% uptime in production
622
- - **Security**: SOC2 compliant architecture
623
-
624
- ## 📚 Documentation
625
-
626
- ### Getting Started
627
- - [**Quick Start Guide**](docs/getting-started/quick-start.md) - Get up and running in 60 seconds
628
- - [**Installation**](docs/getting-started/installation.md) - Detailed installation instructions
629
- - [**Architecture Overview**](PHILOSOPHY.md) - Design principles and philosophy
630
-
631
- ### Core Documentation
632
- - [**API Reference**](docs/api/BRAINY-API-REFERENCE.md) - Complete API documentation
633
- - [**Augmentation Guide**](docs/augmentations/README.md) - Build your own augmentations
634
- - [**CLI Reference**](docs/brainy-cli.md) - Command-line interface
635
- - [**All Documentation**](docs/README.md) - Browse all docs
636
-
637
- ### Guides
638
- - [**Search & Metadata**](docs/user-guides/SEARCH_AND_METADATA_GUIDE.md) - Advanced search
639
- - [**Performance Optimization**](docs/optimization-guides/large-scale-optimizations.md) - Scale Brainy
640
- - [**Production Deployment**](docs/deployment/DEPLOYMENT-GUIDE.md) - Deploy to production
641
- - [**Contributing Guidelines**](CONTRIBUTING.md) - Join the community
642
-
643
- ## 🤝 Our Promise to the Community
644
-
645
- 1. **Brainy core will ALWAYS be open source** (MIT License)
646
- 2. **No feature will ever move from free to paid**
647
- 3. **Community augmentations always welcome**
648
- 4. **We'll actively promote community creators**
649
- 5. **Commercial success funds open source development**
650
-
651
- ## 🙏 Join the Movement
652
-
653
- ### Ways to Contribute
654
- - 🐛 Report bugs
655
- - 💡 Suggest features
656
- - 🔧 Submit PRs
657
- - 📦 Create augmentations
658
- - 📖 Improve docs
659
- - ⭐ Star the repo
660
- - 📢 Spread the word
661
-
662
- ### Get Help & Connect
663
- - 📧 [Email Support](mailto:support@soulcraft.com)
664
- - 🐛 [GitHub Issues](https://github.com/soulcraftlabs/brainy/issues)
665
- - 💬 [GitHub Discussions](https://github.com/soulcraftlabs/brainy/discussions)
666
-
667
- ## 📈 Who's Using Brainy?
668
-
669
- - 🚀 **Startups**: Building AI-first products
670
- - 🏢 **Enterprises**: Replacing expensive databases
671
- - 🎓 **Researchers**: Exploring knowledge graphs
672
- - 👨‍💻 **Developers**: Creating smart applications
673
- - 🤖 **AI Engineers**: Building RAG systems
292
+ Visit [soulcraft.com](https://soulcraft.com) for more information.
674
293
 
675
294
  ## 📄 License
676
295
 
677
- **MIT License** - Use it anywhere, build anything!
678
-
679
- Premium augmentations available at [soulcraft.com](https://soulcraft.com)
296
+ MIT © Brainy Contributors
680
297
 
681
298
  ---
682
299
 
683
- <div align="center">
684
-
685
- ### 🧠⚛️ **Give Your Data a Brain Upgrade**
686
-
687
- **[Get Started](docs/getting-started/quick-start-1.0.md)** •
688
- **[Examples](examples/)** •
689
- **[API Docs](UNIFIED-API.md)** •
690
- **[GitHub](https://github.com/soulcraftlabs/brainy)**
691
-
692
- ⭐ **Star us on GitHub to support open source AI!** ⭐
693
-
694
- *Created and maintained by [SoulCraft](https://soulcraft.com) • Powered by our amazing open source community*
695
-
696
- **SoulCraft** builds and maintains Brainy as open source (MIT License) because we believe AI infrastructure should be accessible to everyone.
697
-
698
- </div>
300
+ <p align="center">
301
+ <strong>Built with ❤️ by the Brainy community</strong><br>
302
+ <em>Zero-Configuration AI Database with Triple Intelligence™</em>
303
+ </p>