A local-first embedded database with secure end-to-end encrypted multi-device sync.
- Local-first data storage with full offline functionality
- Secure sync across devices with end-to-end encryption
- ACID transactions with serializable isolation
- CRDT-based conflict resolution
- WAL-based durability with automatic checkpointing
- Production-grade reliability with checksums, verification, and repair tools
- Installation
- Quick Start
- Architecture
- API Reference
- Operations Guide
- Security
- Performance
- Contributing
go get github.com/lattice-db/lattice@latestdocker pull ghcr.io/lattice-db/lattice:latestDownload pre-built binaries from the Releases page.
package main
import (
"fmt"
"log"
"github.com/lattice-db/lattice/pkg/lattice"
)
func main() {
// Open a database
db, err := lattice.Open("./data", nil)
if err != nil {
log.Fatal(err)
}
defer db.Close()
// Start a writable transaction
tx, err := db.Begin(true)
if err != nil {
log.Fatal(err)
}
// Create a collection
err = tx.CreateCollection("users", &lattice.Schema{
PrimaryKey: "id",
Fields: map[string]lattice.FieldDef{
"id": {Type: lattice.TypeString, Required: true},
"name": {Type: lattice.TypeString, Required: true},
"email": {Type: lattice.TypeString},
},
})
if err != nil {
log.Fatal(err)
}
// Insert a document
doc := lattice.NewDocument()
doc.Set("id", "user-1")
doc.Set("name", "Alice")
doc.Set("email", "alice@example.com")
err = tx.Insert("users", doc)
if err != nil {
log.Fatal(err)
}
// Commit transaction
err = tx.Commit()
if err != nil {
log.Fatal(err)
}
fmt.Println("Database initialized successfully")
}# Initialize a database
lattice init ./data
# Store a value
lattice put user:1 '{"name":"Alice"}'
# Retrieve a value
lattice get user:1
# Verify database integrity
lattice verify
# Start sync server
lattice-server --addr=:8080- WAL (Write-Ahead Log) for crash recovery
- Segmented storage with automatic compaction
- Page-based structure with checksums on every page
- MVCC (Multi-Version Concurrency Control) for consistent reads
- Serializable isolation with conflict detection
- LWW Register for last-writer-wins values
- OR Set for add-wins sets
- Map of CRDT values for nested structures
- Counter with increment and decrement support
- ECDH for key exchange
- AES-256-GCM for encryption
- Ed25519 for signatures
lattice.db/
├── cmd/ # CLI tools
├── pkg/ # Public APIs
├── internal/ # Private implementation
├── docs/ # Documentation
├── spec/ # Formal specifications
├── rfcs/ # Design proposals
└── testdata/ # Test fixtures
Copyright (c) 2025 LATTICE.DB contributors. See LICENSE for details.