Skip to content

Add PostgreSQL adapter as alternative storage backend #3

Description

@josharsh

Summary

Engram currently uses SQLite for everything (storage, FTS5, sqlite-vec). This works great for single-process and embedded use cases, but teams running multiple agent instances need a shared database.

A PostgreSQL adapter would enable multi-process and distributed deployments.

Design considerations

  • The MemoryStore class in src/store/store.ts is the abstraction boundary. A PG adapter should implement the same interface.
  • PostgreSQL has tsvector for full-text search (replaces FTS5)
  • PostgreSQL has pgvector extension for vector similarity search (replaces sqlite-vec)
  • Migrations should be separate from SQLite migrations
  • The adapter should be an optional dependency (don't break the zero-dependency SQLite default)

Suggested approach

  1. Extract a StorageAdapter interface from the current MemoryStore methods
  2. Keep existing SQLite implementation as the default
  3. Add a new pg-store.ts that implements the same interface using pg + pgvector
  4. Let users choose via config: { adapter: 'sqlite' | 'postgres', connectionString: '...' }

This is a significant contribution

This is a larger piece of work suited for someone comfortable with both SQLite and PostgreSQL. Happy to pair on the interface design before implementation starts — open a draft PR or comment here.

Acceptance criteria

  • Same test suite passes against both SQLite and PostgreSQL adapters
  • PostgreSQL adapter uses pgvector for similarity search
  • PostgreSQL adapter uses tsvector for full-text search
  • SQLite remains the default with zero extra dependencies
  • Documentation for PostgreSQL setup

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions