MemoGrafter is a server-side TypeScript library that gives chatbots long-term, topic-aware memory without replaying the full conversation history into every prompt.
It turns conversations into structured memory nodes, links related topics in a graph, and injects only the most relevant memory when the chatbot needs context.
| Area | Details |
|---|---|
| Type | TypeScript / Node.js library |
| Focus | Chatbot memory, graph retrieval, memory grafting |
| Storage | PostgreSQL + pgvector |
| Providers | OpenAI, Anthropic, Gemini, custom adapters |
| GitHub | mayhemking007/memo-grafter |
| NPM | https://www.npmjs.com/package/memo-grafter |
Most chatbots forget anything outside the current context window. MemoGrafter solves this by converting long conversations into compact, searchable topic memory.
Its key idea is memory grafting: one chatbot or session can selectively absorb useful memory from another without copying the entire history.
+----------------------+
| Chatbot App |
| invoke(user input) |
+----------+-----------+
|
v
+----------------------+
| MemoGrafterAgent |
| memory-aware chat |
+----------+-----------+
|
+------------------+------------------+
| |
v v
+------------------+ +------------------+
| Ingest Pipeline | | Grafter Pipeline |
| build memory | | retrieve memory |
+--------+---------+ +--------+---------+
| |
v v
+------------------+ +------------------+
| Topic Detection | | Relevant Nodes |
| Segmentation | | Graph Neighbours |
| Summarization | | Token Budgeting |
+--------+---------+ +--------+---------+
| |
+------------------+------------------+
|
v
+----------------------+
| PostgresGraphStore |
| messages, nodes, |
| embeddings, edges |
+----------+-----------+
|
v
+----------------------+
| PostgreSQL + pgvector|
+----------------------+
External adapters:
- LLM adapter: summarizes segments and generates chatbot responses
- Embedding adapter: converts messages and memory nodes into vectors
| Component | Role |
|---|---|
MemoGrafter | Low-level memory core. |
MemoGrafterAgent | Chatbot wrapper with invoke(), ingestion, and grafting. |
IngestPipeline | Converts conversations into topic memory. |
TopicDriftDetector | Detects topic changes and reentry. |
GrafterPipeline | Builds memory prompts from retrieved nodes. |
PostgresGraphStore | Stores messages, embeddings, nodes, and graph edges. |
MemoGrafterFleet | Enables memory sharing across multiple chatbots. |
MemoGrafterAgent.invoke().MemoGrafter is my flagship AI infrastructure project. It shows my ability to design reusable backend systems for LLM applications, especially around memory, retrieval, embeddings, graph storage, and prompt construction.