@soulcraft/brainy 3.0.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 (260) hide show
  1. package/CHANGELOG.md +53 -3
  2. package/README.md +353 -110
  3. package/bin/brainy.js +340 -62
  4. package/dist/api/ConfigAPI.d.ts +67 -0
  5. package/dist/api/ConfigAPI.js +166 -0
  6. package/dist/api/DataAPI.d.ts +123 -0
  7. package/dist/api/DataAPI.js +391 -0
  8. package/dist/api/SecurityAPI.d.ts +50 -0
  9. package/dist/api/SecurityAPI.js +139 -0
  10. package/dist/api/UniversalImportAPI.d.ts +134 -0
  11. package/dist/api/UniversalImportAPI.js +615 -0
  12. package/dist/augmentationManager.js +12 -7
  13. package/dist/augmentationPipeline.d.ts +0 -61
  14. package/dist/augmentationPipeline.js +0 -87
  15. package/dist/augmentationRegistry.d.ts +1 -1
  16. package/dist/augmentationRegistry.js +1 -1
  17. package/dist/augmentations/apiServerAugmentation.d.ts +27 -1
  18. package/dist/augmentations/apiServerAugmentation.js +290 -9
  19. package/dist/augmentations/auditLogAugmentation.d.ts +109 -0
  20. package/dist/augmentations/auditLogAugmentation.js +358 -0
  21. package/dist/augmentations/batchProcessingAugmentation.d.ts +3 -2
  22. package/dist/augmentations/batchProcessingAugmentation.js +123 -22
  23. package/dist/augmentations/brainyAugmentation.d.ts +142 -8
  24. package/dist/augmentations/brainyAugmentation.js +179 -2
  25. package/dist/augmentations/cacheAugmentation.d.ts +8 -5
  26. package/dist/augmentations/cacheAugmentation.js +116 -17
  27. package/dist/augmentations/conduitAugmentations.d.ts +2 -2
  28. package/dist/augmentations/conduitAugmentations.js +2 -2
  29. package/dist/augmentations/configResolver.d.ts +122 -0
  30. package/dist/augmentations/configResolver.js +440 -0
  31. package/dist/augmentations/connectionPoolAugmentation.d.ts +3 -1
  32. package/dist/augmentations/connectionPoolAugmentation.js +37 -12
  33. package/dist/augmentations/defaultAugmentations.d.ts +14 -10
  34. package/dist/augmentations/defaultAugmentations.js +16 -11
  35. package/dist/augmentations/discovery/catalogDiscovery.d.ts +142 -0
  36. package/dist/augmentations/discovery/catalogDiscovery.js +249 -0
  37. package/dist/augmentations/discovery/localDiscovery.d.ts +84 -0
  38. package/dist/augmentations/discovery/localDiscovery.js +246 -0
  39. package/dist/augmentations/discovery/runtimeLoader.d.ts +97 -0
  40. package/dist/augmentations/discovery/runtimeLoader.js +337 -0
  41. package/dist/augmentations/discovery.d.ts +152 -0
  42. package/dist/augmentations/discovery.js +441 -0
  43. package/dist/augmentations/display/cache.d.ts +130 -0
  44. package/dist/augmentations/display/cache.js +319 -0
  45. package/dist/augmentations/display/fieldPatterns.d.ts +52 -0
  46. package/dist/augmentations/display/fieldPatterns.js +393 -0
  47. package/dist/augmentations/display/iconMappings.d.ts +57 -0
  48. package/dist/augmentations/display/iconMappings.js +68 -0
  49. package/dist/augmentations/display/intelligentComputation.d.ts +109 -0
  50. package/dist/augmentations/display/intelligentComputation.js +462 -0
  51. package/dist/augmentations/display/types.d.ts +203 -0
  52. package/dist/augmentations/display/types.js +7 -0
  53. package/dist/augmentations/entityRegistryAugmentation.d.ts +3 -1
  54. package/dist/augmentations/entityRegistryAugmentation.js +5 -1
  55. package/dist/augmentations/indexAugmentation.d.ts +5 -3
  56. package/dist/augmentations/indexAugmentation.js +5 -2
  57. package/dist/augmentations/intelligentVerbScoringAugmentation.d.ts +24 -7
  58. package/dist/augmentations/intelligentVerbScoringAugmentation.js +111 -27
  59. package/dist/augmentations/manifest.d.ts +176 -0
  60. package/dist/augmentations/manifest.js +8 -0
  61. package/dist/augmentations/marketplace/AugmentationMarketplace.d.ts +168 -0
  62. package/dist/augmentations/marketplace/AugmentationMarketplace.js +329 -0
  63. package/dist/augmentations/marketplace/cli.d.ts +47 -0
  64. package/dist/augmentations/marketplace/cli.js +265 -0
  65. package/dist/augmentations/metricsAugmentation.d.ts +3 -3
  66. package/dist/augmentations/metricsAugmentation.js +2 -2
  67. package/dist/augmentations/monitoringAugmentation.d.ts +3 -3
  68. package/dist/augmentations/monitoringAugmentation.js +2 -2
  69. package/dist/augmentations/neuralImport.d.ts +1 -1
  70. package/dist/augmentations/neuralImport.js +4 -4
  71. package/dist/augmentations/rateLimitAugmentation.d.ts +82 -0
  72. package/dist/augmentations/rateLimitAugmentation.js +321 -0
  73. package/dist/augmentations/requestDeduplicatorAugmentation.d.ts +2 -2
  74. package/dist/augmentations/requestDeduplicatorAugmentation.js +1 -1
  75. package/dist/augmentations/storageAugmentation.d.ts +1 -1
  76. package/dist/augmentations/storageAugmentation.js +2 -2
  77. package/dist/augmentations/storageAugmentations.d.ts +37 -8
  78. package/dist/augmentations/storageAugmentations.js +204 -15
  79. package/dist/augmentations/synapseAugmentation.d.ts +1 -1
  80. package/dist/augmentations/synapseAugmentation.js +35 -16
  81. package/dist/augmentations/typeMatching/brainyTypes.d.ts +83 -0
  82. package/dist/augmentations/typeMatching/brainyTypes.js +425 -0
  83. package/dist/augmentations/typeMatching/intelligentTypeMatcher.d.ts +39 -59
  84. package/dist/augmentations/typeMatching/intelligentTypeMatcher.js +103 -389
  85. package/dist/augmentations/universalDisplayAugmentation.d.ts +191 -0
  86. package/dist/augmentations/universalDisplayAugmentation.js +371 -0
  87. package/dist/brainy-unified.d.ts +106 -0
  88. package/dist/brainy-unified.js +327 -0
  89. package/dist/brainy.d.ts +273 -0
  90. package/dist/brainy.js +1181 -0
  91. package/dist/brainyData.d.ts +56 -111
  92. package/dist/brainyData.js +912 -756
  93. package/dist/brainyDataV3.d.ts +186 -0
  94. package/dist/brainyDataV3.js +337 -0
  95. package/dist/browserFramework.d.ts +6 -6
  96. package/dist/browserFramework.js +11 -8
  97. package/dist/browserFramework.minimal.d.ts +5 -5
  98. package/dist/browserFramework.minimal.js +11 -8
  99. package/dist/config/distributedPresets-new.d.ts +118 -0
  100. package/dist/config/distributedPresets-new.js +318 -0
  101. package/dist/config/distributedPresets.d.ts +118 -0
  102. package/dist/config/distributedPresets.js +318 -0
  103. package/dist/config/extensibleConfig.d.ts +99 -0
  104. package/dist/config/extensibleConfig.js +268 -0
  105. package/dist/config/index.d.ts +17 -0
  106. package/dist/config/index.js +35 -0
  107. package/dist/config/modelAutoConfig.d.ts +32 -0
  108. package/dist/config/modelAutoConfig.js +139 -0
  109. package/dist/config/modelPrecisionManager.d.ts +42 -0
  110. package/dist/config/modelPrecisionManager.js +98 -0
  111. package/dist/config/sharedConfigManager.d.ts +67 -0
  112. package/dist/config/sharedConfigManager.js +215 -0
  113. package/dist/config/storageAutoConfig.d.ts +41 -0
  114. package/dist/config/storageAutoConfig.js +328 -0
  115. package/dist/config/zeroConfig.d.ts +68 -0
  116. package/dist/config/zeroConfig.js +301 -0
  117. package/dist/cortex/backupRestore.d.ts +2 -2
  118. package/dist/cortex/backupRestore.js +85 -27
  119. package/dist/cortex/healthCheck.d.ts +2 -2
  120. package/dist/cortex/neuralImport.d.ts +2 -2
  121. package/dist/cortex/neuralImport.js +18 -13
  122. package/dist/cortex/performanceMonitor.d.ts +2 -2
  123. package/dist/critical/model-guardian.d.ts +4 -0
  124. package/dist/critical/model-guardian.js +31 -11
  125. package/dist/demo.d.ts +4 -4
  126. package/dist/demo.js +7 -7
  127. package/dist/distributed/cacheSync.d.ts +112 -0
  128. package/dist/distributed/cacheSync.js +265 -0
  129. package/dist/distributed/coordinator.d.ts +193 -0
  130. package/dist/distributed/coordinator.js +548 -0
  131. package/dist/distributed/httpTransport.d.ts +120 -0
  132. package/dist/distributed/httpTransport.js +446 -0
  133. package/dist/distributed/index.d.ts +8 -0
  134. package/dist/distributed/index.js +5 -0
  135. package/dist/distributed/networkTransport.d.ts +132 -0
  136. package/dist/distributed/networkTransport.js +633 -0
  137. package/dist/distributed/queryPlanner.d.ts +104 -0
  138. package/dist/distributed/queryPlanner.js +327 -0
  139. package/dist/distributed/readWriteSeparation.d.ts +134 -0
  140. package/dist/distributed/readWriteSeparation.js +350 -0
  141. package/dist/distributed/shardManager.d.ts +114 -0
  142. package/dist/distributed/shardManager.js +357 -0
  143. package/dist/distributed/shardMigration.d.ts +110 -0
  144. package/dist/distributed/shardMigration.js +289 -0
  145. package/dist/distributed/storageDiscovery.d.ts +160 -0
  146. package/dist/distributed/storageDiscovery.js +551 -0
  147. package/dist/embeddings/CachedEmbeddings.d.ts +40 -0
  148. package/dist/embeddings/CachedEmbeddings.js +146 -0
  149. package/dist/embeddings/EmbeddingManager.d.ts +102 -0
  150. package/dist/embeddings/EmbeddingManager.js +291 -0
  151. package/dist/embeddings/SingletonModelManager.d.ts +95 -0
  152. package/dist/embeddings/SingletonModelManager.js +220 -0
  153. package/dist/embeddings/index.d.ts +12 -0
  154. package/dist/embeddings/index.js +16 -0
  155. package/dist/embeddings/lightweight-embedder.d.ts +0 -1
  156. package/dist/embeddings/lightweight-embedder.js +4 -12
  157. package/dist/embeddings/model-manager.d.ts +11 -0
  158. package/dist/embeddings/model-manager.js +43 -7
  159. package/dist/embeddings/universal-memory-manager.d.ts +1 -1
  160. package/dist/embeddings/universal-memory-manager.js +27 -67
  161. package/dist/embeddings/worker-embedding.js +4 -8
  162. package/dist/errors/brainyError.d.ts +5 -1
  163. package/dist/errors/brainyError.js +12 -0
  164. package/dist/examples/basicUsage.js +7 -4
  165. package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
  166. package/dist/graph/graphAdjacencyIndex.js +288 -0
  167. package/dist/graph/pathfinding.js +4 -2
  168. package/dist/hnsw/scaledHNSWSystem.js +11 -2
  169. package/dist/importManager.js +8 -5
  170. package/dist/index.d.ts +17 -22
  171. package/dist/index.js +37 -23
  172. package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
  173. package/dist/mcp/brainyMCPAdapter.js +5 -5
  174. package/dist/mcp/brainyMCPService.d.ts +3 -3
  175. package/dist/mcp/brainyMCPService.js +3 -11
  176. package/dist/mcp/mcpAugmentationToolset.js +20 -30
  177. package/dist/neural/embeddedPatterns.d.ts +1 -1
  178. package/dist/neural/embeddedPatterns.js +2 -2
  179. package/dist/neural/entityExtractor.d.ts +65 -0
  180. package/dist/neural/entityExtractor.js +316 -0
  181. package/dist/neural/improvedNeuralAPI.d.ts +357 -0
  182. package/dist/neural/improvedNeuralAPI.js +2628 -0
  183. package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
  184. package/dist/neural/naturalLanguageProcessor.js +941 -66
  185. package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
  186. package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
  187. package/dist/neural/neuralAPI.js +8 -2
  188. package/dist/neural/patternLibrary.d.ts +57 -3
  189. package/dist/neural/patternLibrary.js +348 -13
  190. package/dist/neural/staticPatternMatcher.d.ts +2 -2
  191. package/dist/neural/staticPatternMatcher.js +2 -2
  192. package/dist/neural/types.d.ts +287 -0
  193. package/dist/neural/types.js +24 -0
  194. package/dist/shared/default-augmentations.d.ts +3 -3
  195. package/dist/shared/default-augmentations.js +5 -5
  196. package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
  197. package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
  198. package/dist/storage/adapters/fileSystemStorage.js +218 -15
  199. package/dist/storage/adapters/memoryStorage.d.ts +4 -4
  200. package/dist/storage/adapters/memoryStorage.js +17 -12
  201. package/dist/storage/adapters/opfsStorage.d.ts +2 -2
  202. package/dist/storage/adapters/opfsStorage.js +2 -2
  203. package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
  204. package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
  205. package/dist/storage/backwardCompatibility.d.ts +10 -78
  206. package/dist/storage/backwardCompatibility.js +17 -132
  207. package/dist/storage/baseStorage.d.ts +18 -2
  208. package/dist/storage/baseStorage.js +74 -3
  209. package/dist/storage/cacheManager.js +2 -2
  210. package/dist/storage/readOnlyOptimizations.js +8 -3
  211. package/dist/streaming/pipeline.d.ts +154 -0
  212. package/dist/streaming/pipeline.js +551 -0
  213. package/dist/triple/TripleIntelligence.d.ts +25 -110
  214. package/dist/triple/TripleIntelligence.js +4 -574
  215. package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
  216. package/dist/triple/TripleIntelligenceSystem.js +519 -0
  217. package/dist/types/apiTypes.d.ts +278 -0
  218. package/dist/types/apiTypes.js +33 -0
  219. package/dist/types/brainy.types.d.ts +308 -0
  220. package/dist/types/brainy.types.js +8 -0
  221. package/dist/types/brainyDataInterface.d.ts +5 -8
  222. package/dist/types/brainyDataInterface.js +2 -2
  223. package/dist/types/graphTypes.js +2 -2
  224. package/dist/utils/brainyTypes.d.ts +217 -0
  225. package/dist/utils/brainyTypes.js +261 -0
  226. package/dist/utils/cacheAutoConfig.d.ts +3 -3
  227. package/dist/utils/embedding.d.ts +9 -4
  228. package/dist/utils/embedding.js +89 -26
  229. package/dist/utils/enhancedLogger.d.ts +104 -0
  230. package/dist/utils/enhancedLogger.js +232 -0
  231. package/dist/utils/hybridModelManager.d.ts +19 -28
  232. package/dist/utils/hybridModelManager.js +36 -200
  233. package/dist/utils/index.d.ts +1 -1
  234. package/dist/utils/index.js +1 -1
  235. package/dist/utils/intelligentTypeMapper.d.ts +60 -0
  236. package/dist/utils/intelligentTypeMapper.js +349 -0
  237. package/dist/utils/metadataIndex.d.ts +118 -1
  238. package/dist/utils/metadataIndex.js +539 -16
  239. package/dist/utils/nodeVersionCheck.d.ts +24 -0
  240. package/dist/utils/nodeVersionCheck.js +65 -0
  241. package/dist/utils/paramValidation.d.ts +39 -0
  242. package/dist/utils/paramValidation.js +192 -0
  243. package/dist/utils/rateLimiter.d.ts +160 -0
  244. package/dist/utils/rateLimiter.js +271 -0
  245. package/dist/utils/statistics.d.ts +4 -4
  246. package/dist/utils/statistics.js +3 -3
  247. package/dist/utils/structuredLogger.d.ts +146 -0
  248. package/dist/utils/structuredLogger.js +394 -0
  249. package/dist/utils/textEncoding.js +2 -1
  250. package/dist/utils/typeValidation.d.ts +59 -0
  251. package/dist/utils/typeValidation.js +374 -0
  252. package/dist/utils/version.js +19 -3
  253. package/package.json +15 -4
  254. package/scripts/download-models.cjs +94 -20
  255. package/dist/augmentations/walAugmentation.d.ts +0 -109
  256. package/dist/augmentations/walAugmentation.js +0 -516
  257. package/dist/chat/BrainyChat.d.ts +0 -121
  258. package/dist/chat/BrainyChat.js +0 -396
  259. package/dist/chat/ChatCLI.d.ts +0 -61
  260. package/dist/chat/ChatCLI.js +0 -351
package/README.md CHANGED
@@ -9,72 +9,114 @@
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**
31
23
 
32
- ## ⚑ Quick Start
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
42
+
43
+ ## ⚑ Quick Start - Zero Configuration
33
44
 
34
45
  ```bash
35
46
  npm install @soulcraft/brainy
36
47
  ```
37
48
 
49
+ ### 🎯 **True Zero Configuration**
50
+
38
51
  ```javascript
39
- import { BrainyData } from 'brainy'
52
+ import {Brainy} from '@soulcraft/brainy'
40
53
 
41
- const brain = new BrainyData()
54
+ // Just this - auto-detects everything!
55
+ const brain = new Brainy()
42
56
  await brain.init()
43
57
 
44
- // Add entities (nouns) with automatic embedding
45
- const jsId = await brain.addNoun("JavaScript is a programming language", {
46
- type: "language",
47
- year: 1995,
48
- 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
+ }
49
67
  })
50
68
 
51
- const nodeId = await brain.addNoun("Node.js runtime environment", {
52
- type: "runtime",
53
- year: 2009,
54
- 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
+ }
55
77
  })
56
78
 
57
- // Create relationships (verbs) between entities
58
- await brain.addVerb(nodeId, jsId, "executes", {
59
- since: 2009,
60
- 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
+ }
61
88
  })
62
89
 
63
90
  // Natural language search with graph relationships
64
- const results = await brain.find("programming languages used by server runtimes")
91
+ const results = await brain.find({query: "programming languages used by server runtimes"})
65
92
 
66
93
  // Triple Intelligence: vector + metadata + relationships
67
94
  const filtered = await brain.find({
68
- like: "JavaScript", // Vector similarity
69
- where: { type: "language" }, // Metadata filtering
70
- 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
71
98
  })
72
99
  ```
73
100
 
101
+ ## πŸ“‹ System Requirements
102
+
103
+ **Node.js Version:** 22 LTS or later (recommended)
104
+
105
+ - βœ… **Node.js 22 LTS** - Fully supported and recommended for production
106
+ - βœ… **Node.js 20 LTS** - Compatible (maintenance mode)
107
+ - ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
108
+
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.
111
+
112
+ If using nvm: `nvm use` (we provide a `.nvmrc` file)
113
+
74
114
  ## πŸš€ Key Features
75
115
 
76
116
  ### World's First Triple Intelligenceβ„’ Engine
117
+
77
118
  **The breakthrough that enables the Universal Knowledge Protocol:**
119
+
78
120
  - **Vector Search**: Semantic similarity with HNSW indexing
79
121
  - **Graph Relationships**: Navigate connected knowledge like Neo4j
80
122
  - **Document Filtering**: MongoDB-style queries with O(log n) performance
@@ -82,7 +124,9 @@ const filtered = await brain.find({
82
124
  - **First to solve this**: Others do vector OR graph OR documentβ€”we do ALL
83
125
 
84
126
  ### Universal Knowledge Protocol with Infinite Expressiveness
127
+
85
128
  **Enabled by Triple Intelligence, standardized for everyone:**
129
+
86
130
  - **24 Noun Types Γ— 40 Verb Types**: 960 base combinations
87
131
  - **∞ Expressiveness**: Unlimited metadata = model ANY data
88
132
  - **One Language**: All tools, augmentations, AI models speak the same types
@@ -90,6 +134,7 @@ const filtered = await brain.find({
90
134
  - **No Schema Lock-in**: Evolve without migrations
91
135
 
92
136
  ### Natural Language Understanding
137
+
93
138
  ```javascript
94
139
  // Ask questions naturally
95
140
  await brain.find("Show me recent React components with tests")
@@ -97,54 +142,118 @@ await brain.find("Popular JavaScript libraries similar to Vue")
97
142
  await brain.find("Documentation about authentication from last month")
98
143
  ```
99
144
 
100
- ### Zero Configuration Philosophy
101
- - **No API keys required** - Built-in embedding models
102
- - **No external dependencies** - Everything included
103
- - **No complex setup** - Works instantly
104
- - **Smart defaults** - Optimized out of the box
145
+ ### 🎯 Zero Configuration Philosophy
146
+
147
+ Brainy 3.0 automatically configures **everything**:
148
+
149
+ ```javascript
150
+ import {Brainy} from '@soulcraft/brainy'
151
+
152
+ // 1. Pure zero-config - detects everything
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']
168
+ })
169
+ ```
170
+
171
+ **What's Auto-Detected:**
172
+
173
+ - **Storage**: S3/GCS/R2 β†’ Filesystem β†’ Memory (priority order)
174
+ - **Models**: Always Q8 for optimal balance
175
+ - **Features**: Minimal β†’ Default β†’ Full based on environment
176
+ - **Memory**: Optimal cache sizes and batching
177
+ - **Performance**: Threading, chunking, indexing strategies
105
178
 
106
179
  ### Production Performance
180
+
107
181
  - **3ms average search** - Lightning fast queries
108
182
  - **24MB memory footprint** - Efficient resource usage
109
183
  - **Worker-based embeddings** - Non-blocking operations
110
184
  - **Automatic caching** - Intelligent result caching
111
185
 
186
+ ### πŸŽ›οΈ Advanced Configuration (When Needed)
187
+
188
+ Most users **never need this** - zero-config handles everything. For advanced use cases:
189
+
190
+ ```javascript
191
+ // Model is always Q8 for optimal performance
192
+ const brain = new Brainy() // Uses Q8 automatically
193
+
194
+ // Storage control (auto-detected by default)
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
198
+
199
+ // Legacy full config (still supported)
200
+ const legacyBrain = new Brainy({
201
+ storage: {forceMemoryStorage: true}
202
+ })
203
+ ```
204
+
205
+ **Model Details:**
206
+
207
+ - **Q8**: 33MB, 99% accuracy, 75% smaller than full precision
208
+ - Fast loading and optimal memory usage
209
+ - Perfect for all environments
210
+
211
+ **Air-gap deployment:**
212
+
213
+ ```bash
214
+ npm run download-models # Download Q8 model
215
+ npm run download-models:q8 # Download Q8 model
216
+ ```
217
+
112
218
  ## πŸ“š Core API
113
219
 
114
220
  ### `search()` - Vector Similarity
221
+
115
222
  ```javascript
116
223
  const results = await brain.search("machine learning", {
117
- limit: 10, // Number of results
118
- metadata: { type: "article" }, // Filter by metadata
119
- includeContent: true // Include full content
224
+ limit: 10, // Number of results
225
+ metadata: {type: "article"}, // Filter by metadata
226
+ includeContent: true // Include full content
120
227
  })
121
228
  ```
122
229
 
123
230
  ### `find()` - Natural Language Queries
231
+
124
232
  ```javascript
125
233
  // Simple natural language
126
234
  const results = await brain.find("recent important documents")
127
235
 
128
236
  // Structured query with Triple Intelligence
129
237
  const results = await brain.find({
130
- like: "JavaScript", // Vector similarity
131
- where: { // Metadata filters
132
- year: { greaterThan: 2020 },
133
- important: true
134
- },
135
- 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
136
244
  })
137
245
  ```
138
246
 
139
247
  ### CRUD Operations
248
+
140
249
  ```javascript
141
250
  // Create entities (nouns)
142
- const id = await brain.addNoun(data, metadata)
251
+ const id = await brain.addNoun(data, nounType, metadata)
143
252
 
144
253
  // Create relationships (verbs)
145
254
  const verbId = await brain.addVerb(sourceId, targetId, "relationType", {
146
- strength: 0.9,
147
- bidirectional: false
255
+ strength: 0.9,
256
+ bidirectional: false
148
257
  })
149
258
 
150
259
  // Read
@@ -161,36 +270,106 @@ await brain.deleteVerb(verbId)
161
270
 
162
271
  // Bulk operations
163
272
  await brain.import(arrayOfData)
164
- const exported = await brain.export({ format: 'json' })
273
+ const exported = await brain.export({format: 'json'})
165
274
  ```
166
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
+
167
345
  ## 🎯 Use Cases
168
346
 
169
347
  ### Knowledge Management with Relationships
348
+
170
349
  ```javascript
171
350
  // Store documentation with rich relationships
172
- const apiGuide = await brain.addNoun("REST API Guide", {
173
- title: "API Guide",
174
- category: "documentation",
175
- version: "2.0"
351
+ const apiGuide = await brain.addNoun("REST API Guide", 'document', {
352
+ title: "API Guide",
353
+ category: "documentation",
354
+ version: "2.0"
176
355
  })
177
356
 
178
- const author = await brain.addNoun("Jane Developer", {
179
- type: "person",
180
- role: "tech-lead"
357
+ const author = await brain.addNoun("Jane Developer", 'person', {
358
+ type: "person",
359
+ role: "tech-lead"
181
360
  })
182
361
 
183
- const project = await brain.addNoun("E-commerce Platform", {
184
- type: "project",
185
- status: "active"
362
+ const project = await brain.addNoun("E-commerce Platform", 'project', {
363
+ type: "project",
364
+ status: "active"
186
365
  })
187
366
 
188
367
  // Create knowledge graph
189
- await brain.addVerb(author, apiGuide, "authored", {
190
- date: "2024-03-15"
368
+ await brain.addVerb(author, apiGuide, "authored", {
369
+ date: "2024-03-15"
191
370
  })
192
- await brain.addVerb(apiGuide, project, "documents", {
193
- coverage: "complete"
371
+ await brain.addVerb(apiGuide, project, "documents", {
372
+ coverage: "complete"
194
373
  })
195
374
 
196
375
  // Query the knowledge graph naturally
@@ -198,31 +377,33 @@ const docs = await brain.find("documentation authored by tech leads for active p
198
377
  ```
199
378
 
200
379
  ### Semantic Search
380
+
201
381
  ```javascript
202
382
  // Find similar content
203
383
  const similar = await brain.search(existingContent, {
204
- limit: 5,
205
- threshold: 0.8
384
+ limit: 5,
385
+ threshold: 0.8
206
386
  })
207
387
  ```
208
388
 
209
389
  ### AI Memory Layer with Context
390
+
210
391
  ```javascript
211
392
  // Store conversation with relationships
212
- const userId = await brain.addNoun("User 123", {
213
- type: "user",
214
- tier: "premium"
393
+ const userId = await brain.addNoun("User 123", 'user', {
394
+ type: "user",
395
+ tier: "premium"
215
396
  })
216
397
 
217
- const messageId = await brain.addNoun(userMessage, {
218
- type: "message",
219
- timestamp: Date.now(),
220
- session: "abc"
398
+ const messageId = await brain.addNoun(userMessage, 'message', {
399
+ type: "message",
400
+ timestamp: Date.now(),
401
+ session: "abc"
221
402
  })
222
403
 
223
- const topicId = await brain.addNoun("Product Support", {
224
- type: "topic",
225
- category: "support"
404
+ const topicId = await brain.addNoun("Product Support", 'topic', {
405
+ type: "topic",
406
+ category: "support"
226
407
  })
227
408
 
228
409
  // Link conversation elements
@@ -231,9 +412,9 @@ await brain.addVerb(messageId, topicId, "about")
231
412
 
232
413
  // Retrieve context with relationships
233
414
  const context = await brain.find({
234
- where: { type: "message" },
235
- connected: { from: userId, type: "sent" },
236
- like: "previous product issues"
415
+ where: {type: "message"},
416
+ connected: {from: userId, type: "sent"},
417
+ like: "previous product issues"
237
418
  })
238
419
  ```
239
420
 
@@ -243,30 +424,30 @@ Brainy supports multiple storage backends:
243
424
 
244
425
  ```javascript
245
426
  // Memory (default for testing)
246
- const brain = new BrainyData({
247
- storage: { type: 'memory' }
427
+ const brain = new Brainy({
428
+ storage: {type: 'memory'}
248
429
  })
249
430
 
250
431
  // FileSystem (Node.js)
251
- const brain = new BrainyData({
252
- storage: {
253
- type: 'filesystem',
254
- path: './data'
255
- }
432
+ const brain = new Brainy({
433
+ storage: {
434
+ type: 'filesystem',
435
+ path: './data'
436
+ }
256
437
  })
257
438
 
258
439
  // Browser Storage (OPFS)
259
- const brain = new BrainyData({
260
- storage: { type: 'opfs' }
440
+ const brain = new Brainy({
441
+ storage: {type: 'opfs'}
261
442
  })
262
443
 
263
444
  // S3 Compatible (Production)
264
- const brain = new BrainyData({
265
- storage: {
266
- type: 's3',
267
- bucket: 'my-bucket',
268
- region: 'us-east-1'
269
- }
445
+ const brain = new Brainy({
446
+ storage: {
447
+ type: 's3',
448
+ bucket: 'my-bucket',
449
+ region: 'us-east-1'
450
+ }
270
451
  })
271
452
  ```
272
453
 
@@ -294,6 +475,68 @@ brainy chat
294
475
  brainy export --format json > backup.json
295
476
  ```
296
477
 
478
+ ## 🧠 Neural API - Advanced AI Features
479
+
480
+ Brainy includes a powerful Neural API for advanced semantic analysis:
481
+
482
+ ### Clustering & Analysis
483
+
484
+ ```javascript
485
+ // Access via brain.neural
486
+ const neural = brain.neural
487
+
488
+ // Automatic semantic clustering
489
+ const clusters = await neural.clusters()
490
+ // Returns groups of semantically similar items
491
+
492
+ // Cluster with options
493
+ const clusters = await neural.clusters({
494
+ algorithm: 'kmeans', // or 'hierarchical', 'sample'
495
+ maxClusters: 5, // Maximum number of clusters
496
+ threshold: 0.8 // Similarity threshold
497
+ })
498
+
499
+ // Calculate similarity between any items
500
+ const similarity = await neural.similar('item1', 'item2')
501
+ // Returns 0-1 score
502
+
503
+ // Find nearest neighbors
504
+ const neighbors = await neural.neighbors('item-id', 10)
505
+
506
+ // Build semantic hierarchy
507
+ const hierarchy = await neural.hierarchy('item-id')
508
+
509
+ // Detect outliers
510
+ const outliers = await neural.outliers(0.3)
511
+
512
+ // Generate visualization data for D3/Cytoscape
513
+ const vizData = await neural.visualize({
514
+ maxNodes: 100,
515
+ dimensions: 3,
516
+ algorithm: 'force'
517
+ })
518
+ ```
519
+
520
+ ### Real-World Examples
521
+
522
+ ```javascript
523
+ // Group customer feedback into themes
524
+ const feedbackClusters = await neural.clusters()
525
+ for (const cluster of feedbackClusters) {
526
+ console.log(`Theme: ${cluster.label}`)
527
+ console.log(`Items: ${cluster.members.length}`)
528
+ }
529
+
530
+ // Find related documents
531
+ const docId = await brain.addNoun("Machine learning guide", 'document')
532
+ const similar = await neural.neighbors(docId, 5)
533
+ // Returns 5 most similar documents
534
+
535
+ // Detect anomalies in data
536
+ const anomalies = await neural.outliers(0.2)
537
+ console.log(`Found ${anomalies.length} outliers`)
538
+ ```
539
+
297
540
  ## πŸ”Œ Augmentations
298
541
 
299
542
  Extend Brainy with powerful augmentations:
@@ -314,32 +557,30 @@ brainy cloud setup
314
557
  Brainy includes enterprise-grade capabilities at no extra cost. **No premium tiers, no paywalls.**
315
558
 
316
559
  - **Scales to 10M+ items** with consistent 3ms search latency
317
- - **Write-Ahead Logging (WAL)** for zero data loss durability
318
560
  - **Distributed architecture** with sharding and replication
319
561
  - **Read/write separation** for horizontal scaling
320
562
  - **Connection pooling** and request deduplication
321
563
  - **Built-in monitoring** with metrics and health checks
322
564
  - **Production ready** with circuit breakers and backpressure
323
565
 
324
- πŸ“– **[Read the full Enterprise Features guide β†’](docs/ENTERPRISE-FEATURES.md)**
566
+ πŸ“– **Enterprise features coming in Brainy 3.1** - Stay tuned!
325
567
 
326
568
  ## πŸ“Š Benchmarks
327
569
 
328
- | Operation | Performance | Memory |
329
- |-----------|------------|--------|
330
- | Initialize | 450ms | 24MB |
331
- | Add Item | 12ms | +0.1MB |
332
- | Vector Search (1k items) | 3ms | - |
333
- | Metadata Filter (10k items) | 0.8ms | - |
334
- | Natural Language Query | 15ms | - |
335
- | Bulk Import (1000 items) | 2.3s | +8MB |
336
- | **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** |
337
579
 
338
- ## πŸ”„ Migration from 1.x
580
+ ## πŸ”„ Migration from 2.x
339
581
 
340
- See [MIGRATION.md](MIGRATION.md) for detailed upgrade instructions.
582
+ Key changes for upgrading to 3.0:
341
583
 
342
- Key changes:
343
584
  - Search methods consolidated into `search()` and `find()`
344
585
  - Result format now includes full objects with metadata
345
586
  - New natural language capabilities
@@ -353,8 +594,9 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
353
594
  ### How We Achieved The Impossible
354
595
 
355
596
  **Triple Intelligenceβ„’** makes us the **world's first** to unify three database paradigms:
597
+
356
598
  1. **Vector databases** (Pinecone, Weaviate) - semantic similarity
357
- 2. **Graph databases** (Neo4j, ArangoDB) - relationships
599
+ 2. **Graph databases** (Neo4j, ArangoDB) - relationships
358
600
  3. **Document databases** (MongoDB, Elasticsearch) - metadata filtering
359
601
 
360
602
  **One API to rule them all.** Others make you choose. We unified them.
@@ -373,6 +615,7 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
373
615
  ### Why This Changes Everything
374
616
 
375
617
  **Like HTTP for the web, Brainy for knowledge:**
618
+
376
619
  - All augmentations compose perfectly - same noun-verb language
377
620
  - All AI models share knowledge - GPT, Claude, Llama all understand
378
621
  - All tools integrate seamlessly - no translation layers