Skip to content

Repository files navigation

Engram

Bitemporal, graph-backed memory system for AI coding agents. Captures reasoning traces from Claude Code, Codex CLI, and others into a knowledge graph with full temporal history.

engram_preview.webm

Quick Start

# Prerequisites: Bun v1.3.5+, Docker, Python 3.12+ with uv
git clone https://github.com/ccheney/engram.git
cd engram
bun install
bun run infra:up # Start FalkorDB, Qdrant, NATS, PostgreSQL
bun run dev # Start all services

Verify: Observatory http://localhost:6178 | API http://localhost:6174/v1/health

Architecture

CLI Agents → Ingestion (6175) → NATS → Memory → FalkorDB
↓
Search (6176) → Qdrant
↓
Neural Observatory (6178)

Storage: FalkorDB (graph), Qdrant (vectors), NATS+JetStream (events), PostgreSQL (API keys/usage)

Bitemporal: All graph nodes track vt_start/vt_end (valid time) and tt_start/tt_end (transaction time) for time-travel queries.

Project Structure

Applications

AppPortPurpose
api6174REST API - memory ops, OAuth, rate limiting, OpenTofu state backend
ingestion6175Event parsing from 8+ providers, PII redaction
mcpstdioMCP server - remember/recall/query/context tools
memory-Graph persistence, turn aggregation, NATS consumer
observatory6178Next.js 16 real-time session visualization
console6185Next.js 16 infrastructure management console
search6176Python/FastAPI hybrid search, multi-tier reranking
tuner6177Python/FastAPI Optuna hyperparameter optimization

Packages

PackagePurpose
benchmarkLongMemEval/MTEB/BEIR evaluation suite (Python)
commonUtilities, errors, constants, test fixtures
engram-pluginClaude Code plugin for memory commands
eventsZod schemas for RawStreamEvent/ParsedStreamEvent
graphBitemporal models, repositories, QueryBuilder
infraOpenTofu IaC for Hetzner Cloud deployment
loggerPino structured logging with PII redaction
parserProvider parsers, extractors, redaction
storageFalkorDB, NATS, PostgreSQL, Redis, blob clients
temporalRehydrator, TimeTravelService, ReplayEngine
tsconfigShared TypeScript 7 configuration
tunerTypeScript client/CLI for tuner service
vfsVirtualFileSystem, NodeFileSystem, PatchManager

Commands

# Development
bun run dev # Start all services
bun run infra:up # Start infrastructure (Docker)
bun run infra:down # Stop infrastructure# Build & Test
bun run build # Build all packages
bun run test# Run Vitest tests
bun run typecheck # TypeScript validation
bun run lint # Biome linting
bun run format # Biome formatting# Python servicescd apps/search && uv sync && uv run search
cd apps/tuner && uv sync && uv run tuner

MCP Tools

ToolPurpose
rememberStore memory with type (decision/insight/preference/fact) and tags
recallRetrieve memories via hybrid semantic/keyword search
queryExecute read-only Cypher queries (local mode)
contextComprehensive context assembly for tasks (local mode)
summarizeCondense text using client LLM (requires sampling)
extract_factsParse text into atomic facts (requires sampling)
enrich_memoryAuto-generate summary/keywords/category (requires sampling)

API Endpoints

EndpointMethodScopePurpose
/v1/healthGETPublicHealth check
/v1/memory/rememberPOSTmemory:writeStore memory with deduplication
/v1/memory/recallPOSTmemory:readHybrid search with reranking
/v1/memory/queryPOSTquery:readRead-only Cypher queries
/v1/memory/contextPOSTmemory:readContext assembly
/v1/tofuGET/POSTstate:writeOpenTofu remote state

Providers

Ingestion supports 8+ LLM providers:

ProviderKeyAliases
Anthropicanthropicclaude
OpenAIopenaigpt, gpt-4
Google Geminigemini-
XAI (Grok)xaigrok
Claude Codeclaude_codeclaude-code
Clinecline-
Codexcodex-
OpenCodeopencode-

Infrastructure

All services use Kaprekar's constant (6174) as the base port.

ServicePortCategory
API6174Service
Ingestion6175Service
Search6176Service
Tuner6177Service
Observatory6178Service
FalkorDB6179Database
Qdrant6180Database
NATS6181Database
NATS Monitor6182Dev Tool
PostgreSQL6183Database
Optuna Dashboard6184Dev Tool
Console6185Service

Tech Stack

  • TypeScript: Bun runtime, TypeScript 7 (tsgo), Biome
  • Python: uv, Ruff, FastAPI, Optuna, sentence-transformers
  • Graph: FalkorDB (Redis-based graph DB)
  • Vectors: Qdrant with BGE/SPLADE embeddings
  • Messaging: NATS JetStream
  • Frontend: Next.js 16, React 19, React Flow
  • Auth: OAuth 2.1 with RFC 7662 token introspection

Development

Local OAuth Setup

All services require OAuth authentication in local development for production parity. See Local OAuth Setup Guide for detailed configuration.

Quick start:

# Configure environment (copy template)
cp .env.local.example .env
# Start all services with OAuth
bun run infra:up
# Verify OAuth server
curl http://localhost:6178/api/health

Observatory (port 6178) acts as the OAuth authorization server. All services (search, tuner, api, memory, ingestion) authenticate via token introspection.

License

AGPL-3.0

Releases

Packages

Contributors

Languages