A Claude-written graph database in Rust. Use at your own risk.
README.md

GigaBrain Examples#

This directory contains example applications demonstrating how to use GigaBrain's graph database capabilities.

Available Examples#

🧠 Basic Example - ✅ Working#

A simple, working example that demonstrates core GigaBrain functionality:

cd examples/basic-example
cargo run

Features demonstrated:

  • Schema setup (labels, properties, relationships)
  • Node creation with typed properties
  • Relationship creation and traversal
  • Graph querying and statistics
  • Basic graph operations

Output:

🧠 GigaBrain Basic Example
=========================

📝 Creating nodes...
✅ Created Alice (Person)
✅ Created Bob (Person)  
✅ Created TechCorp (Company)

🔗 Creating relationships...
✅ Alice works for TechCorp
✅ Bob works for TechCorp
✅ Alice knows Bob

🔍 Querying the graph...
📊 Total nodes: 3
👥 People in the graph:
  - Bob (age: 25)
  - Alice (age: 30)

🕸️  Alice's relationships:
  - WORKS_FOR -> TechCorp
  - KNOWS -> Bob

📈 Graph Statistics:
  Nodes: 3
  Relationships: 3

✨ Example completed successfully!

🌐 Social Network Example - ⚠️ In Development#

A comprehensive social network application (currently has compilation issues):

Planned Features:

  • User registration and authentication
  • Posts, likes, comments, shares
  • Friend/follow relationships
  • Recommendation engine
  • Timeline and feed generation
  • REST API with 20+ endpoints
  • Graph visualization integration

Note: This example is currently being debugged and may not compile.

Getting Started#

  1. Prerequisites: Ensure you have Rust installed
  2. Choose an Example: Start with the basic example to understand core concepts
  3. Run the Example: Navigate to the example directory and run cargo run
  4. Explore the Code: Read the source code to understand the implementation

Key Concepts Demonstrated#

Schema Management#

// Setup labels, properties, and relationship types
let mut schema = graph.schema().write();
schema.get_or_create_label("Person");
schema.get_or_create_property_key("name");
schema.get_or_create_relationship_type("KNOWS");

Node Operations#

// Create and update nodes
let node_id = graph.create_node();
graph.update_node(node_id, |node| {
    node.add_label(person_label);
    node.properties.insert(name_prop, PropertyValue::String("Alice".to_string()));
})?;

Relationship Creation#

// Create relationships between nodes
graph.create_relationship(alice_id, bob_id, knows_rel)?;

Graph Traversal#

// Find relationships for a node
let relationships = graph.get_node_relationships(
    node_id, 
    Direction::Outgoing, 
    Some(relationship_type)
);

Best Practices#

  1. Schema First: Always set up your schema before creating nodes
  2. Type Safety: Use strongly typed PropertyValue enums
  3. Error Handling: Properly handle GigaBrain errors
  4. Resource Management: Use appropriate lock scopes for schema operations
  5. Query Optimization: Leverage relationship direction and type filtering

Next Steps#


For more examples and tutorials, see the GigaBrain documentation.