Database / Memory

PostgreSQL + pgvector for data, Redis + BullMQ for jobs, PHI vault for medical data

What It Does

The storage layer underpins everything. Three distinct systems handle different kinds of data:

External Service Details

Journeys

The database layer supports all 10 patient and operational journeys:

Key Source Files

Memory Search System

Karen uses a hybrid search approach to retrieve relevant memory. All four methods are combined via Reciprocal Rank Fusion (RRF) to produce a single ranked result set:

  1. searchVector() — pgvector semantic similarity. Converts the query to an embedding and finds the nearest stored vectors. Best for meaning-based retrieval ("what did this patient ask about last time").
  2. searchKeyword() — PostgreSQL full-text search (tsvector/tsquery). Best for exact term matching ("Botox", procedure names, contact names).
  3. searchTags() — Tag-based filtering. Memories can be tagged by category (e.g. care_plan, booking, complaint) for fast scoped retrieval.
  4. searchExact() — Exact string match against indexed fields. Used for lookups by ID, phone number, or known unique values.

The combined hybridSearch() function (line 125 of src/memory.js) runs all four in parallel and merges the ranked results before returning to the context builder.

Known Issues

core_memory.js:161 — owner_tenant_id bug outstanding. There is an unresolved bug on line 161 of src/core_memory.js related to owner_tenant_id. This affects how per-tenant core memory (persona, goals) is read back. Do not rely on getCoreMemory() returning the correct owner context until this is patched.