@soulcraft/brainy 2.15.0 β†’ 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +249 -152
  3. package/dist/api/ConfigAPI.d.ts +67 -0
  4. package/dist/api/ConfigAPI.js +166 -0
  5. package/dist/api/DataAPI.d.ts +123 -0
  6. package/dist/api/DataAPI.js +391 -0
  7. package/dist/api/SecurityAPI.d.ts +50 -0
  8. package/dist/api/SecurityAPI.js +139 -0
  9. package/dist/api/UniversalImportAPI.d.ts +134 -0
  10. package/dist/api/UniversalImportAPI.js +615 -0
  11. package/dist/augmentationManager.js +12 -7
  12. package/dist/augmentationPipeline.d.ts +0 -61
  13. package/dist/augmentationPipeline.js +0 -87
  14. package/dist/augmentationRegistry.d.ts +1 -1
  15. package/dist/augmentationRegistry.js +1 -1
  16. package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
  17. package/dist/augmentations/apiServerAugmentation.js +288 -7
  18. package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
  19. package/dist/augmentations/auditLogAugmentation.js +358 -0
  20. package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
  21. package/dist/augmentations/batchProcessingAugmentation.js +123 -22
  22. package/dist/augmentations/brainyAugmentation.d.ts +87 -8
  23. package/dist/augmentations/brainyAugmentation.js +159 -2
  24. package/dist/augmentations/cacheAugmentation.d.ts +6 -5
  25. package/dist/augmentations/cacheAugmentation.js +113 -17
  26. package/dist/augmentations/conduitAugmentations.d.ts +2 -2
  27. package/dist/augmentations/conduitAugmentations.js +2 -2
  28. package/dist/augmentations/configResolver.d.ts +122 -0
  29. package/dist/augmentations/configResolver.js +440 -0
  30. package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
  31. package/dist/augmentations/connectionPoolAugmentation.js +37 -12
  32. package/dist/augmentations/defaultAugmentations.d.ts +9 -11
  33. package/dist/augmentations/defaultAugmentations.js +4 -11
  34. package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
  35. package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
  36. package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
  37. package/dist/augmentations/discovery/localDiscovery.js +246 -0
  38. package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
  39. package/dist/augmentations/discovery/runtimeLoader.js +337 -0
  40. package/dist/augmentations/discovery.d.ts +152 -0
  41. package/dist/augmentations/discovery.js +441 -0
  42. package/dist/augmentations/display/intelligentComputation.d.ts +1 -1
  43. package/dist/augmentations/display/intelligentComputation.js +4 -4
  44. package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
  45. package/dist/augmentations/entityRegistryAugmentation.js +5 -1
  46. package/dist/augmentations/indexAugmentation.d.ts +3 -3
  47. package/dist/augmentations/indexAugmentation.js +2 -2
  48. package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +22 -6
  49. package/dist/augmentations/intelligentVerbScoringAugmentation.js +106 -23
  50. package/dist/augmentations/manifest.d.ts +176 -0
  51. package/dist/augmentations/manifest.js +8 -0
  52. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
  53. package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
  54. package/dist/augmentations/marketplace/cli.d.ts +47 -0
  55. package/dist/augmentations/marketplace/cli.js +265 -0
  56. package/dist/augmentations/metricsAugmentation.d.ts +3 -3
  57. package/dist/augmentations/metricsAugmentation.js +2 -2
  58. package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
  59. package/dist/augmentations/monitoringAugmentation.js +2 -2
  60. package/dist/augmentations/neuralImport.d.ts +1 -1
  61. package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
  62. package/dist/augmentations/rateLimitAugmentation.js +321 -0
  63. package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
  64. package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
  65. package/dist/augmentations/storageAugmentation.d.ts +1 -1
  66. package/dist/augmentations/storageAugmentation.js +2 -2
  67. package/dist/augmentations/storageAugmentations.d.ts +37 -8
  68. package/dist/augmentations/storageAugmentations.js +204 -15
  69. package/dist/augmentations/synapseAugmentation.d.ts +1 -1
  70. package/dist/augmentations/synapseAugmentation.js +35 -16
  71. package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
  72. package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
  73. package/dist/augmentations/universalDisplayAugmentation.d.ts +2 -2
  74. package/dist/augmentations/universalDisplayAugmentation.js +2 -2
  75. package/dist/brainy-unified.d.ts +106 -0
  76. package/dist/brainy-unified.js +327 -0
  77. package/dist/brainy.d.ts +273 -0
  78. package/dist/brainy.js +1181 -0
  79. package/dist/brainyData.d.ts +29 -72
  80. package/dist/brainyData.js +350 -304
  81. package/dist/brainyDataV3.d.ts +186 -0
  82. package/dist/brainyDataV3.js +337 -0
  83. package/dist/browserFramework.d.ts +6 -6
  84. package/dist/browserFramework.js +11 -8
  85. package/dist/browserFramework.minimal.d.ts +5 -5
  86. package/dist/browserFramework.minimal.js +11 -8
  87. package/dist/config/index.d.ts +2 -2
  88. package/dist/config/index.js +3 -3
  89. package/dist/config/modelAutoConfig.d.ts +6 -7
  90. package/dist/config/modelAutoConfig.js +17 -76
  91. package/dist/cortex/backupRestore.d.ts +2 -2
  92. package/dist/cortex/backupRestore.js +85 -27
  93. package/dist/cortex/healthCheck.d.ts +2 -2
  94. package/dist/cortex/neuralImport.d.ts +2 -2
  95. package/dist/cortex/neuralImport.js +18 -13
  96. package/dist/cortex/performanceMonitor.d.ts +2 -2
  97. package/dist/critical/model-guardian.d.ts +4 -0
  98. package/dist/critical/model-guardian.js +31 -11
  99. package/dist/demo.d.ts +4 -4
  100. package/dist/demo.js +7 -7
  101. package/dist/distributed/cacheSync.d.ts +112 -0
  102. package/dist/distributed/cacheSync.js +265 -0
  103. package/dist/distributed/coordinator.d.ts +193 -0
  104. package/dist/distributed/coordinator.js +548 -0
  105. package/dist/distributed/httpTransport.d.ts +120 -0
  106. package/dist/distributed/httpTransport.js +446 -0
  107. package/dist/distributed/index.d.ts +8 -0
  108. package/dist/distributed/index.js +5 -0
  109. package/dist/distributed/networkTransport.d.ts +132 -0
  110. package/dist/distributed/networkTransport.js +633 -0
  111. package/dist/distributed/queryPlanner.d.ts +104 -0
  112. package/dist/distributed/queryPlanner.js +327 -0
  113. package/dist/distributed/readWriteSeparation.d.ts +134 -0
  114. package/dist/distributed/readWriteSeparation.js +350 -0
  115. package/dist/distributed/shardManager.d.ts +114 -0
  116. package/dist/distributed/shardManager.js +357 -0
  117. package/dist/distributed/shardMigration.d.ts +110 -0
  118. package/dist/distributed/shardMigration.js +289 -0
  119. package/dist/distributed/storageDiscovery.d.ts +160 -0
  120. package/dist/distributed/storageDiscovery.js +551 -0
  121. package/dist/embeddings/EmbeddingManager.d.ts +0 -4
  122. package/dist/embeddings/EmbeddingManager.js +21 -26
  123. package/dist/errors/brainyError.d.ts +5 -1
  124. package/dist/errors/brainyError.js +12 -0
  125. package/dist/examples/basicUsage.js +3 -3
  126. package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
  127. package/dist/graph/graphAdjacencyIndex.js +288 -0
  128. package/dist/graph/pathfinding.js +4 -2
  129. package/dist/hnsw/scaledHNSWSystem.js +11 -2
  130. package/dist/importManager.js +6 -3
  131. package/dist/index.d.ts +12 -21
  132. package/dist/index.js +14 -22
  133. package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
  134. package/dist/mcp/brainyMCPAdapter.js +5 -5
  135. package/dist/mcp/brainyMCPService.d.ts +3 -3
  136. package/dist/mcp/brainyMCPService.js +3 -11
  137. package/dist/mcp/mcpAugmentationToolset.js +20 -30
  138. package/dist/neural/embeddedPatterns.d.ts +1 -1
  139. package/dist/neural/embeddedPatterns.js +2 -2
  140. package/dist/neural/entityExtractor.d.ts +65 -0
  141. package/dist/neural/entityExtractor.js +316 -0
  142. package/dist/neural/improvedNeuralAPI.js +90 -79
  143. package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
  144. package/dist/neural/naturalLanguageProcessor.js +941 -66
  145. package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
  146. package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
  147. package/dist/neural/neuralAPI.js +8 -2
  148. package/dist/neural/patternLibrary.d.ts +57 -3
  149. package/dist/neural/patternLibrary.js +348 -13
  150. package/dist/neural/staticPatternMatcher.d.ts +2 -2
  151. package/dist/neural/staticPatternMatcher.js +2 -2
  152. package/dist/shared/default-augmentations.d.ts +3 -3
  153. package/dist/shared/default-augmentations.js +5 -5
  154. package/dist/storage/adapters/fileSystemStorage.d.ts +4 -0
  155. package/dist/storage/adapters/fileSystemStorage.js +54 -1
  156. package/dist/storage/adapters/memoryStorage.js +13 -8
  157. package/dist/storage/backwardCompatibility.d.ts +10 -78
  158. package/dist/storage/backwardCompatibility.js +17 -132
  159. package/dist/storage/baseStorage.d.ts +6 -0
  160. package/dist/storage/baseStorage.js +17 -0
  161. package/dist/storage/cacheManager.js +2 -2
  162. package/dist/storage/readOnlyOptimizations.js +8 -3
  163. package/dist/streaming/pipeline.d.ts +154 -0
  164. package/dist/streaming/pipeline.js +551 -0
  165. package/dist/triple/TripleIntelligence.d.ts +25 -110
  166. package/dist/triple/TripleIntelligence.js +4 -574
  167. package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
  168. package/dist/triple/TripleIntelligenceSystem.js +519 -0
  169. package/dist/types/apiTypes.d.ts +278 -0
  170. package/dist/types/apiTypes.js +33 -0
  171. package/dist/types/brainy.types.d.ts +308 -0
  172. package/dist/types/brainy.types.js +8 -0
  173. package/dist/types/brainyDataInterface.d.ts +3 -3
  174. package/dist/types/brainyDataInterface.js +2 -2
  175. package/dist/types/graphTypes.js +2 -2
  176. package/dist/utils/cacheAutoConfig.d.ts +3 -3
  177. package/dist/utils/embedding.js +8 -14
  178. package/dist/utils/enhancedLogger.d.ts +104 -0
  179. package/dist/utils/enhancedLogger.js +232 -0
  180. package/dist/utils/index.d.ts +1 -1
  181. package/dist/utils/index.js +1 -1
  182. package/dist/utils/intelligentTypeMapper.d.ts +60 -0
  183. package/dist/utils/intelligentTypeMapper.js +349 -0
  184. package/dist/utils/metadataIndex.d.ts +118 -1
  185. package/dist/utils/metadataIndex.js +539 -16
  186. package/dist/utils/paramValidation.d.ts +39 -0
  187. package/dist/utils/paramValidation.js +192 -0
  188. package/dist/utils/rateLimiter.d.ts +160 -0
  189. package/dist/utils/rateLimiter.js +271 -0
  190. package/dist/utils/statistics.d.ts +4 -4
  191. package/dist/utils/statistics.js +3 -3
  192. package/dist/utils/structuredLogger.d.ts +146 -0
  193. package/dist/utils/structuredLogger.js +394 -0
  194. package/dist/utils/textEncoding.js +2 -1
  195. package/dist/utils/typeValidation.d.ts +34 -0
  196. package/dist/utils/typeValidation.js +247 -0
  197. package/package.json +14 -6
  198. package/scripts/download-models.cjs +6 -15
  199. package/dist/augmentations/walAugmentation.d.ts +0 -111
  200. package/dist/augmentations/walAugmentation.js +0 -519
  201. package/dist/chat/BrainyChat.d.ts +0 -121
  202. package/dist/chat/BrainyChat.js +0 -396
  203. package/dist/chat/ChatCLI.d.ts +0 -61
  204. package/dist/chat/ChatCLI.js +0 -351
package/README.md CHANGED
@@ -9,25 +9,36 @@
9
9
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
10
  [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/)
11
11
 
12
- **🧠 Brainy 2.0 - The Universal Knowledge Protocolβ„’**
12
+ **🧠 Brainy 3.0 - Universal Knowledge Protocolβ„’**
13
13
 
14
- **World's first Triple Intelligenceβ„’ database**β€”unifying vector similarity, graph relationships, and document filtering in one magical API. Model ANY data from ANY domain using 31 standardized noun types Γ— 40 verb types.
14
+ **World's first Triple Intelligenceβ„’ database** unifying vector similarity, graph relationships, and document filtering in one magical API. Model ANY data from ANY domain using 31 standardized noun types Γ— 40 verb types.
15
15
 
16
16
  **Why Brainy Leads**: We're the first to solve the impossibleβ€”combining three different database paradigms (vector, graph, document) into one unified query interface. This breakthrough enables us to be the Universal Knowledge Protocol where all tools, augmentations, and AI models speak the same language.
17
17
 
18
- **Build once, integrate everywhere.** O(log n) performance, 3ms search latency, 24MB memory footprint.
18
+ **Build once, integrate everywhere.** O(log n) performance, <10ms search latency, production-ready.
19
19
 
20
- ## πŸŽ‰ What's New in 2.0
20
+ ## πŸŽ‰ What's New in 3.0
21
21
 
22
- - **World's First Triple Intelligenceβ„’**: Unified vector + graph + document in ONE query
23
- - **Universal Knowledge Protocol**: 31 nouns Γ— 40 verbs standardize all knowledge
24
- - **Infinite Expressiveness**: Model ANY data with unlimited metadata
25
- - **API Consolidation**: 15+ methods β†’ 2 clean APIs (`search()` and `find()`)
26
- - **Natural Language**: Ask questions in plain English
27
- - **Zero Configuration**: Works instantly, no setup required
28
- - **O(log n) Performance**: Binary search on sorted indices
29
- - **Perfect Interoperability**: All tools and AI models speak the same language
30
- - **Universal Compatibility**: Node.js, Browser, Edge, Workers
22
+ ### 🧠 **Triple Intelligenceβ„’ Engine**
23
+
24
+ - **Vector Search**: HNSW-powered semantic similarity
25
+ - **Graph Relationships**: Navigate connected knowledge
26
+ - **Document Filtering**: MongoDB-style metadata queries
27
+ - **Unified API**: All three in a single query interface
28
+
29
+ ### 🎯 **Clean API Design**
30
+
31
+ - **Modern Syntax**: `brain.add()`, `brain.find()`, `brain.relate()`
32
+ - **Type Safety**: Full TypeScript integration
33
+ - **Zero Config**: Works out of the box with memory storage
34
+ - **Consistent Parameters**: Clean, predictable API surface
35
+
36
+ ### ⚑ **Performance & Reliability**
37
+
38
+ - **<10ms Search**: Fast semantic queries
39
+ - **384D Vectors**: Optimized embeddings (all-MiniLM-L6-v2)
40
+ - **Built-in Caching**: Intelligent result caching
41
+ - **Production Ready**: Thoroughly tested core functionality
31
42
 
32
43
  ## ⚑ Quick Start - Zero Configuration
33
44
 
@@ -36,40 +47,54 @@ npm install @soulcraft/brainy
36
47
  ```
37
48
 
38
49
  ### 🎯 **True Zero Configuration**
50
+
39
51
  ```javascript
40
- import { BrainyData } from '@soulcraft/brainy'
52
+ import {Brainy} from '@soulcraft/brainy'
41
53
 
42
54
  // Just this - auto-detects everything!
43
- const brain = new BrainyData()
55
+ const brain = new Brainy()
44
56
  await brain.init()
45
57
 
46
- // Add entities (nouns) with automatic embedding
47
- const jsId = await brain.addNoun("JavaScript is a programming language", 'concept', {
48
- type: "language",
49
- year: 1995,
50
- paradigm: "multi-paradigm"
58
+ // Add entities with automatic embedding
59
+ const jsId = await brain.add({
60
+ data: "JavaScript is a programming language",
61
+ type: "concept",
62
+ metadata: {
63
+ type: "language",
64
+ year: 1995,
65
+ paradigm: "multi-paradigm"
66
+ }
51
67
  })
52
68
 
53
- const nodeId = await brain.addNoun("Node.js runtime environment", 'concept', {
54
- type: "runtime",
55
- year: 2009,
56
- platform: "server-side"
69
+ const nodeId = await brain.add({
70
+ data: "Node.js runtime environment",
71
+ type: "concept",
72
+ metadata: {
73
+ type: "runtime",
74
+ year: 2009,
75
+ platform: "server-side"
76
+ }
57
77
  })
58
78
 
59
- // Create relationships (verbs) between entities
60
- await brain.addVerb(nodeId, jsId, "executes", {
61
- since: 2009,
62
- performance: "high"
79
+ // Create relationships between entities
80
+ await brain.relate({
81
+ from: nodeId,
82
+ to: jsId,
83
+ type: "executes",
84
+ metadata: {
85
+ since: 2009,
86
+ performance: "high"
87
+ }
63
88
  })
64
89
 
65
90
  // Natural language search with graph relationships
66
- const results = await brain.find("programming languages used by server runtimes")
91
+ const results = await brain.find({query: "programming languages used by server runtimes"})
67
92
 
68
93
  // Triple Intelligence: vector + metadata + relationships
69
94
  const filtered = await brain.find({
70
- like: "JavaScript", // Vector similarity
71
- where: { type: "language" }, // Metadata filtering
72
- connected: { from: nodeId, depth: 1 } // Graph relationships
95
+ query: "JavaScript", // Vector similarity
96
+ where: {type: "language"}, // Metadata filtering
97
+ connected: {from: nodeId, depth: 1} // Graph relationships
73
98
  })
74
99
  ```
75
100
 
@@ -81,14 +106,17 @@ const filtered = await brain.find({
81
106
  - βœ… **Node.js 20 LTS** - Compatible (maintenance mode)
82
107
  - ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
83
108
 
84
- > **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
109
+ > **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause
110
+ > crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
85
111
 
86
112
  If using nvm: `nvm use` (we provide a `.nvmrc` file)
87
113
 
88
114
  ## πŸš€ Key Features
89
115
 
90
116
  ### World's First Triple Intelligenceβ„’ Engine
117
+
91
118
  **The breakthrough that enables the Universal Knowledge Protocol:**
119
+
92
120
  - **Vector Search**: Semantic similarity with HNSW indexing
93
121
  - **Graph Relationships**: Navigate connected knowledge like Neo4j
94
122
  - **Document Filtering**: MongoDB-style queries with O(log n) performance
@@ -96,7 +124,9 @@ If using nvm: `nvm use` (we provide a `.nvmrc` file)
96
124
  - **First to solve this**: Others do vector OR graph OR documentβ€”we do ALL
97
125
 
98
126
  ### Universal Knowledge Protocol with Infinite Expressiveness
127
+
99
128
  **Enabled by Triple Intelligence, standardized for everyone:**
129
+
100
130
  - **24 Noun Types Γ— 40 Verb Types**: 960 base combinations
101
131
  - **∞ Expressiveness**: Unlimited metadata = model ANY data
102
132
  - **One Language**: All tools, augmentations, AI models speak the same types
@@ -104,6 +134,7 @@ If using nvm: `nvm use` (we provide a `.nvmrc` file)
104
134
  - **No Schema Lock-in**: Evolve without migrations
105
135
 
106
136
  ### Natural Language Understanding
137
+
107
138
  ```javascript
108
139
  // Ask questions naturally
109
140
  await brain.find("Show me recent React components with tests")
@@ -112,42 +143,41 @@ await brain.find("Documentation about authentication from last month")
112
143
  ```
113
144
 
114
145
  ### 🎯 Zero Configuration Philosophy
115
- Brainy 2.9+ automatically configures **everything**:
146
+
147
+ Brainy 3.0 automatically configures **everything**:
116
148
 
117
149
  ```javascript
118
- import { BrainyData, PresetName } from '@soulcraft/brainy'
150
+ import {Brainy} from '@soulcraft/brainy'
119
151
 
120
152
  // 1. Pure zero-config - detects everything
121
- const brain = new BrainyData()
122
-
123
- // 2. Environment presets (strongly typed)
124
- const devBrain = new BrainyData(PresetName.DEVELOPMENT) // Memory + verbose
125
- const prodBrain = new BrainyData(PresetName.PRODUCTION) // Disk + optimized
126
- const miniBrain = new BrainyData(PresetName.MINIMAL) // Q8 + minimal features
127
-
128
- // 3. Distributed architecture presets
129
- const writer = new BrainyData(PresetName.WRITER) // Write-only instance
130
- const reader = new BrainyData(PresetName.READER) // Read-only + caching
131
- const ingestion = new BrainyData(PresetName.INGESTION_SERVICE) // High-throughput
132
- const searchAPI = new BrainyData(PresetName.SEARCH_API) // Low-latency search
133
-
134
- // 4. Custom zero-config (type-safe)
135
- const customBrain = new BrainyData({
136
- mode: 'production',
137
- model: 'fp32', // or 'q8', 'auto'
138
- storage: 'cloud', // or 'memory', 'disk', 'auto'
139
- features: ['core', 'search', 'cache']
153
+ const brain = new Brainy()
154
+
155
+ // 2. Custom configuration
156
+ const brain = new Brainy({
157
+ storage: { type: 'memory' },
158
+ embeddings: { model: 'all-MiniLM-L6-v2' },
159
+ cache: { enabled: true, maxSize: 1000 }
160
+ })
161
+
162
+ // 3. Production configuration
163
+ const customBrain = new Brainy({
164
+ mode: 'production',
165
+ model: 'q8', // Optimized model (99% accuracy, 75% smaller)
166
+ storage: 'cloud', // or 'memory', 'disk', 'auto'
167
+ features: ['core', 'search', 'cache']
140
168
  })
141
169
  ```
142
170
 
143
171
  **What's Auto-Detected:**
172
+
144
173
  - **Storage**: S3/GCS/R2 β†’ Filesystem β†’ Memory (priority order)
145
- - **Models**: FP32 vs Q8 based on memory/performance
174
+ - **Models**: Always Q8 for optimal balance
146
175
  - **Features**: Minimal β†’ Default β†’ Full based on environment
147
176
  - **Memory**: Optimal cache sizes and batching
148
177
  - **Performance**: Threading, chunking, indexing strategies
149
178
 
150
179
  ### Production Performance
180
+
151
181
  - **3ms average search** - Lightning fast queries
152
182
  - **24MB memory footprint** - Efficient resource usage
153
183
  - **Worker-based embeddings** - Non-blocking operations
@@ -158,79 +188,72 @@ const customBrain = new BrainyData({
158
188
  Most users **never need this** - zero-config handles everything. For advanced use cases:
159
189
 
160
190
  ```javascript
161
- // Model precision control (auto-detected by default)
162
- const brain = new BrainyData({
163
- model: 'fp32' // Full precision - max compatibility
164
- })
165
- const fastBrain = new BrainyData({
166
- model: 'q8' // Quantized - 75% smaller, 99% accuracy
167
- })
191
+ // Model is always Q8 for optimal performance
192
+ const brain = new Brainy() // Uses Q8 automatically
168
193
 
169
194
  // Storage control (auto-detected by default)
170
- const memoryBrain = new BrainyData({ storage: 'memory' }) // RAM only
171
- const diskBrain = new BrainyData({ storage: 'disk' }) // Local filesystem
172
- const cloudBrain = new BrainyData({ storage: 'cloud' }) // S3/GCS/R2
195
+ const memoryBrain = new Brainy({storage: 'memory'}) // RAM only
196
+ const diskBrain = new Brainy({storage: 'disk'}) // Local filesystem
197
+ const cloudBrain = new Brainy({storage: 'cloud'}) // S3/GCS/R2
173
198
 
174
199
  // Legacy full config (still supported)
175
- const legacyBrain = new BrainyData({
176
- storage: { forceMemoryStorage: true },
177
- embeddingOptions: { precision: 'fp32' }
200
+ const legacyBrain = new Brainy({
201
+ storage: {forceMemoryStorage: true}
178
202
  })
179
203
  ```
180
204
 
181
- **Model Comparison:**
182
- - **FP32**: 90MB, 100% accuracy, maximum compatibility
183
- - **Q8**: 23MB, ~99% accuracy, faster loading, smaller memory
205
+ **Model Details:**
184
206
 
185
- **When to use Q8:**
186
- - βœ… Memory-constrained environments
187
- - βœ… Faster startup required
188
- - βœ… Mobile or edge deployments
189
- - ❌ Existing FP32 datasets (incompatible embeddings)
207
+ - **Q8**: 33MB, 99% accuracy, 75% smaller than full precision
208
+ - Fast loading and optimal memory usage
209
+ - Perfect for all environments
190
210
 
191
211
  **Air-gap deployment:**
212
+
192
213
  ```bash
193
- npm run download-models # Both models (recommended)
194
- npm run download-models:q8 # Q8 only (space-constrained)
195
- npm run download-models:fp32 # FP32 only (compatibility)
214
+ npm run download-models # Download Q8 model
215
+ npm run download-models:q8 # Download Q8 model
196
216
  ```
197
217
 
198
218
  ## πŸ“š Core API
199
219
 
200
220
  ### `search()` - Vector Similarity
221
+
201
222
  ```javascript
202
223
  const results = await brain.search("machine learning", {
203
- limit: 10, // Number of results
204
- metadata: { type: "article" }, // Filter by metadata
205
- includeContent: true // Include full content
224
+ limit: 10, // Number of results
225
+ metadata: {type: "article"}, // Filter by metadata
226
+ includeContent: true // Include full content
206
227
  })
207
228
  ```
208
229
 
209
230
  ### `find()` - Natural Language Queries
231
+
210
232
  ```javascript
211
233
  // Simple natural language
212
234
  const results = await brain.find("recent important documents")
213
235
 
214
236
  // Structured query with Triple Intelligence
215
237
  const results = await brain.find({
216
- like: "JavaScript", // Vector similarity
217
- where: { // Metadata filters
218
- year: { greaterThan: 2020 },
219
- important: true
220
- },
221
- related: { to: "React" } // Graph relationships
238
+ like: "JavaScript", // Vector similarity
239
+ where: { // Metadata filters
240
+ year: {greaterThan: 2020},
241
+ important: true
242
+ },
243
+ related: {to: "React"} // Graph relationships
222
244
  })
223
245
  ```
224
246
 
225
247
  ### CRUD Operations
248
+
226
249
  ```javascript
227
250
  // Create entities (nouns)
228
251
  const id = await brain.addNoun(data, nounType, metadata)
229
252
 
230
253
  // Create relationships (verbs)
231
254
  const verbId = await brain.addVerb(sourceId, targetId, "relationType", {
232
- strength: 0.9,
233
- bidirectional: false
255
+ strength: 0.9,
256
+ bidirectional: false
234
257
  })
235
258
 
236
259
  // Read
@@ -247,36 +270,106 @@ await brain.deleteVerb(verbId)
247
270
 
248
271
  // Bulk operations
249
272
  await brain.import(arrayOfData)
250
- const exported = await brain.export({ format: 'json' })
273
+ const exported = await brain.export({format: 'json'})
251
274
  ```
252
275
 
276
+ ## 🌐 Distributed System (NEW!)
277
+
278
+ ### Zero-Config Distributed Setup
279
+
280
+ ```javascript
281
+ // Single node (default)
282
+ const brain = new Brainy({
283
+ storage: {type: 's3', options: {bucket: 'my-data'}}
284
+ })
285
+
286
+ // Distributed cluster - just add one flag!
287
+ const brain = new Brainy({
288
+ storage: {type: 's3', options: {bucket: 'my-data'}},
289
+ distributed: true // That's it! Everything else is automatic
290
+ })
291
+ ```
292
+
293
+ ### How It Works
294
+
295
+ - **Storage-Based Discovery**: Nodes find each other via S3/GCS (no Consul/etcd!)
296
+ - **Automatic Sharding**: Data distributed by content hash
297
+ - **Smart Query Planning**: Queries routed to optimal shards
298
+ - **Live Rebalancing**: Handles node joins/leaves automatically
299
+ - **Zero Downtime**: Streaming shard migration
300
+
301
+ ### Real-World Example: Social Media Firehose
302
+
303
+ ```javascript
304
+ // Ingestion nodes (optimized for writes)
305
+ const ingestionNode = new Brainy({
306
+ storage: {type: 's3', options: {bucket: 'social-data'}},
307
+ distributed: true,
308
+ writeOnly: true // Optimized for high-throughput writes
309
+ })
310
+
311
+ // Process Bluesky firehose
312
+ blueskyStream.on('post', async (post) => {
313
+ await ingestionNode.addNoun(post, 'social-post', {
314
+ platform: 'bluesky',
315
+ author: post.author,
316
+ timestamp: post.createdAt
317
+ })
318
+ })
319
+
320
+ // Search nodes (optimized for queries)
321
+ const searchNode = new Brainy({
322
+ storage: {type: 's3', options: {bucket: 'social-data'}},
323
+ distributed: true,
324
+ readOnly: true // Optimized for fast queries
325
+ })
326
+
327
+ // Search across ALL data from ALL nodes
328
+ const trending = await searchNode.find('trending AI topics', {
329
+ where: {timestamp: {greaterThan: Date.now() - 3600000}},
330
+ limit: 100
331
+ })
332
+ ```
333
+
334
+ ### Benefits Over Traditional Systems
335
+
336
+ | Feature | Traditional (Pinecone, Weaviate) | Brainy Distributed |
337
+ |----------------|----------------------------------|-------------------------------|
338
+ | Setup | Complex (k8s, operators) | One flag: `distributed: true` |
339
+ | Coordination | External (etcd, Consul) | Built-in (via storage) |
340
+ | Minimum Nodes | 3-5 for HA | 1 (scale as needed) |
341
+ | Sharding | Random | Domain-aware |
342
+ | Query Planning | Basic | Triple Intelligence |
343
+ | Cost | High (always-on clusters) | Low (scale to zero) |
344
+
253
345
  ## 🎯 Use Cases
254
346
 
255
347
  ### Knowledge Management with Relationships
348
+
256
349
  ```javascript
257
350
  // Store documentation with rich relationships
258
351
  const apiGuide = await brain.addNoun("REST API Guide", 'document', {
259
- title: "API Guide",
260
- category: "documentation",
261
- version: "2.0"
352
+ title: "API Guide",
353
+ category: "documentation",
354
+ version: "2.0"
262
355
  })
263
356
 
264
357
  const author = await brain.addNoun("Jane Developer", 'person', {
265
- type: "person",
266
- role: "tech-lead"
358
+ type: "person",
359
+ role: "tech-lead"
267
360
  })
268
361
 
269
362
  const project = await brain.addNoun("E-commerce Platform", 'project', {
270
- type: "project",
271
- status: "active"
363
+ type: "project",
364
+ status: "active"
272
365
  })
273
366
 
274
367
  // Create knowledge graph
275
- await brain.addVerb(author, apiGuide, "authored", {
276
- date: "2024-03-15"
368
+ await brain.addVerb(author, apiGuide, "authored", {
369
+ date: "2024-03-15"
277
370
  })
278
- await brain.addVerb(apiGuide, project, "documents", {
279
- coverage: "complete"
371
+ await brain.addVerb(apiGuide, project, "documents", {
372
+ coverage: "complete"
280
373
  })
281
374
 
282
375
  // Query the knowledge graph naturally
@@ -284,31 +377,33 @@ const docs = await brain.find("documentation authored by tech leads for active p
284
377
  ```
285
378
 
286
379
  ### Semantic Search
380
+
287
381
  ```javascript
288
382
  // Find similar content
289
383
  const similar = await brain.search(existingContent, {
290
- limit: 5,
291
- threshold: 0.8
384
+ limit: 5,
385
+ threshold: 0.8
292
386
  })
293
387
  ```
294
388
 
295
389
  ### AI Memory Layer with Context
390
+
296
391
  ```javascript
297
392
  // Store conversation with relationships
298
393
  const userId = await brain.addNoun("User 123", 'user', {
299
- type: "user",
300
- tier: "premium"
394
+ type: "user",
395
+ tier: "premium"
301
396
  })
302
397
 
303
398
  const messageId = await brain.addNoun(userMessage, 'message', {
304
- type: "message",
305
- timestamp: Date.now(),
306
- session: "abc"
399
+ type: "message",
400
+ timestamp: Date.now(),
401
+ session: "abc"
307
402
  })
308
403
 
309
404
  const topicId = await brain.addNoun("Product Support", 'topic', {
310
- type: "topic",
311
- category: "support"
405
+ type: "topic",
406
+ category: "support"
312
407
  })
313
408
 
314
409
  // Link conversation elements
@@ -317,9 +412,9 @@ await brain.addVerb(messageId, topicId, "about")
317
412
 
318
413
  // Retrieve context with relationships
319
414
  const context = await brain.find({
320
- where: { type: "message" },
321
- connected: { from: userId, type: "sent" },
322
- like: "previous product issues"
415
+ where: {type: "message"},
416
+ connected: {from: userId, type: "sent"},
417
+ like: "previous product issues"
323
418
  })
324
419
  ```
325
420
 
@@ -329,30 +424,30 @@ Brainy supports multiple storage backends:
329
424
 
330
425
  ```javascript
331
426
  // Memory (default for testing)
332
- const brain = new BrainyData({
333
- storage: { type: 'memory' }
427
+ const brain = new Brainy({
428
+ storage: {type: 'memory'}
334
429
  })
335
430
 
336
431
  // FileSystem (Node.js)
337
- const brain = new BrainyData({
338
- storage: {
339
- type: 'filesystem',
340
- path: './data'
341
- }
432
+ const brain = new Brainy({
433
+ storage: {
434
+ type: 'filesystem',
435
+ path: './data'
436
+ }
342
437
  })
343
438
 
344
439
  // Browser Storage (OPFS)
345
- const brain = new BrainyData({
346
- storage: { type: 'opfs' }
440
+ const brain = new Brainy({
441
+ storage: {type: 'opfs'}
347
442
  })
348
443
 
349
444
  // S3 Compatible (Production)
350
- const brain = new BrainyData({
351
- storage: {
352
- type: 's3',
353
- bucket: 'my-bucket',
354
- region: 'us-east-1'
355
- }
445
+ const brain = new Brainy({
446
+ storage: {
447
+ type: 's3',
448
+ bucket: 'my-bucket',
449
+ region: 'us-east-1'
450
+ }
356
451
  })
357
452
  ```
358
453
 
@@ -385,6 +480,7 @@ brainy export --format json > backup.json
385
480
  Brainy includes a powerful Neural API for advanced semantic analysis:
386
481
 
387
482
  ### Clustering & Analysis
483
+
388
484
  ```javascript
389
485
  // Access via brain.neural
390
486
  const neural = brain.neural
@@ -395,9 +491,9 @@ const clusters = await neural.clusters()
395
491
 
396
492
  // Cluster with options
397
493
  const clusters = await neural.clusters({
398
- algorithm: 'kmeans', // or 'hierarchical', 'sample'
399
- maxClusters: 5, // Maximum number of clusters
400
- threshold: 0.8 // Similarity threshold
494
+ algorithm: 'kmeans', // or 'hierarchical', 'sample'
495
+ maxClusters: 5, // Maximum number of clusters
496
+ threshold: 0.8 // Similarity threshold
401
497
  })
402
498
 
403
499
  // Calculate similarity between any items
@@ -415,19 +511,20 @@ const outliers = await neural.outliers(0.3)
415
511
 
416
512
  // Generate visualization data for D3/Cytoscape
417
513
  const vizData = await neural.visualize({
418
- maxNodes: 100,
419
- dimensions: 3,
420
- algorithm: 'force'
514
+ maxNodes: 100,
515
+ dimensions: 3,
516
+ algorithm: 'force'
421
517
  })
422
518
  ```
423
519
 
424
520
  ### Real-World Examples
521
+
425
522
  ```javascript
426
523
  // Group customer feedback into themes
427
524
  const feedbackClusters = await neural.clusters()
428
525
  for (const cluster of feedbackClusters) {
429
- console.log(`Theme: ${cluster.label}`)
430
- console.log(`Items: ${cluster.members.length}`)
526
+ console.log(`Theme: ${cluster.label}`)
527
+ console.log(`Items: ${cluster.members.length}`)
431
528
  }
432
529
 
433
530
  // Find related documents
@@ -460,32 +557,30 @@ brainy cloud setup
460
557
  Brainy includes enterprise-grade capabilities at no extra cost. **No premium tiers, no paywalls.**
461
558
 
462
559
  - **Scales to 10M+ items** with consistent 3ms search latency
463
- - **Write-Ahead Logging (WAL)** for zero data loss durability
464
560
  - **Distributed architecture** with sharding and replication
465
561
  - **Read/write separation** for horizontal scaling
466
562
  - **Connection pooling** and request deduplication
467
563
  - **Built-in monitoring** with metrics and health checks
468
564
  - **Production ready** with circuit breakers and backpressure
469
565
 
470
- πŸ“– **[Read the full Enterprise Features guide β†’](docs/ENTERPRISE-FEATURES.md)**
566
+ πŸ“– **Enterprise features coming in Brainy 3.1** - Stay tuned!
471
567
 
472
568
  ## πŸ“Š Benchmarks
473
569
 
474
- | Operation | Performance | Memory |
475
- |-----------|------------|--------|
476
- | Initialize | 450ms | 24MB |
477
- | Add Item | 12ms | +0.1MB |
478
- | Vector Search (1k items) | 3ms | - |
479
- | Metadata Filter (10k items) | 0.8ms | - |
480
- | Natural Language Query | 15ms | - |
481
- | Bulk Import (1000 items) | 2.3s | +8MB |
482
- | **Production Scale (10M items)** | **5.8ms** | **12GB** |
570
+ | Operation | Performance | Memory |
571
+ |----------------------------------|-------------|----------|
572
+ | Initialize | 450ms | 24MB |
573
+ | Add Item | 12ms | +0.1MB |
574
+ | Vector Search (1k items) | 3ms | - |
575
+ | Metadata Filter (10k items) | 0.8ms | - |
576
+ | Natural Language Query | 15ms | - |
577
+ | Bulk Import (1000 items) | 2.3s | +8MB |
578
+ | **Production Scale (10M items)** | **5.8ms** | **12GB** |
483
579
 
484
- ## πŸ”„ Migration from 1.x
580
+ ## πŸ”„ Migration from 2.x
485
581
 
486
- See [MIGRATION.md](MIGRATION.md) for detailed upgrade instructions.
582
+ Key changes for upgrading to 3.0:
487
583
 
488
- Key changes:
489
584
  - Search methods consolidated into `search()` and `find()`
490
585
  - Result format now includes full objects with metadata
491
586
  - New natural language capabilities
@@ -499,8 +594,9 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
499
594
  ### How We Achieved The Impossible
500
595
 
501
596
  **Triple Intelligenceβ„’** makes us the **world's first** to unify three database paradigms:
597
+
502
598
  1. **Vector databases** (Pinecone, Weaviate) - semantic similarity
503
- 2. **Graph databases** (Neo4j, ArangoDB) - relationships
599
+ 2. **Graph databases** (Neo4j, ArangoDB) - relationships
504
600
  3. **Document databases** (MongoDB, Elasticsearch) - metadata filtering
505
601
 
506
602
  **One API to rule them all.** Others make you choose. We unified them.
@@ -519,6 +615,7 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
519
615
  ### Why This Changes Everything
520
616
 
521
617
  **Like HTTP for the web, Brainy for knowledge:**
618
+
522
619
  - All augmentations compose perfectly - same noun-verb language
523
620
  - All AI models share knowledge - GPT, Claude, Llama all understand
524
621
  - All tools integrate seamlessly - no translation layers