@soulcraft/brainy 3.0.0 β†’ 3.1.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 (270) hide show
  1. package/CHANGELOG.md +53 -3
  2. package/README.md +427 -111
  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 +277 -0
  90. package/dist/brainy.js +1241 -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/config/distributedPresets-new.d.ts +118 -0
  96. package/dist/config/distributedPresets-new.js +318 -0
  97. package/dist/config/distributedPresets.d.ts +118 -0
  98. package/dist/config/distributedPresets.js +318 -0
  99. package/dist/config/extensibleConfig.d.ts +99 -0
  100. package/dist/config/extensibleConfig.js +268 -0
  101. package/dist/config/index.d.ts +17 -0
  102. package/dist/config/index.js +35 -0
  103. package/dist/config/modelAutoConfig.d.ts +32 -0
  104. package/dist/config/modelAutoConfig.js +139 -0
  105. package/dist/config/modelPrecisionManager.d.ts +42 -0
  106. package/dist/config/modelPrecisionManager.js +98 -0
  107. package/dist/config/sharedConfigManager.d.ts +67 -0
  108. package/dist/config/sharedConfigManager.js +215 -0
  109. package/dist/config/storageAutoConfig.d.ts +41 -0
  110. package/dist/config/storageAutoConfig.js +328 -0
  111. package/dist/config/zeroConfig.d.ts +68 -0
  112. package/dist/config/zeroConfig.js +301 -0
  113. package/dist/cortex/backupRestore.d.ts +2 -2
  114. package/dist/cortex/backupRestore.js +85 -27
  115. package/dist/cortex/healthCheck.d.ts +2 -2
  116. package/dist/cortex/neuralImport.d.ts +2 -2
  117. package/dist/cortex/neuralImport.js +18 -13
  118. package/dist/cortex/performanceMonitor.d.ts +2 -2
  119. package/dist/critical/model-guardian.d.ts +4 -0
  120. package/dist/critical/model-guardian.js +31 -11
  121. package/dist/demo.d.ts +4 -4
  122. package/dist/demo.js +7 -7
  123. package/dist/distributed/cacheSync.d.ts +112 -0
  124. package/dist/distributed/cacheSync.js +265 -0
  125. package/dist/distributed/coordinator.d.ts +193 -0
  126. package/dist/distributed/coordinator.js +548 -0
  127. package/dist/distributed/httpTransport.d.ts +120 -0
  128. package/dist/distributed/httpTransport.js +446 -0
  129. package/dist/distributed/index.d.ts +8 -0
  130. package/dist/distributed/index.js +5 -0
  131. package/dist/distributed/networkTransport.d.ts +132 -0
  132. package/dist/distributed/networkTransport.js +633 -0
  133. package/dist/distributed/queryPlanner.d.ts +104 -0
  134. package/dist/distributed/queryPlanner.js +327 -0
  135. package/dist/distributed/readWriteSeparation.d.ts +134 -0
  136. package/dist/distributed/readWriteSeparation.js +350 -0
  137. package/dist/distributed/shardManager.d.ts +114 -0
  138. package/dist/distributed/shardManager.js +357 -0
  139. package/dist/distributed/shardMigration.d.ts +110 -0
  140. package/dist/distributed/shardMigration.js +289 -0
  141. package/dist/distributed/storageDiscovery.d.ts +160 -0
  142. package/dist/distributed/storageDiscovery.js +551 -0
  143. package/dist/embeddings/CachedEmbeddings.d.ts +40 -0
  144. package/dist/embeddings/CachedEmbeddings.js +146 -0
  145. package/dist/embeddings/EmbeddingManager.d.ts +102 -0
  146. package/dist/embeddings/EmbeddingManager.js +291 -0
  147. package/dist/embeddings/SingletonModelManager.d.ts +95 -0
  148. package/dist/embeddings/SingletonModelManager.js +220 -0
  149. package/dist/embeddings/index.d.ts +12 -0
  150. package/dist/embeddings/index.js +16 -0
  151. package/dist/embeddings/lightweight-embedder.d.ts +0 -1
  152. package/dist/embeddings/lightweight-embedder.js +4 -12
  153. package/dist/embeddings/model-manager.d.ts +11 -0
  154. package/dist/embeddings/model-manager.js +43 -7
  155. package/dist/embeddings/universal-memory-manager.d.ts +1 -1
  156. package/dist/embeddings/universal-memory-manager.js +27 -67
  157. package/dist/embeddings/worker-embedding.js +4 -8
  158. package/dist/errors/brainyError.d.ts +5 -1
  159. package/dist/errors/brainyError.js +12 -0
  160. package/dist/examples/basicUsage.js +7 -4
  161. package/dist/graph/graphAdjacencyIndex.d.ts +96 -0
  162. package/dist/graph/graphAdjacencyIndex.js +288 -0
  163. package/dist/graph/pathfinding.js +4 -2
  164. package/dist/hnsw/scaledHNSWSystem.js +11 -2
  165. package/dist/importManager.js +8 -5
  166. package/dist/index.d.ts +17 -22
  167. package/dist/index.js +37 -23
  168. package/dist/mcp/brainyMCPAdapter.d.ts +4 -4
  169. package/dist/mcp/brainyMCPAdapter.js +5 -5
  170. package/dist/mcp/brainyMCPService.d.ts +3 -3
  171. package/dist/mcp/brainyMCPService.js +3 -11
  172. package/dist/mcp/mcpAugmentationToolset.js +20 -30
  173. package/dist/neural/embeddedPatterns.d.ts +1 -1
  174. package/dist/neural/embeddedPatterns.js +2 -2
  175. package/dist/neural/entityExtractor.d.ts +65 -0
  176. package/dist/neural/entityExtractor.js +316 -0
  177. package/dist/neural/improvedNeuralAPI.d.ts +357 -0
  178. package/dist/neural/improvedNeuralAPI.js +2628 -0
  179. package/dist/neural/naturalLanguageProcessor.d.ts +155 -10
  180. package/dist/neural/naturalLanguageProcessor.js +941 -66
  181. package/dist/neural/naturalLanguageProcessorStatic.d.ts +2 -2
  182. package/dist/neural/naturalLanguageProcessorStatic.js +3 -3
  183. package/dist/neural/neuralAPI.js +8 -2
  184. package/dist/neural/patternLibrary.d.ts +57 -3
  185. package/dist/neural/patternLibrary.js +348 -13
  186. package/dist/neural/staticPatternMatcher.d.ts +2 -2
  187. package/dist/neural/staticPatternMatcher.js +2 -2
  188. package/dist/neural/types.d.ts +287 -0
  189. package/dist/neural/types.js +24 -0
  190. package/dist/shared/default-augmentations.d.ts +3 -3
  191. package/dist/shared/default-augmentations.js +5 -5
  192. package/dist/storage/adapters/baseStorageAdapter.d.ts +42 -0
  193. package/dist/storage/adapters/fileSystemStorage.d.ts +26 -2
  194. package/dist/storage/adapters/fileSystemStorage.js +218 -15
  195. package/dist/storage/adapters/memoryStorage.d.ts +4 -4
  196. package/dist/storage/adapters/memoryStorage.js +17 -12
  197. package/dist/storage/adapters/opfsStorage.d.ts +2 -2
  198. package/dist/storage/adapters/opfsStorage.js +2 -2
  199. package/dist/storage/adapters/s3CompatibleStorage.d.ts +2 -2
  200. package/dist/storage/adapters/s3CompatibleStorage.js +2 -2
  201. package/dist/storage/backwardCompatibility.d.ts +10 -78
  202. package/dist/storage/backwardCompatibility.js +17 -132
  203. package/dist/storage/baseStorage.d.ts +18 -2
  204. package/dist/storage/baseStorage.js +74 -3
  205. package/dist/storage/cacheManager.js +2 -2
  206. package/dist/storage/readOnlyOptimizations.js +8 -3
  207. package/dist/streaming/pipeline.d.ts +154 -0
  208. package/dist/streaming/pipeline.js +551 -0
  209. package/dist/triple/TripleIntelligence.d.ts +25 -110
  210. package/dist/triple/TripleIntelligence.js +4 -574
  211. package/dist/triple/TripleIntelligenceSystem.d.ts +159 -0
  212. package/dist/triple/TripleIntelligenceSystem.js +519 -0
  213. package/dist/types/apiTypes.d.ts +278 -0
  214. package/dist/types/apiTypes.js +33 -0
  215. package/dist/types/brainy.types.d.ts +308 -0
  216. package/dist/types/brainy.types.js +8 -0
  217. package/dist/types/brainyDataInterface.d.ts +5 -8
  218. package/dist/types/brainyDataInterface.js +2 -2
  219. package/dist/types/graphTypes.js +2 -2
  220. package/dist/universal/crypto.d.ts +11 -1
  221. package/dist/universal/crypto.js +24 -93
  222. package/dist/universal/events.d.ts +3 -2
  223. package/dist/universal/events.js +6 -75
  224. package/dist/universal/fs.d.ts +2 -3
  225. package/dist/universal/fs.js +5 -211
  226. package/dist/universal/path.d.ts +3 -2
  227. package/dist/universal/path.js +22 -78
  228. package/dist/universal/uuid.d.ts +1 -1
  229. package/dist/universal/uuid.js +1 -1
  230. package/dist/utils/brainyTypes.d.ts +217 -0
  231. package/dist/utils/brainyTypes.js +261 -0
  232. package/dist/utils/cacheAutoConfig.d.ts +3 -3
  233. package/dist/utils/embedding.d.ts +9 -4
  234. package/dist/utils/embedding.js +89 -26
  235. package/dist/utils/enhancedLogger.d.ts +104 -0
  236. package/dist/utils/enhancedLogger.js +232 -0
  237. package/dist/utils/hybridModelManager.d.ts +19 -28
  238. package/dist/utils/hybridModelManager.js +36 -200
  239. package/dist/utils/index.d.ts +1 -1
  240. package/dist/utils/index.js +1 -1
  241. package/dist/utils/intelligentTypeMapper.d.ts +60 -0
  242. package/dist/utils/intelligentTypeMapper.js +349 -0
  243. package/dist/utils/metadataIndex.d.ts +118 -1
  244. package/dist/utils/metadataIndex.js +539 -16
  245. package/dist/utils/nodeVersionCheck.d.ts +24 -0
  246. package/dist/utils/nodeVersionCheck.js +65 -0
  247. package/dist/utils/paramValidation.d.ts +39 -0
  248. package/dist/utils/paramValidation.js +192 -0
  249. package/dist/utils/rateLimiter.d.ts +160 -0
  250. package/dist/utils/rateLimiter.js +271 -0
  251. package/dist/utils/statistics.d.ts +4 -4
  252. package/dist/utils/statistics.js +3 -3
  253. package/dist/utils/structuredLogger.d.ts +146 -0
  254. package/dist/utils/structuredLogger.js +394 -0
  255. package/dist/utils/textEncoding.js +2 -1
  256. package/dist/utils/typeValidation.d.ts +59 -0
  257. package/dist/utils/typeValidation.js +374 -0
  258. package/dist/utils/version.js +19 -3
  259. package/package.json +15 -17
  260. package/scripts/download-models.cjs +94 -20
  261. package/dist/augmentations/walAugmentation.d.ts +0 -109
  262. package/dist/augmentations/walAugmentation.js +0 -516
  263. package/dist/browserFramework.d.ts +0 -15
  264. package/dist/browserFramework.js +0 -31
  265. package/dist/browserFramework.minimal.d.ts +0 -14
  266. package/dist/browserFramework.minimal.js +0 -31
  267. package/dist/chat/BrainyChat.d.ts +0 -121
  268. package/dist/chat/BrainyChat.js +0 -396
  269. package/dist/chat/ChatCLI.d.ts +0 -61
  270. package/dist/chat/ChatCLI.js +0 -351
package/README.md CHANGED
@@ -9,72 +9,181 @@
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. **Framework-friendly design** works seamlessly with Next.js, React, Vue, Angular, and any modern JavaScript framework.
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
+ **Framework-first design.** Built for modern web development with zero configuration and automatic framework compatibility. 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
+ ## 🌐 Framework Integration
102
+
103
+ **Brainy 3.0 is framework-first!** Works seamlessly with any modern JavaScript framework:
104
+
105
+ ### βš›οΈ **React & Next.js**
106
+ ```javascript
107
+ import { Brainy } from '@soulcraft/brainy'
108
+
109
+ function SearchComponent() {
110
+ const [brain] = useState(() => new Brainy())
111
+
112
+ useEffect(() => {
113
+ brain.init()
114
+ }, [])
115
+
116
+ const handleSearch = async (query) => {
117
+ const results = await brain.find(query)
118
+ setResults(results)
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### 🟒 **Vue.js & Nuxt.js**
124
+ ```javascript
125
+ import { Brainy } from '@soulcraft/brainy'
126
+
127
+ export default {
128
+ async mounted() {
129
+ this.brain = new Brainy()
130
+ await this.brain.init()
131
+ },
132
+ methods: {
133
+ async search(query) {
134
+ return await this.brain.find(query)
135
+ }
136
+ }
137
+ }
138
+ ```
139
+
140
+ ### πŸ…°οΈ **Angular**
141
+ ```typescript
142
+ import { Injectable } from '@angular/core'
143
+ import { Brainy } from '@soulcraft/brainy'
144
+
145
+ @Injectable({ providedIn: 'root' })
146
+ export class BrainyService {
147
+ private brain = new Brainy()
148
+
149
+ async init() {
150
+ await this.brain.init()
151
+ }
152
+
153
+ async search(query: string) {
154
+ return await this.brain.find(query)
155
+ }
156
+ }
157
+ ```
158
+
159
+ ### πŸ”₯ **Other Frameworks**
160
+ Brainy works with **any** framework that supports ES6 imports: Svelte, Solid.js, Qwik, Fresh, and more!
161
+
162
+ **Framework Compatibility:**
163
+ - βœ… All modern bundlers (Webpack, Vite, Rollup, Parcel)
164
+ - βœ… SSR/SSG (Next.js, Nuxt, SvelteKit, Astro)
165
+ - βœ… Edge runtimes (Vercel Edge, Cloudflare Workers)
166
+ - βœ… Browser and Node.js environments
167
+
168
+ ## πŸ“‹ System Requirements
169
+
170
+ **Node.js Version:** 22 LTS or later (recommended)
171
+
172
+ - βœ… **Node.js 22 LTS** - Fully supported and recommended for production
173
+ - βœ… **Node.js 20 LTS** - Compatible (maintenance mode)
174
+ - ❌ **Node.js 24** - Not supported (known ONNX runtime compatibility issues)
175
+
176
+ > **Important:** Brainy uses ONNX runtime for AI embeddings. Node.js 24 has known compatibility issues that cause
177
+ > crashes during inference operations. We recommend Node.js 22 LTS for maximum stability.
178
+
179
+ If using nvm: `nvm use` (we provide a `.nvmrc` file)
180
+
74
181
  ## πŸš€ Key Features
75
182
 
76
183
  ### World's First Triple Intelligenceβ„’ Engine
184
+
77
185
  **The breakthrough that enables the Universal Knowledge Protocol:**
186
+
78
187
  - **Vector Search**: Semantic similarity with HNSW indexing
79
188
  - **Graph Relationships**: Navigate connected knowledge like Neo4j
80
189
  - **Document Filtering**: MongoDB-style queries with O(log n) performance
@@ -82,7 +191,9 @@ const filtered = await brain.find({
82
191
  - **First to solve this**: Others do vector OR graph OR documentβ€”we do ALL
83
192
 
84
193
  ### Universal Knowledge Protocol with Infinite Expressiveness
194
+
85
195
  **Enabled by Triple Intelligence, standardized for everyone:**
196
+
86
197
  - **24 Noun Types Γ— 40 Verb Types**: 960 base combinations
87
198
  - **∞ Expressiveness**: Unlimited metadata = model ANY data
88
199
  - **One Language**: All tools, augmentations, AI models speak the same types
@@ -90,6 +201,7 @@ const filtered = await brain.find({
90
201
  - **No Schema Lock-in**: Evolve without migrations
91
202
 
92
203
  ### Natural Language Understanding
204
+
93
205
  ```javascript
94
206
  // Ask questions naturally
95
207
  await brain.find("Show me recent React components with tests")
@@ -97,54 +209,118 @@ await brain.find("Popular JavaScript libraries similar to Vue")
97
209
  await brain.find("Documentation about authentication from last month")
98
210
  ```
99
211
 
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
212
+ ### 🎯 Zero Configuration Philosophy
213
+
214
+ Brainy 3.0 automatically configures **everything**:
215
+
216
+ ```javascript
217
+ import {Brainy} from '@soulcraft/brainy'
218
+
219
+ // 1. Pure zero-config - detects everything
220
+ const brain = new Brainy()
221
+
222
+ // 2. Custom configuration
223
+ const brain = new Brainy({
224
+ storage: { type: 'memory' },
225
+ embeddings: { model: 'all-MiniLM-L6-v2' },
226
+ cache: { enabled: true, maxSize: 1000 }
227
+ })
228
+
229
+ // 3. Production configuration
230
+ const customBrain = new Brainy({
231
+ mode: 'production',
232
+ model: 'q8', // Optimized model (99% accuracy, 75% smaller)
233
+ storage: 'cloud', // or 'memory', 'disk', 'auto'
234
+ features: ['core', 'search', 'cache']
235
+ })
236
+ ```
237
+
238
+ **What's Auto-Detected:**
239
+
240
+ - **Storage**: S3/GCS/R2 β†’ Filesystem β†’ Memory (priority order)
241
+ - **Models**: Always Q8 for optimal balance
242
+ - **Features**: Minimal β†’ Default β†’ Full based on environment
243
+ - **Memory**: Optimal cache sizes and batching
244
+ - **Performance**: Threading, chunking, indexing strategies
105
245
 
106
246
  ### Production Performance
247
+
107
248
  - **3ms average search** - Lightning fast queries
108
249
  - **24MB memory footprint** - Efficient resource usage
109
250
  - **Worker-based embeddings** - Non-blocking operations
110
251
  - **Automatic caching** - Intelligent result caching
111
252
 
253
+ ### πŸŽ›οΈ Advanced Configuration (When Needed)
254
+
255
+ Most users **never need this** - zero-config handles everything. For advanced use cases:
256
+
257
+ ```javascript
258
+ // Model is always Q8 for optimal performance
259
+ const brain = new Brainy() // Uses Q8 automatically
260
+
261
+ // Storage control (auto-detected by default)
262
+ const memoryBrain = new Brainy({storage: 'memory'}) // RAM only
263
+ const diskBrain = new Brainy({storage: 'disk'}) // Local filesystem
264
+ const cloudBrain = new Brainy({storage: 'cloud'}) // S3/GCS/R2
265
+
266
+ // Legacy full config (still supported)
267
+ const legacyBrain = new Brainy({
268
+ storage: {forceMemoryStorage: true}
269
+ })
270
+ ```
271
+
272
+ **Model Details:**
273
+
274
+ - **Q8**: 33MB, 99% accuracy, 75% smaller than full precision
275
+ - Fast loading and optimal memory usage
276
+ - Perfect for all environments
277
+
278
+ **Air-gap deployment:**
279
+
280
+ ```bash
281
+ npm run download-models # Download Q8 model
282
+ npm run download-models:q8 # Download Q8 model
283
+ ```
284
+
112
285
  ## πŸ“š Core API
113
286
 
114
287
  ### `search()` - Vector Similarity
288
+
115
289
  ```javascript
116
290
  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
291
+ limit: 10, // Number of results
292
+ metadata: {type: "article"}, // Filter by metadata
293
+ includeContent: true // Include full content
120
294
  })
121
295
  ```
122
296
 
123
297
  ### `find()` - Natural Language Queries
298
+
124
299
  ```javascript
125
300
  // Simple natural language
126
301
  const results = await brain.find("recent important documents")
127
302
 
128
303
  // Structured query with Triple Intelligence
129
304
  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
305
+ like: "JavaScript", // Vector similarity
306
+ where: { // Metadata filters
307
+ year: {greaterThan: 2020},
308
+ important: true
309
+ },
310
+ related: {to: "React"} // Graph relationships
136
311
  })
137
312
  ```
138
313
 
139
314
  ### CRUD Operations
315
+
140
316
  ```javascript
141
317
  // Create entities (nouns)
142
- const id = await brain.addNoun(data, metadata)
318
+ const id = await brain.addNoun(data, nounType, metadata)
143
319
 
144
320
  // Create relationships (verbs)
145
321
  const verbId = await brain.addVerb(sourceId, targetId, "relationType", {
146
- strength: 0.9,
147
- bidirectional: false
322
+ strength: 0.9,
323
+ bidirectional: false
148
324
  })
149
325
 
150
326
  // Read
@@ -161,36 +337,106 @@ await brain.deleteVerb(verbId)
161
337
 
162
338
  // Bulk operations
163
339
  await brain.import(arrayOfData)
164
- const exported = await brain.export({ format: 'json' })
340
+ const exported = await brain.export({format: 'json'})
341
+ ```
342
+
343
+ ## 🌐 Distributed System (NEW!)
344
+
345
+ ### Zero-Config Distributed Setup
346
+
347
+ ```javascript
348
+ // Single node (default)
349
+ const brain = new Brainy({
350
+ storage: {type: 's3', options: {bucket: 'my-data'}}
351
+ })
352
+
353
+ // Distributed cluster - just add one flag!
354
+ const brain = new Brainy({
355
+ storage: {type: 's3', options: {bucket: 'my-data'}},
356
+ distributed: true // That's it! Everything else is automatic
357
+ })
358
+ ```
359
+
360
+ ### How It Works
361
+
362
+ - **Storage-Based Discovery**: Nodes find each other via S3/GCS (no Consul/etcd!)
363
+ - **Automatic Sharding**: Data distributed by content hash
364
+ - **Smart Query Planning**: Queries routed to optimal shards
365
+ - **Live Rebalancing**: Handles node joins/leaves automatically
366
+ - **Zero Downtime**: Streaming shard migration
367
+
368
+ ### Real-World Example: Social Media Firehose
369
+
370
+ ```javascript
371
+ // Ingestion nodes (optimized for writes)
372
+ const ingestionNode = new Brainy({
373
+ storage: {type: 's3', options: {bucket: 'social-data'}},
374
+ distributed: true,
375
+ writeOnly: true // Optimized for high-throughput writes
376
+ })
377
+
378
+ // Process Bluesky firehose
379
+ blueskyStream.on('post', async (post) => {
380
+ await ingestionNode.addNoun(post, 'social-post', {
381
+ platform: 'bluesky',
382
+ author: post.author,
383
+ timestamp: post.createdAt
384
+ })
385
+ })
386
+
387
+ // Search nodes (optimized for queries)
388
+ const searchNode = new Brainy({
389
+ storage: {type: 's3', options: {bucket: 'social-data'}},
390
+ distributed: true,
391
+ readOnly: true // Optimized for fast queries
392
+ })
393
+
394
+ // Search across ALL data from ALL nodes
395
+ const trending = await searchNode.find('trending AI topics', {
396
+ where: {timestamp: {greaterThan: Date.now() - 3600000}},
397
+ limit: 100
398
+ })
165
399
  ```
166
400
 
401
+ ### Benefits Over Traditional Systems
402
+
403
+ | Feature | Traditional (Pinecone, Weaviate) | Brainy Distributed |
404
+ |----------------|----------------------------------|-------------------------------|
405
+ | Setup | Complex (k8s, operators) | One flag: `distributed: true` |
406
+ | Coordination | External (etcd, Consul) | Built-in (via storage) |
407
+ | Minimum Nodes | 3-5 for HA | 1 (scale as needed) |
408
+ | Sharding | Random | Domain-aware |
409
+ | Query Planning | Basic | Triple Intelligence |
410
+ | Cost | High (always-on clusters) | Low (scale to zero) |
411
+
167
412
  ## 🎯 Use Cases
168
413
 
169
414
  ### Knowledge Management with Relationships
415
+
170
416
  ```javascript
171
417
  // 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"
418
+ const apiGuide = await brain.addNoun("REST API Guide", 'document', {
419
+ title: "API Guide",
420
+ category: "documentation",
421
+ version: "2.0"
176
422
  })
177
423
 
178
- const author = await brain.addNoun("Jane Developer", {
179
- type: "person",
180
- role: "tech-lead"
424
+ const author = await brain.addNoun("Jane Developer", 'person', {
425
+ type: "person",
426
+ role: "tech-lead"
181
427
  })
182
428
 
183
- const project = await brain.addNoun("E-commerce Platform", {
184
- type: "project",
185
- status: "active"
429
+ const project = await brain.addNoun("E-commerce Platform", 'project', {
430
+ type: "project",
431
+ status: "active"
186
432
  })
187
433
 
188
434
  // Create knowledge graph
189
- await brain.addVerb(author, apiGuide, "authored", {
190
- date: "2024-03-15"
435
+ await brain.addVerb(author, apiGuide, "authored", {
436
+ date: "2024-03-15"
191
437
  })
192
- await brain.addVerb(apiGuide, project, "documents", {
193
- coverage: "complete"
438
+ await brain.addVerb(apiGuide, project, "documents", {
439
+ coverage: "complete"
194
440
  })
195
441
 
196
442
  // Query the knowledge graph naturally
@@ -198,31 +444,33 @@ const docs = await brain.find("documentation authored by tech leads for active p
198
444
  ```
199
445
 
200
446
  ### Semantic Search
447
+
201
448
  ```javascript
202
449
  // Find similar content
203
450
  const similar = await brain.search(existingContent, {
204
- limit: 5,
205
- threshold: 0.8
451
+ limit: 5,
452
+ threshold: 0.8
206
453
  })
207
454
  ```
208
455
 
209
456
  ### AI Memory Layer with Context
457
+
210
458
  ```javascript
211
459
  // Store conversation with relationships
212
- const userId = await brain.addNoun("User 123", {
213
- type: "user",
214
- tier: "premium"
460
+ const userId = await brain.addNoun("User 123", 'user', {
461
+ type: "user",
462
+ tier: "premium"
215
463
  })
216
464
 
217
- const messageId = await brain.addNoun(userMessage, {
218
- type: "message",
219
- timestamp: Date.now(),
220
- session: "abc"
465
+ const messageId = await brain.addNoun(userMessage, 'message', {
466
+ type: "message",
467
+ timestamp: Date.now(),
468
+ session: "abc"
221
469
  })
222
470
 
223
- const topicId = await brain.addNoun("Product Support", {
224
- type: "topic",
225
- category: "support"
471
+ const topicId = await brain.addNoun("Product Support", 'topic', {
472
+ type: "topic",
473
+ category: "support"
226
474
  })
227
475
 
228
476
  // Link conversation elements
@@ -231,9 +479,9 @@ await brain.addVerb(messageId, topicId, "about")
231
479
 
232
480
  // Retrieve context with relationships
233
481
  const context = await brain.find({
234
- where: { type: "message" },
235
- connected: { from: userId, type: "sent" },
236
- like: "previous product issues"
482
+ where: {type: "message"},
483
+ connected: {from: userId, type: "sent"},
484
+ like: "previous product issues"
237
485
  })
238
486
  ```
239
487
 
@@ -243,30 +491,30 @@ Brainy supports multiple storage backends:
243
491
 
244
492
  ```javascript
245
493
  // Memory (default for testing)
246
- const brain = new BrainyData({
247
- storage: { type: 'memory' }
494
+ const brain = new Brainy({
495
+ storage: {type: 'memory'}
248
496
  })
249
497
 
250
498
  // FileSystem (Node.js)
251
- const brain = new BrainyData({
252
- storage: {
253
- type: 'filesystem',
254
- path: './data'
255
- }
499
+ const brain = new Brainy({
500
+ storage: {
501
+ type: 'filesystem',
502
+ path: './data'
503
+ }
256
504
  })
257
505
 
258
- // Browser Storage (OPFS)
259
- const brain = new BrainyData({
260
- storage: { type: 'opfs' }
506
+ // Browser Storage (OPFS) - Works with frameworks
507
+ const brain = new Brainy({
508
+ storage: {type: 'opfs'} // Framework handles browser polyfills
261
509
  })
262
510
 
263
511
  // S3 Compatible (Production)
264
- const brain = new BrainyData({
265
- storage: {
266
- type: 's3',
267
- bucket: 'my-bucket',
268
- region: 'us-east-1'
269
- }
512
+ const brain = new Brainy({
513
+ storage: {
514
+ type: 's3',
515
+ bucket: 'my-bucket',
516
+ region: 'us-east-1'
517
+ }
270
518
  })
271
519
  ```
272
520
 
@@ -294,6 +542,68 @@ brainy chat
294
542
  brainy export --format json > backup.json
295
543
  ```
296
544
 
545
+ ## 🧠 Neural API - Advanced AI Features
546
+
547
+ Brainy includes a powerful Neural API for advanced semantic analysis:
548
+
549
+ ### Clustering & Analysis
550
+
551
+ ```javascript
552
+ // Access via brain.neural
553
+ const neural = brain.neural
554
+
555
+ // Automatic semantic clustering
556
+ const clusters = await neural.clusters()
557
+ // Returns groups of semantically similar items
558
+
559
+ // Cluster with options
560
+ const clusters = await neural.clusters({
561
+ algorithm: 'kmeans', // or 'hierarchical', 'sample'
562
+ maxClusters: 5, // Maximum number of clusters
563
+ threshold: 0.8 // Similarity threshold
564
+ })
565
+
566
+ // Calculate similarity between any items
567
+ const similarity = await neural.similar('item1', 'item2')
568
+ // Returns 0-1 score
569
+
570
+ // Find nearest neighbors
571
+ const neighbors = await neural.neighbors('item-id', 10)
572
+
573
+ // Build semantic hierarchy
574
+ const hierarchy = await neural.hierarchy('item-id')
575
+
576
+ // Detect outliers
577
+ const outliers = await neural.outliers(0.3)
578
+
579
+ // Generate visualization data for D3/Cytoscape
580
+ const vizData = await neural.visualize({
581
+ maxNodes: 100,
582
+ dimensions: 3,
583
+ algorithm: 'force'
584
+ })
585
+ ```
586
+
587
+ ### Real-World Examples
588
+
589
+ ```javascript
590
+ // Group customer feedback into themes
591
+ const feedbackClusters = await neural.clusters()
592
+ for (const cluster of feedbackClusters) {
593
+ console.log(`Theme: ${cluster.label}`)
594
+ console.log(`Items: ${cluster.members.length}`)
595
+ }
596
+
597
+ // Find related documents
598
+ const docId = await brain.addNoun("Machine learning guide", 'document')
599
+ const similar = await neural.neighbors(docId, 5)
600
+ // Returns 5 most similar documents
601
+
602
+ // Detect anomalies in data
603
+ const anomalies = await neural.outliers(0.2)
604
+ console.log(`Found ${anomalies.length} outliers`)
605
+ ```
606
+
297
607
  ## πŸ”Œ Augmentations
298
608
 
299
609
  Extend Brainy with powerful augmentations:
@@ -314,32 +624,30 @@ brainy cloud setup
314
624
  Brainy includes enterprise-grade capabilities at no extra cost. **No premium tiers, no paywalls.**
315
625
 
316
626
  - **Scales to 10M+ items** with consistent 3ms search latency
317
- - **Write-Ahead Logging (WAL)** for zero data loss durability
318
627
  - **Distributed architecture** with sharding and replication
319
628
  - **Read/write separation** for horizontal scaling
320
629
  - **Connection pooling** and request deduplication
321
630
  - **Built-in monitoring** with metrics and health checks
322
631
  - **Production ready** with circuit breakers and backpressure
323
632
 
324
- πŸ“– **[Read the full Enterprise Features guide β†’](docs/ENTERPRISE-FEATURES.md)**
633
+ πŸ“– **Enterprise features coming in Brainy 3.1** - Stay tuned!
325
634
 
326
635
  ## πŸ“Š Benchmarks
327
636
 
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** |
637
+ | Operation | Performance | Memory |
638
+ |----------------------------------|-------------|----------|
639
+ | Initialize | 450ms | 24MB |
640
+ | Add Item | 12ms | +0.1MB |
641
+ | Vector Search (1k items) | 3ms | - |
642
+ | Metadata Filter (10k items) | 0.8ms | - |
643
+ | Natural Language Query | 15ms | - |
644
+ | Bulk Import (1000 items) | 2.3s | +8MB |
645
+ | **Production Scale (10M items)** | **5.8ms** | **12GB** |
337
646
 
338
- ## πŸ”„ Migration from 1.x
647
+ ## πŸ”„ Migration from 2.x
339
648
 
340
- See [MIGRATION.md](MIGRATION.md) for detailed upgrade instructions.
649
+ Key changes for upgrading to 3.0:
341
650
 
342
- Key changes:
343
651
  - Search methods consolidated into `search()` and `find()`
344
652
  - Result format now includes full objects with metadata
345
653
  - New natural language capabilities
@@ -353,8 +661,9 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
353
661
  ### How We Achieved The Impossible
354
662
 
355
663
  **Triple Intelligenceβ„’** makes us the **world's first** to unify three database paradigms:
664
+
356
665
  1. **Vector databases** (Pinecone, Weaviate) - semantic similarity
357
- 2. **Graph databases** (Neo4j, ArangoDB) - relationships
666
+ 2. **Graph databases** (Neo4j, ArangoDB) - relationships
358
667
  3. **Document databases** (MongoDB, Elasticsearch) - metadata filtering
359
668
 
360
669
  **One API to rule them all.** Others make you choose. We unified them.
@@ -373,6 +682,7 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
373
682
  ### Why This Changes Everything
374
683
 
375
684
  **Like HTTP for the web, Brainy for knowledge:**
685
+
376
686
  - All augmentations compose perfectly - same noun-verb language
377
687
  - All AI models share knowledge - GPT, Claude, Llama all understand
378
688
  - All tools integrate seamlessly - no translation layers
@@ -386,6 +696,12 @@ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
386
696
 
387
697
  ## πŸ“– Documentation
388
698
 
699
+ ### Framework Integration
700
+ - [Framework Integration Guide](docs/guides/framework-integration.md) - **NEW!** Complete framework setup guide
701
+ - [Next.js Integration](docs/guides/nextjs-integration.md) - **NEW!** React and Next.js examples
702
+ - [Vue.js Integration](docs/guides/vue-integration.md) - **NEW!** Vue and Nuxt examples
703
+
704
+ ### Core Documentation
389
705
  - [Getting Started Guide](docs/guides/getting-started.md)
390
706
  - [API Reference](docs/api/README.md)
391
707
  - [Architecture Overview](docs/architecture/overview.md)