HelixDB CRM Example
A complete CRM example demonstrating HelixDB's graph-vector database capabilities with both Rust and Python SDKs.
Prerequisites
- Rust - For the Rust CRM tool
- uv - For Python dependency management
- HelixDB CLI - Database server
Quick Start
# 1. Install dependencies
./install.sh
# 2. Start HelixDB server (in separate terminal)
helix start dev
# 3. Start dashboard (in separate terminal)
helix dashboard
# 4. Load sample data and run queries
./run_rust.sh load
./run_rust.sh all
Project Structure
helixdb/
├── db/
│ ├── schema.hx # Database schema (nodes & edges)
│ └── queries.hx # HelixQL queries
├── data/
│ ├── contacts.toml # Sample contacts
│ ├── accounts.toml # Sample accounts
│ ├── deals.toml # Sample deals
│ ├── products.toml # Sample products
│ ├── activities.toml # Sample activities
│ └── relationships.toml # Edge definitions
├── crm_tool/ # Rust CLI tool
│ ├── Cargo.toml
│ └── src/main.rs
├── python_example/ # Python examples
│ ├── pyproject.toml
│ ├── crm_example.py # CRM queries demo
│ └── ai_search_example.py # Semantic search demo
├── install.sh # Install all dependencies
├── run_rust.sh # Run Rust tool
└── run_py.sh # Run Python examples
Scripts
| Script |
Description |
./install.sh |
Install Rust and Python dependencies |
./run_rust.sh |
Run the Rust CRM tool |
./run_py.sh |
Run Python examples |
Rust CRM Tool
./run_rust.sh load # Load TOML data into database
./run_rust.sh query # Run sample queries
./run_rust.sh all # Load data + run all queries
./run_rust.sh help # Show help
Python Examples
./run_py.sh crm # CRM queries and edge traversals
./run_py.sh ai # AI/semantic search (requires API key)
Schema
Nodes
| Type |
Description |
Contact |
People (name, email, phone, title) |
Account |
Companies (name, industry, website, size) |
Deal |
Sales opportunities (title, value, stage, probability) |
Product |
Products/services (name, category, price) |
Activity |
Interactions (type, subject, notes, date) |
Note |
Vector-enabled notes for semantic search |
Edges (Relationships)
| Edge |
From |
To |
Description |
WorksAt |
Contact |
Account |
Employment relationship |
HasDeal |
Account |
Deal |
Account's deals |
ContactDeal |
Contact |
Deal |
Contact involved in deal |
DealProduct |
Deal |
Product |
Products in deal |
ActivityContact |
Activity |
Contact |
Activity with contact |
Knows |
Contact |
Contact |
Contact knows another |
AI/Semantic Search
HelixDB supports vector embeddings for semantic search. The Note node type uses V::Note syntax for vector storage.
Supported Embedding Providers
| Provider |
Install |
Environment Variable |
| OpenAI |
pip install helix-py[embed-openai] |
OPENAI_API_KEY |
| Google Gemini |
pip install helix-py[embed-gemini] |
GEMINI_API_KEY |
| Voyage AI |
pip install helix-py[embed-voyageai] |
VOYAGEAI_API_KEY |
Usage
# Set your API key
export OPENAI_API_KEY='sk-your-key-here'
# Run semantic search example
./run_py.sh ai
Example Queries
Query: "How do we help new customers get started?"
-> Finds: Customer Onboarding Process notes
Query: "What are our plans for machine learning?"
-> Finds: Product Roadmap, Competitor Analysis notes
URLs
HelixQL Examples
Adding a Node
QUERY createContact(name: String, email: String, phone: String, title: String) =>
contact <- AddN<Contact>({ Name: name, Email: email, Phone: phone, Title: title })
RETURN contact
Creating an Edge
QUERY linkContactToAccount(contact_id: String, account_id: String, role: String, start_date: I64) =>
edge <- AddE<WorksAt>({ Role: role, StartDate: start_date })::From(contact_id)::To(account_id)
RETURN edge
Traversing Relationships
QUERY getAccountContacts(account_id: String) =>
contacts <- N<Account>(account_id)::In<WorksAt>::N<Contact>
RETURN contacts
Vector Search
QUERY searchNotes(query: String, limit: I64) =>
notes <- SearchV<Note>(Embed(query), limit)
RETURN notes
Dashboard Query Naming Convention
For the dashboard visualization to work correctly, queries should follow this naming convention:
| Prefix |
Purpose |
Example |
create* |
Create nodes/edges |
createContact, createDeal |
get* |
Read/query data |
getContacts, getAccountDeals |
update* |
Update existing data |
updateContact, updateDeal |
delete* |
Delete data |
deleteContact, deleteDeal |
link* |
Create relationships |
linkContactToAccount |
Documentation