2025-08-07 19:33:03 -07:00
# 🧠⚛️ Brainy - Lightning-Fast Vector + Graph Database with AI Intelligence
2025-08-06 16:35:14 -07:00
< div align = "center" >
2025-06-24 11:41:30 -07:00
2025-08-07 19:33:03 -07:00

[](https://badge.fury.io/js/%40soulcraft%2Fbrainy)
[](https://opensource.org/licenses/MIT)
**feat(tests, docs, storage): add statistics storage tests and enhance documentation**
- **Tests**: Added new `statistics-storage.test.ts` to validate statistics storage functionality across scenarios including saving, retrieving, time-based partitioning, and backward compatibility. Ensured tests dynamically handle missing environment variables by skipping S3-related tests when credentials are unavailable.
- **Docs**: Enhanced `statistics.md` with detailed explanations of scalability improvements, including adaptive flush timing, batched updates, and time-based partitioning. Improved readability and structure.
- **Storage**: Updated all storage adapters to integrate time-based partitioning and maintain backward compatibility with legacy statistics storage formats.
- **Dependencies**: Added `dotenv` to support environmental variable management for storage adapter tests.
**Purpose**: Strengthen system reliability by adding comprehensive test coverage for statistics storage, improve scalability documentation, and ensure consistency across storage adapters with robust implementations.
2025-07-24 16:24:02 -07:00
[](https://nodejs.org/)
2025-07-04 12:19:48 -07:00
[](https://www.typescriptlang.org/)
2025-06-24 11:41:30 -07:00
2025-08-07 19:33:03 -07:00
**The world's only true Vector + Graph database with built-in AI intelligence**
**Sub-millisecond queries across millions of vectors + billions of relationships**
2025-06-24 11:41:30 -07:00
< / div >
2025-08-07 19:33:03 -07:00
## The Problem: Three Databases for One Search
2025-08-06 14:39:33 -07:00
2025-08-07 19:33:03 -07:00
**"I need semantic search, relationship traversal, AND metadata filtering - that means 3+ databases"**
2025-08-07 13:57:48 -07:00
2025-08-07 19:33:03 -07:00
❌ **Current Reality** : Pinecone + Neo4j + Elasticsearch + Custom Sync = Slow, expensive, complex
✅ **Brainy Reality** : One blazing-fast database. One API. Everything in sync.
2025-08-07 13:57:48 -07:00
2025-08-07 19:33:03 -07:00
## 🚀 Quick Start: 8 Lines to Production
2025-08-07 14:25:35 -07:00
2025-08-07 19:33:03 -07:00
```bash
npm install @soulcraft/brainy
2025-08-07 13:57:48 -07:00
```
2025-08-07 19:33:03 -07:00
```javascript
import { BrainyData } from '@soulcraft/brainy '
2025-08-07 14:25:35 -07:00
2025-08-07 19:33:03 -07:00
const brainy = new BrainyData() // Auto-detects environment
await brainy.init() // Zero configuration
2025-08-07 13:57:48 -07:00
2025-08-07 19:33:03 -07:00
// Add data with relationships
const openai = await brainy.add("OpenAI", { type: "company", funding: 11000000 })
const gpt4 = await brainy.add("GPT-4", { type: "product", users: 100000000 })
await brainy.relate(openai, gpt4, "develops")
2025-08-07 13:57:48 -07:00
2025-08-07 19:33:03 -07:00
// One query, three search paradigms
const results = await brainy.search("AI language models", 5, {
metadata: { funding: { $gte: 10000000 } }, // MongoDB-style filtering
includeVerbs: true // Graph relationships
}) // Semantic vector search
```
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
**That's it. You just built a knowledge graph with semantic search in 8 lines.**
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
## 🎯 Key Features: Why Developers Choose Brainy
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
### ⚡ Blazing Performance at Scale
2025-08-07 13:53:17 -07:00
```
2025-08-07 19:33:03 -07:00
Vector Search (1M embeddings): 2-8ms p95 latency
Graph Traversal (100M relations): 1-3ms p95 latency
Combined Vector+Graph+Filter: 5-15ms p95 latency
Throughput: 10K+ queries/second
```
### 🌍 Write Once, Run Anywhere
- **Same code** works in React, Vue, Angular, Node.js, Edge Workers
- **Auto-detects** environment and optimizes automatically
- **Zero config** - no setup files, no tuning parameters
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
### 🧠 Built-in AI Intelligence (FREE)
- **Neural Import**: AI understands your data structure automatically
- **Entity Detection**: Identifies people, companies, locations
- **Relationship Mapping**: Discovers connections between entities
- **Chat Interface**: Talk to your data naturally (v0.56+)
2025-08-07 13:53:17 -07:00
---
2025-08-07 19:33:03 -07:00
# 🎆 NEW: Talk to Your Data with Brainy Chat!
2025-08-06 14:39:33 -07:00
2025-08-07 19:33:03 -07:00
```javascript
import { BrainyChat } from '@soulcraft/brainy '
const chat = new BrainyChat(brainy) // That's it!
const answer = await chat.ask("What patterns do you see in customer behavior?")
// → Works instantly with zero config!
```
2025-08-05 19:29:59 -07:00
2025-08-07 19:33:03 -07:00
**One line. Zero complexity. Optional LLM for smarter responses.**
[📖 **Learn More About Brainy Chat** ](BRAINY-CHAT.md )
2025-08-05 19:29:59 -07:00
2025-08-06 16:26:39 -07:00
## 🔥 The Power of Three-in-One Search
2025-08-05 19:29:59 -07:00
2025-08-06 12:29:32 -07:00
```javascript
2025-08-06 16:26:39 -07:00
// This ONE query does what used to require 3 databases:
const results = await brainy.search("AI startups in healthcare", 10, {
// 🔍 Vector: Semantic similarity
includeVerbs: true,
// 🔗 Graph: Relationship traversal
verbTypes: ["invests_in", "partners_with"],
// 📊 Faceted: MongoDB-style filtering
2025-08-06 12:29:32 -07:00
metadata: {
2025-08-06 16:26:39 -07:00
industry: "healthcare",
funding: { $gte: 1000000 },
stage: { $in: ["Series A", "Series B"] }
2025-08-06 12:29:32 -07:00
}
})
2025-08-06 16:26:39 -07:00
// Returns: Companies similar to your query + their relationships + matching your criteria
2025-08-06 12:29:32 -07:00
```
2025-08-07 19:33:03 -07:00
## 🌍 Works Everywhere - Same Code
2025-08-07 07:57:41 -07:00
2025-08-07 19:33:03 -07:00
**Write once, run anywhere.** Brainy auto-detects your environment:
2025-08-07 07:57:41 -07:00
2025-08-07 19:33:03 -07:00
| Environment | Storage | Optimization |
|-------------|---------|-------------|
| 🌐 Browser | OPFS | Web Workers, Memory Cache |
| 🟢 Node.js | FileSystem / S3 | Worker Threads, Clustering |
| ⚡ Serverless | S3 / Memory | Cold Start Optimization |
| 🔥 Edge | Memory / KV | Minimal Footprint |
2025-08-07 07:57:41 -07:00
2025-08-07 19:33:03 -07:00
< details >
< summary > 🔧 < strong > Advanced Configuration Options< / strong > < / summary >
2025-08-07 07:57:41 -07:00
```javascript
2025-08-07 19:33:03 -07:00
// High-throughput writer
const writer = new BrainyData({
2025-08-07 07:57:41 -07:00
writeOnly: true,
2025-08-07 19:33:03 -07:00
allowDirectReads: true // For deduplication
2025-08-07 07:57:41 -07:00
})
2025-08-07 19:33:03 -07:00
// Read-only search service
const reader = new BrainyData({
2025-08-07 07:57:41 -07:00
readOnly: true,
2025-08-07 19:33:03 -07:00
frozen: true // No stats updates
2025-08-07 07:57:41 -07:00
})
2025-08-07 19:33:03 -07:00
// Custom storage
const custom = new BrainyData({
storage: {
type: 's3',
s3Storage: { bucketName: 'my-vectors' }
2025-08-07 07:57:41 -07:00
},
2025-08-07 19:33:03 -07:00
hnsw: {
maxConnections: 32 // Higher quality
2025-08-07 07:57:41 -07:00
}
})
```
< / details >
2025-08-07 19:33:03 -07:00
## 🎮 Cortex CLI - Command Center for Everything
2025-08-06 16:38:52 -07:00
2025-08-07 19:33:03 -07:00
```bash
# Talk to your data
cortex chat "What patterns do you see?"
2025-08-06 16:38:52 -07:00
2025-08-07 19:33:03 -07:00
# AI-powered data import
cortex neural import data.csv --confidence 0.8
2025-08-06 16:38:52 -07:00
2025-08-07 19:33:03 -07:00
# Real-time monitoring
cortex monitor --dashboard
2025-08-06 16:38:52 -07:00
2025-08-07 19:33:03 -07:00
# Start premium trials
cortex license trial notion
2025-08-06 16:38:52 -07:00
```
2025-08-07 19:33:03 -07:00
[📖 **Full Cortex Documentation** ](/docs/cortex.md )
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
## ⚙️ Configuration (Optional)
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
Brainy works with **zero configuration** , but you can customize
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
## 🆚 Why Not Just Use...?
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
### vs. Multiple Databases
❌ **Pinecone + Neo4j + Elasticsearch** - 3 databases, sync nightmares, 3x the cost
✅ **Brainy** - One database, always synced, built-in intelligence
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
### vs. Cloud-Only Vector DBs
❌ **Pinecone/Weaviate/Qdrant** - Vendor lock-in, expensive, cloud-only
✅ **Brainy** - Run anywhere, your data stays yours, cost-effective
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
### vs. Graph DBs with "Vector Features"
❌ **Neo4j + vector plugin** - Bolt-on solution, not native, limited
✅ **Brainy** - Native vector+graph architecture from the ground up
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
## 💎 Premium Features (Optional)
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
**Core Brainy is FREE forever. Premium features for enterprise needs:**
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
### 🔗 Enterprise Connectors (14-day trials)
- **Notion** ($49/mo) - Bidirectional workspace sync
- **Salesforce** ($99/mo) - CRM integration
- **Slack** ($49/mo) - Team collaboration
- **Asana** ($44/mo) - Project management
2025-08-07 13:53:17 -07:00
```bash
2025-08-07 19:33:03 -07:00
cortex license trial notion # Start free trial
2025-08-07 13:53:17 -07:00
```
2025-08-07 19:33:03 -07:00
**No vendor lock-in. Your data stays yours.**
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
## 🎨 What You Can Build
2025-08-07 13:53:17 -07:00
2025-08-07 19:33:03 -07:00
- **🤖 AI Chat Applications** - ChatGPT-like apps with long-term memory
- **🔍 Semantic Search** - Search by meaning, not keywords
- **🎯 Recommendation Engines** - "Users who liked this also liked..."
- **🧬 Knowledge Graphs** - Connect everything to everything
- **🛡️ Fraud Detection** - Find patterns humans can't see
- **📚 Smart Documentation** - Docs that answer questions
2025-08-05 15:34:39 -07:00
2025-08-06 16:38:52 -07:00
< details >
2025-08-07 19:33:03 -07:00
< summary > 📦 < strong > Framework Examples< / strong > < / summary >
2025-08-06 09:52:45 -07:00
2025-08-07 19:33:03 -07:00
### React
2025-08-06 16:38:52 -07:00
```jsx
import { BrainyData } from '@soulcraft/brainy '
2025-08-07 19:33:03 -07:00
function App() {
const [brainy] = useState(() => new BrainyData())
useEffect(() => brainy.init(), [])
2025-08-06 16:38:52 -07:00
const search = async (query) => {
2025-08-07 19:33:03 -07:00
return await brainy.search(query, 10)
2025-08-06 16:38:52 -07:00
}
}
2025-08-05 15:34:39 -07:00
```
2025-08-07 19:33:03 -07:00
### Vue 3
```vue
< script setup >
const brainy = new BrainyData()
await brainy.init()
< / script >
```
2025-08-06 16:38:52 -07:00
2025-08-07 19:33:03 -07:00
### Angular
2025-08-06 16:38:52 -07:00
```typescript
2025-08-07 19:33:03 -07:00
@Component ({})
export class AppComponent {
2025-08-06 16:38:52 -07:00
brainy = new BrainyData()
async ngOnInit() {
await this.brainy.init()
}
}
```
2025-08-07 19:33:03 -07:00
### Node.js
2025-08-06 16:38:52 -07:00
```javascript
const brainy = new BrainyData()
2025-08-06 16:41:03 -07:00
await brainy.init()
```
2025-08-07 19:33:03 -07:00
< / details >
2025-08-05 15:34:39 -07:00
2025-08-06 12:29:32 -07:00
2025-08-06 16:26:39 -07:00
## 📦 Advanced Features
2025-08-05 15:34:39 -07:00
2025-08-06 09:52:45 -07:00
< details >
2025-08-06 16:26:39 -07:00
< summary > 🔧 < strong > MongoDB-Style Metadata Filtering< / strong > < / summary >
2025-08-05 15:34:39 -07:00
```javascript
2025-08-06 16:26:39 -07:00
const results = await brainy.search("machine learning", 10, {
metadata: {
price: { $gte: 100, $lte: 1000 },
2025-08-07 19:33:03 -07:00
category: { $in: ["AI", "ML"] },
2025-08-06 16:26:39 -07:00
rating: { $gt: 4.5 },
tags: { $includes: "tensorflow" }
2025-08-06 09:52:45 -07:00
}
2025-08-01 08:27:39 -07:00
})
2025-08-05 15:34:39 -07:00
```
2025-08-07 19:33:03 -07:00
**15+ operators**: `$gt` , `$in` , `$regex` , `$and` , `$or` , etc.
2025-08-05 15:34:39 -07:00
2025-08-06 16:26:39 -07:00
< / details >
2025-08-04 08:56:05 -07:00
2025-08-06 16:26:39 -07:00
< details >
2025-08-07 19:33:03 -07:00
< summary > 🔗 < strong > Graph Relationships< / strong > < / summary >
2025-08-04 14:33:39 -07:00
2025-08-04 12:18:58 -07:00
```javascript
2025-08-06 16:26:39 -07:00
const company = await brainy.add("OpenAI", { type: "company" })
const product = await brainy.add("GPT-4", { type: "product" })
await brainy.relate(company, product, "develops")
2025-08-05 15:34:39 -07:00
2025-08-07 19:33:03 -07:00
const products = await brainy.getVerbsBySource(company)
2025-08-04 10:14:33 -07:00
```
2025-08-04 08:56:05 -07:00
2025-08-06 16:26:39 -07:00
< / details >
2025-08-05 15:34:39 -07:00
2025-08-06 16:26:39 -07:00
< details >
2025-08-07 19:33:03 -07:00
< summary > 🐳 < strong > Docker Deployment< / strong > < / summary >
2025-08-05 15:34:39 -07:00
```dockerfile
2025-08-07 19:33:03 -07:00
FROM node:24-slim
RUN npm run download-models # Embed models
CMD ["node", "server.js"]
2025-08-05 15:34:39 -07:00
```
2025-08-04 08:56:05 -07:00
2025-08-07 19:33:03 -07:00
Deploy anywhere: AWS, GCP, Azure, Cloudflare
2025-08-04 08:56:05 -07:00
2025-08-06 12:29:32 -07:00
< / details >
2025-08-04 08:56:05 -07:00
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
## 📚 Documentation
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
- [Quick Start ](docs/getting-started/ )
- [API Reference ](docs/api-reference/ )
- [Examples ](docs/examples/ )
- [Cortex CLI ](docs/cortex.md )
- [Performance Guide ](docs/optimization-guides/ )
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
## ❓ Does Brainy Impact Performance?
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
**NO - Brainy actually IMPROVES performance:**
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
✅ **Zero runtime overhead** - Premium features are lazy-loaded only when used
✅ **Smaller than alternatives** - 643KB vs 12.5MB for TensorFlow.js
✅ **Built-in caching** - 95%+ cache hit rates reduce compute
✅ **Automatic optimization** - Gets faster as it learns your patterns
✅ **No network calls** - Works completely offline after setup
2025-08-06 16:41:03 -07:00
2025-08-07 19:33:03 -07:00
**The augmentation system and premium features are 100% optional and have ZERO impact unless explicitly activated.**
2025-08-04 08:56:05 -07:00
2025-08-04 10:14:33 -07:00
## 🤝 Contributing
2025-08-04 08:56:05 -07:00
2025-08-07 19:33:03 -07:00
We welcome contributions! See [Contributing Guidelines ](CONTRIBUTING.md )
2025-08-04 08:56:05 -07:00
2025-08-04 10:14:33 -07:00
## 📄 License
2025-08-04 08:56:05 -07:00
2025-08-07 19:33:03 -07:00
[MIT ](LICENSE ) - Core Brainy is FREE forever
2025-08-04 08:56:05 -07:00
2025-08-04 10:14:33 -07:00
---
2025-08-04 08:56:05 -07:00
2025-08-04 10:14:33 -07:00
< div align = "center" >
2025-08-07 19:33:03 -07:00
< strong > Ready to build the future of search?< / strong >
2025-08-06 16:26:39 -07:00
2025-08-07 19:33:03 -07:00
**[Get Started → ](docs/getting-started/ ) | [Examples → ](docs/examples/ ) | [Discord → ](https://discord.gg/brainy )**
2025-08-06 16:26:39 -07:00
< / div >