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

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
AIRunStateServiceAgent run tracking and tool approval state@pikku/pg, @pikku/kysely
AgentRunServiceRead-only agent run queries (used by the Console)@pikku/pg, @pikku/redis, @pikku/kysely
WorkflowServiceWorkflow run orchestration and step state@pikku/pg, @pikku/redis, @pikku/kysely
WorkflowRunServiceRead-only workflow run queries (used by the Console)@pikku/pg, @pikku/redis, @pikku/kysely
ChannelStoreWebSocket channel and subscription persistence@pikku/pg, @pikku/redis, @pikku/kysely
EventHubStoreChannel topic subscription tracking@pikku/pg, @pikku/redis, @pikku/kysely
DeploymentServiceMulti-instance deployment tracking@pikku/pg, @pikku/redis, @pikku/kysely

Quick Comparison​

FeaturePostgreSQLRedisKysely
AI StoragePgAIStorageServiceβ€”KyselyAIStorageService
WorkflowsPgWorkflowServiceRedisWorkflowServiceKyselyWorkflowService
ChannelsPgChannelStoreRedisChannelStoreKyselyChannelStore
TransactionsNative SQL transactionsLua scriptsKysely transactions
Schema initAuto-creates tables via init()No schema neededAuto-creates tables via init()
Connectionpostgres (postgres.js)ioredisKysely with postgres

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
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.