# Brainy Interactive Demo - A Lightweight Graph & Vector Data Platform

Warning: This demo must be served over HTTP to work properly. If you're seeing this message or the demo isn't working, please:

1. Open a terminal in the project root directory
2. Run: `npx http-server`
3. Navigate to http://localhost:8080/demo/index.html

## 🚀 Key Features

Explore all of Brainy's powerful capabilities in this interactive demo:

#### 🏃‍♂️ Run Everywhere

Run Brainy in a browser, container, serverless cloud service or the terminal!

#### 🔍 Vector Search

Find semantically similar content using embeddings (like having ESP for your data!)

#### 🌐 Graph Database

Connect data with meaningful relationships (your data's social network)

#### 🌊 Streaming Pipeline

Process data in real-time as it flows through the system (like a data waterslide!)

#### 🧩 Extensible Augmentations

Customize and extend functionality with pluggable components (LEGO blocks for your data!)

#### 🔌 Built-in Conduits

Sync and scale across instances with WebSocket and WebRTC (your data's teleportation system!)

#### 🤖 TensorFlow Integration

Use TensorFlow.js for high-quality embeddings (included as a required dependency)

#### 🧠 Adaptive Intelligence

Automatically optimizes for your environment and usage patterns

#### 🌍 Cross-Platform

Works everywhere you do: browsers, Node.js and server environments

#### 💾 Persistent Storage

Data persists across sessions and scales to any size (no memory loss here!)

#### 🔧 TypeScript Support

Fully typed API with generics (for those who like their code tidy)

#### 📱 CLI Tools

Powerful command-line interface for data management (command line wizardry)

#### 📊 Data Visualization

Interactive graph and vector space visualizations

#### ☁️ Cloud Ready

Easy deployment to Google, AWS, Azure and other cloud platforms

#### 🎮 Model Control Protocol (MCP)

Allow external AI models to access Brainy data and use augmentation pipeline as tools

## 📊 What Can You Build?

#### 🔍 Semantic Search Engines

Find content based on meaning, not just keywords

#### 👍 Recommendation Systems

Suggest similar items based on vector similarity

#### 🧠 Knowledge Graphs

Build connected data structures with relationships

#### 🤖 AI Applications

Store and retrieve embeddings for machine learning models

#### 💡 AI-Enhanced Applications

Build applications that leverage vector embeddings for intelligent data processing

#### 📁 Data Organization Tools

Automatically categorize and connect related information

#### 🔄 Adaptive Experiences

Create applications that learn and evolve with your users

#### 🔌 Model-Integrated Systems

Connect external AI models to Brainy data and tools using MCP

## Interactive Brainy Explorer

This interactive demo guides you through Brainy's features step by step, from basic operations to advanced capabilities.

### Step 1: Getting Started with Brainy

Let's start by initializing the database and exploring basic operations.

Database not initialized. Click "Initialize Database" to start.
Database visualization will appear here after initialization

### Step 2: Semantic Search

Search your data using vector embeddings for semantic understanding.

Try searching for topics in the sample data like "machine learning", "AI ethics", "computer vision", "robotics", "quantum computing", "cybersecurity", or specific concepts like "large language models", "federated learning", "explainable AI", "climate science", etc.

Search results will appear here...
Search results visualization

### Step 3: Adding Entities (Nouns)

Now that your database is initialized, let's add some entities (nouns) to it.

Noun Type:
ID (optional):
Name:
Description/Content:
Tags (comma-separated):
Entity operations will appear here...

### Step 4: Creating Relationships (Verbs)

Connect your entities with meaningful relationships to build a knowledge graph.

Source Entity:
Target Entity:
Relationship Type:
Relationship Description:

### Step 5: Advanced Features

Explore Brainy's advanced capabilities for more complex use cases.

### 🔍 Vector Search

Explore how HNSW makes semantic search fast and efficient.

### 🌐 Graph Traversal

Navigate through connected entities in your knowledge graph.

### 💾 Data Management

Backup, restore and manage your data.

### 🧠 Embedding Pipeline

See how text is converted to vectors for semantic understanding.

Select a feature above to see a detailed demonstration...

### Step 6: Command Line Interface

Try Brainy's CLI commands for scripting and automation.

brainy$
Common Commands:
brainy init - Initialize a new database
brainy add <data> - Add data to the database
brainy search <query> - Search for entities
brainy relate <from> <to> - Create relationships
brainy status - Show database status
brainy help - Show all commands

## 🏁 Quick Start

### Node.js Environment

    import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'

    // Create and initialize the database
    const db = new BrainyData()
    await db.init()

    // Add data (automatically converted to vectors)
    const catId = await db.add("Cats are independent pets", {
        noun: NounType.Thing,
        category: 'animal'
    })

    const dogId = await db.add("Dogs are loyal companions", {
        noun: NounType.Thing,
        category: 'animal'
    })

    // Search for similar items
    const results = await db.searchText("feline pets", 2)
    console.log(results)
    // Returns items similar to "feline pets" with similarity scores

    // Add a relationship between items
    await db.addVerb(catId, dogId, {
        verb: VerbType.RelatedTo,
        description: 'Both are common household pets'
    })

### Browser Environment

Brainy uses a unified build that automatically adapts to your environment:

#### Option 1: Standard Import

    // Standard import - automatically adapts to any environment
    import { BrainyData, NounType, VerbType } from '@soulcraft/brainy'

    // Use the same API as in Node.js
    const db = new BrainyData()
    await db.init()
    // ...

#### Option 2: Using a script tag in HTML

    <script type="module">
      // Use local files instead of CDN
      // For GitHub Pages, use relative path: './dist/unified.js'
      // For local development, use absolute path: '/dist/unified.js'
      // This import is replaced by the dynamic import below

      // Or minified version
      // import { BrainyData, NounType, VerbType } from '/dist/unified.min.js'

      const db = new BrainyData()
      await db.init()
      // ...
    </script>

Modern bundlers like Webpack, Rollup and Vite will automatically use the unified build which adapts to any environment.