Skip to main content
AI Generated Content
πŸ€– This documentation was generated with AI assistance. Please report any issues you find.

Storage Backends

Pikku provides official storage backend packages that implement the service interfaces required by features like AI Agents, Workflows, and Channels. Choose the backend that fits your infrastructure.

Available Backends​

PackageDatabaseBest For
@pikku/pgPostgreSQLProduction workloads with full SQL, transactions, and reliability
@pikku/kyselyPostgreSQL (via Kysely)Type-safe query building and multi-dialect support
@pikku/redisRedisHigh-throughput state management and caching
@pikku/mongodbMongoDBDocument-oriented storage with flexible schemas

Service Interfaces​

Each backend implements one or more of these core interfaces:

InterfacePurposeBackends
AIStorageServiceThread, message, and working memory persistence for AI Agents@pikku/pg, @pikku/kysely, @pikku/mongodb
AIRunStateServiceAgent run tracking and tool approval state@pikku/pg, @pikku/kysely, @pikku/mongodb
AgentRunServiceRead-only agent run queries (used by the Console)@pikku/pg, @pikku/redis, @pikku/kysely, @pikku/mongodb
WorkflowServiceWorkflow run orchestration and step state@pikku/pg, @pikku/redis, @pikku/kysely, @pikku/mongodb
WorkflowRunServiceRead-only workflow run queries (used by the Console)@pikku/pg, @pikku/redis, @pikku/kysely, @pikku/mongodb
ChannelStoreWebSocket channel and subscription persistence@pikku/pg, @pikku/redis, @pikku/kysely, @pikku/mongodb
EventHubStoreChannel topic subscription tracking@pikku/pg, @pikku/redis, @pikku/kysely, @pikku/mongodb
DeploymentServiceMulti-instance deployment tracking@pikku/pg, @pikku/redis, @pikku/kysely, @pikku/mongodb
SecretServiceEncrypted secret storage@pikku/pg, @pikku/kysely, @pikku/mongodb

Quick Comparison​

FeaturePostgreSQLRedisKyselyMongoDB
AI StoragePgAIStorageServiceβ€”KyselyAIStorageServiceMongoDBAIStorageService
WorkflowsPgWorkflowServiceRedisWorkflowServiceKyselyWorkflowServiceMongoDBWorkflowService
ChannelsPgChannelStoreRedisChannelStoreKyselyChannelStoreMongoDBChannelStore
SecretsPgSecretServiceβ€”KyselySecretServiceMongoDBSecretService
TransactionsNative SQL transactionsLua scriptsKysely transactionsMongoDB transactions
Schema initAuto-creates tables via init()No schema neededAuto-creates tables via init()Auto-creates collections via init()
Connectionpostgres (postgres.js)ioredisKysely with postgresmongodb driver

Choosing a Backend​

Use PostgreSQL (@pikku/pg) when you need:

  • Full AI Agent support (storage + run state)
  • SQL transactions and complex queries
  • A single database for everything

Use Redis (@pikku/redis) when you need:

  • High-throughput workflow orchestration
  • Low-latency channel state management
  • You already have Redis in your stack

Use Kysely (@pikku/kysely) when you need:

  • Type-safe SQL queries
  • The Kysely query builder for custom queries
  • Potential future multi-database dialect support

Use MongoDB (@pikku/mongodb) when you need:

  • Document-oriented storage with flexible schemas
  • You already have MongoDB in your stack
  • Full coverage of all service interfaces including encrypted secrets
tip

You can mix backends β€” for example, use @pikku/pg for AI storage and @pikku/redis for channel state. Just provide the appropriate service instances in your singleton services.