A high-performance, WASM-based embedded NoSQL database with GraphQL query language support and CRDT-based synchronization for distributed systems.
- WASM Compatible: Runs natively in browsers and WASI-compatible runtimes
- GraphQL API: Full support for queries, mutations, and subscriptions
- CRDT Synchronization: Conflict-free replicated data types with Last-Writer-Wins (LWW) strategy
- Real-time Sync: WebSocket-based real-time data synchronization
- Offline-First: Works offline with automatic conflict resolution when syncing
- Flat Data Design: Optimized for flattened data with efficient relation queries
- Zero Configuration: Simple builder pattern for quick setup
- Rust 1.70+
- wasm-pack (for WASM targets)
[dependencies]
nuclear = "0.1.0"use nuclear::Database;
use nuclear::storage::WasiStorage;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let storage = WasiStorage::new("./data");
let db = Database::builder(storage)
.node_id("node1".to_string())
.build()
.await?;
// Create data with GraphQL mutation
db.mutation(r#"
mutation {
create_user(input: {name: "Alice", email: "alice@example.com"}) {
id
name
}
}
"#).await?;
// Query data with GraphQL
let result = db.query("query { users { id name email } }").await?;
println!("{:?}", result);
// Subscribe to real-time updates
let mut stream = db.subscribe("subscription { user_updated { id name } }").await?;
Ok(())
}-
CRDT Engine (
src/core/)- LWW Register: Last-Writer-Wins value containers
- LWW Map: Key-value store with CRDT semantics
- Vector Clock: Logical time tracking for causality
-
Storage Layer (
src/storage/)- Trait-based abstraction for storage backends
- WasiStorage: WASI file system implementation
- Pluggable design for browser/localStorage
-
GraphQL Layer (
src/graphql/)- Schema definition with queries, mutations, subscriptions
- Scalars for custom types
- Integration with CRDT data model
-
Sync Engine (
src/sync/)- SyncMessage: Wire format for synchronization
- ConflictResolver: LWW-based conflict resolution
-
API Layer (
src/api/)- Database: Main interface for all operations
- DatabaseBuilder: Fluent builder for configuration
User Query → GraphQL Parser → CRDT Engine → Storage → Response
↓
Sync Engine → Network → Other Nodes
cargo build --releasewasm-pack build --target webcargo run --example basic_usagecargo test
cargo test --test integration_testnuclear/
├── src/
│ ├── api/ # Public API (Database, Builder)
│ ├── core/ # CRDT implementations
│ ├── graphql/ # GraphQL schema and execution
│ ├── storage/ # Storage abstractions
│ └── sync/ # Synchronization protocol
├── examples/ # Usage examples
├── tests/ # Integration tests
└── Cargo.toml # Project manifest
MIT License - see LICENSE file for details.