GigaBrain ๐ง #
A high-performance, in-memory graph database written in Rust with Cypher query support.
โจ Features#
- ๐ High Performance: In-memory storage with optimized data structures
- ๐ Cypher Support: Neo4j-compatible query language
- ๐ป Interactive CLI: Comprehensive command-line interface with REPL
- ๐ Graph Algorithms: Built-in pathfinding, centrality, and community detection
- ๐ Dual APIs: Both REST and gRPC interfaces
- ๐ Authentication: JWT-based auth with role-based access control
- ๐พ Persistence: Optional RocksDB backend for data durability
- ๐ Monitoring: Built-in metrics and observability
- โ Schema Validation: Comprehensive constraint system for data integrity
- ๐ฅ๐ค Data Management: JSON/CSV import/export capabilities
๐ Quick Start#
Installation#
git clone https://github.com/your-org/gigabrain.git
cd gigabrain
cargo build --release
Running the Server#
# Start both REST (port 3000) and gRPC (port 50051) servers
cargo run --bin gigabrain
Using the CLI#
# Build and start the interactive CLI
cargo build --release --bin gigabrain-cli
./target/release/gigabrain-cli
# Interactive REPL usage
gigabrain> CREATE (alice:Person {name: 'Alice', age: 30})
gigabrain> MATCH (n:Person) RETURN n.name, n.age
gigabrain> :stats
gigabrain> :help
# Single command execution
./target/release/gigabrain-cli --execute "MATCH (n) RETURN count(n)"
# Batch file processing
./target/release/gigabrain-cli --file my_queries.cypher
Basic Usage#
# Health check
curl http://localhost:3000/api/v1/health
# Create a person
curl -X POST http://localhost:3000/api/v1/nodes \
-H "Content-Type: application/json" \
-d '{
"labels": ["Person"],
"properties": {
"name": "Alice",
"age": 30
}
}'
# Execute Cypher query
curl -X POST http://localhost:3000/api/v1/cypher \
-H "Content-Type: application/json" \
-d '{
"query": "MATCH (n:Person) RETURN n.name, n.age LIMIT 10"
}'
๐ Documentation#
- CLI Guide - Complete command-line interface documentation
- API Reference - Complete REST and gRPC API documentation
- Architecture Guide - Technical architecture and design decisions
- Examples - Practical usage examples and tutorials
- Project Overview - Detailed project documentation
๐๏ธ Architecture#
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ CLI/REPL โ โ REST API โ โ gRPC API โ
โ Interface โ โ (Port 3000) โ โ (Port 50051) โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ โ โ
โโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโ
โ API Layer โ
โ (Auth/Routing) โ
โโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโ
โ Query Engine โ
โ (Cypher Parser) โ
โโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโ
โ Graph Engine โ
โ (Core Storage) โ
โโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโ
โ Storage Layer โ
โ (Memory/RocksDB)โ
โโโโโโโโโโโโโโโโโโโ
๐ฏ Use Cases#
Social Networks#
- Friend recommendations
- Community detection
- Influence analysis
Fraud Detection#
- Pattern recognition
- Anomaly detection
- Risk scoring
Knowledge Graphs#
- Semantic search
- Recommendation engines
- Data lineage
Supply Chain#
- Route optimization
- Dependency analysis
- Impact assessment
๐ Performance#
Benchmarks on 16-core machine with 32GB RAM:
| Operation | Throughput | Latency (p99) |
|---|---|---|
| Node Creation | 1.2M ops/sec | 2ms |
| Relationship Creation | 800K ops/sec | 3ms |
| Single-hop Traversal | 2M ops/sec | 0.5ms |
| Multi-hop Queries | 100K ops/sec | 15ms |
| Shortest Path (6 hops) | 50K ops/sec | 25ms |
๐ง Configuration#
Server Options#
ServerConfig {
rest_port: 3000,
grpc_port: 50051,
max_connections: 1000,
request_timeout: Duration::from_secs(30),
enable_cors: true,
jwt_secret: "your-secret-key",
}
Storage Backends#
# In-memory (default)
cargo run
# With RocksDB persistence
cargo run --features rocksdb-storage
๐งช Development#
Building#
# Debug build
cargo build
# Release build
cargo build --release
# With all features
cargo build --all-features
Testing#
# Run all tests
cargo test
# Run with coverage
cargo test --all-features
# Benchmarks
cargo bench
Code Quality#
# Format code
cargo fmt
# Run linter
cargo clippy
# Check documentation
cargo doc --no-deps --open
๐ API Examples#
REST API#
import requests
# Create node
response = requests.post('http://localhost:3000/api/v1/nodes', json={
'labels': ['Person'],
'properties': [
{'key': 'name', 'value': {'string_value': 'Alice'}}
]
})
# Execute query
response = requests.post('http://localhost:3000/api/v1/cypher', json={
'query': 'MATCH (n:Person) RETURN n.name'
})
gRPC API#
conn, _ := grpc.Dial("localhost:50051", grpc.WithInsecure())
client := pb.NewGigaBrainServiceClient(conn)
node, _ := client.CreateNode(context.Background(), &pb.CreateNodeRequest{
Labels: []string{"Person"},
Properties: []*pb.Property{
{Key: "name", Value: &pb.PropertyValue{
Value: &pb.PropertyValue_StringValue{StringValue: "Alice"},
}},
},
})
๐ท๏ธ Graph Algorithms#
Pathfinding#
- Dijkstra's shortest path
- A* pathfinding
- Bidirectional search
Centrality#
- PageRank
- Betweenness centrality
- Closeness centrality
Community Detection#
- Louvain algorithm
- Modularity optimization
- Label propagation
Traversal#
- Breadth-first search
- Depth-first search
- Random walks
๐ Monitoring#
Metrics#
# Prometheus metrics
curl http://localhost:3000/metrics
Health Checks#
# Application health
curl http://localhost:3000/api/v1/health
# Detailed status
curl http://localhost:3000/api/v1/stats
๐ข Deployment#
Docker#
FROM rust:1.70 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/gigabrain /usr/local/bin/
EXPOSE 3000 50051
CMD ["gigabrain"]
Kubernetes#
apiVersion: apps/v1
kind: Deployment
metadata:
name: gigabrain
spec:
replicas: 3
selector:
matchLabels:
app: gigabrain
template:
spec:
containers:
- name: gigabrain
image: gigabrain:latest
ports:
- containerPort: 3000
- containerPort: 50051
๐ค Contributing#
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Development Guidelines#
- Follow Rust best practices
- Write comprehensive tests
- Update documentation
- Use conventional commits
๐ License#
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฃ๏ธ Roadmap#
v0.2.0#
- Distributed deployment support
- Advanced query optimization
- Real-time streaming APIs
- Graph visualization tools
v0.3.0#
- Machine learning integration
- Time-series graph support
- Advanced security features
- Cloud provider integrations
v1.0.0#
- Production-ready stability
- Enterprise features
- Professional support
๐ Support#
- Documentation: docs/
- Issues: GitHub Issues
- Discussions: GitHub Discussions
๐ Acknowledgments#
- Neo4j for Cypher query language inspiration
- Rust Graph for graph algorithms reference
- Tokio for async runtime
- Tonic for gRPC support
Built with โค๏ธ in Rust