AstraeaDB

An R client for AstraeaDB, a graph database with vector search written in Rust. AstraeaDB provides node and edge CRUD operations, label and edge-type lookups, graph traversals (BFS, DFS, shortest path), temporal queries, graph algorithms (PageRank, Louvain, connected components, centrality), vector similarity search, hybrid graph-vector search, GQL query execution, and GraphRAG (subgraph extraction with LLM integration).

Installation

Install the development version from GitHub:

# install.packages("remotes")
remotes::install_github("AstraeaDB/R-AstraeaDB")

Prerequisites

A running AstraeaDB server is required. See the AstraeaDB documentation for installation and startup instructions.

Quick start

library(AstraeaDB)

# Connect to a local AstraeaDB server
client <- astraea_connect()

# Create nodes
alice <- client$create_node("Person", list(name = "Alice", age = 30))
bob   <- client$create_node("Person", list(name = "Bob", age = 25))

# Create an edge
client$create_edge(alice, bob, "KNOWS", list(since = "2024-01-01"))

# Traverse the graph
client$neighbors(alice)
client$bfs(alice, max_depth = 3)
client$shortest_path(alice, bob)

# Run a GQL query
client$query("MATCH (p:Person) WHERE p.age > 20 RETURN p")

# Disconnect when done
client$disconnect()

Features

Core graph operations

Vector and AI capabilities

Temporal queries

Graph algorithms

Transport options

Transport Class Use case
JSON/TCP (default) AstraeaClient General-purpose, always available
Apache Arrow Flight ArrowClient High-throughput columnar data transfer
Auto-select UnifiedClient Picks the best available transport

Arrow Flight support is optional and activates automatically when the arrow package is installed.

Clients

# Standard JSON/TCP client
client <- astraea_connect(host = "127.0.0.1", port = 7687)

# Arrow Flight client (requires the arrow package)
arrow_client <- astraea_arrow_connect(uri = "grpc://localhost:7689")

# Unified client -- delegates CRUD to JSON/TCP, queries to Arrow when available
unified <- UnifiedClient$new(host = "127.0.0.1", port = 7687)
unified$connect()

Vignettes

The package ships with four vignettes: - Introduction – overview of AstraeaDB and its data model - Getting started – detailed walkthrough of CRUD, traversals, and queries - Advanced features – vector search, temporal queries, and GraphRAG - PCAP analysis – worked example converting network packet captures into a graph

Build vignettes locally with:

devtools::build_vignettes()

Dependencies

Package Role
jsonlite JSON serialisation
R6 Object-oriented client classes
arrow (optional) Arrow Flight transport

License

MIT