Provider-Agnostic Storage for Go. Write Once, Store Anywhere.

Type-safe CRUD across databases, key-value stores, blob storage, and vector indices. Swap backends without touching business logic.

Get Started
import "github.com/zoobz-io/grub"

// Same code, different backends
sessions := grub.NewStore[Session](redis.New(client))
sessions := grub.NewStore[Session](badger.New(db))
sessions := grub.NewStore[Session](bolt.New(db, "sessions"))

// Type-safe operations — returns *Session, not interface{}
session, _ := sessions.Get(ctx, "session:abc")
sessions.Set(ctx, "session:xyz", &Session{UserID: "123"}, time.Hour)

// Four storage modes, one pattern
users := grub.NewDatabase[User](postgres.New(db, "users"))
docs  := grub.NewBucket[Document](s3.New(client, "documents"))
vecs  := grub.NewIndex[Embedding](qdrant.New(client, "embeddings"))

// Consistent errors across all providers
user, err := users.Get(ctx, "usr-123")
if errors.Is(err, grub.ErrNotFound) {
    // Same error whether it's Redis, PostgreSQL, or S3
}
93%Test Coverage
A+Go Report

Why Grub?

Storage becomes a configuration choice, not an architectural constraint.

Four Storage Modes

Store (key-value), Database (SQL), Bucket (blobs), Index (vectors). One pattern, every backend.

Type-Safe Generics

Get returns *T, Query returns []*T. The compiler enforces types across every storage operation.

Semantic Error Consistency

ErrNotFound, ErrDuplicate, ErrConflict mean the same thing whether it's Redis, PostgreSQL, or S3.

Lifecycle Hooks

BeforeSave, AfterLoad, BeforeDelete — validation, normalization, and side-effects without scattering logic.

Modular Providers

Each provider is a separate Go module. Only import Redis if you use Redis. Clean dependency graph.

Atomic Views

Field-level access via atomization for encryption pipelines, data transformations, and framework internals.

Capabilities

CRUD operations, caching strategies, blob storage, vector search, and provider migrations — all behind one interface.

FeatureDescriptionLink
Key-Value StorageGet, Set, Delete, Exists with optional TTL. Redis, BadgerDB, and BoltDB providers.Providers
SQL DatabasesType-safe queries, transactions, and aggregates via soy builders. PostgreSQL, MariaDB, SQLite, SQL Server.Lifecycle
Blob StoragePut, Get, Delete with typed payloads and metadata. S3, MinIO, Google Cloud Storage, Azure Blob.Best Practices
Vector SearchSimilarity search with typed metadata and filters. Qdrant, Pinecone, Milvus, Weaviate.Vector Search
Caching PatternsCache-aside, read-through, and TTL strategies with consistent invalidation across providers.Caching
Provider MigrationsDual-write, shadow-read, and big-bang patterns for zero-downtime backend switches.Migrations

Articles

Browse the full grub documentation.

OverviewProvider-agnostic storage for Go with type-safe CRUD operations

Learn

QuickstartGet started with grub in under 5 minutes
Core ConceptsStores, buckets, databases, and the primitives that power grub
ArchitectureInternal design, concurrency model, and atomization

Guides

ProvidersChoosing and configuring storage providers
Lifecycle OperationsCRUD operations, batch processing, and listing
PaginationListing and paginating large datasets
TestingTesting strategies for different backends
Best PracticesKey design, performance tuning, and operational guidelines

Cookbook

Caching PatternsTTL strategies, cache invalidation, and read-through patterns
Provider MigrationsSwitching storage backends without downtime
Multi-Tenant PatternsIsolating tenant data across storage backends
Vector Search with PostgreSQLUsing Database[T] with pgvector for similarity search

Reference

API ReferenceComplete API documentation for grub
Provider ReferenceProvider-specific behaviors and configuration