Skip to main content

Personal Knowledge Base

The Problem

Developers accumulate knowledge across projects, documentation, Slack threads, and code comments — but it's scattered. When you need to recall a decision made six months ago or find how you solved a specific problem, you either search through dozens of tabs or re-discover it from scratch.

The Solution

Use Memsolus as a personal second brain. Ingest documents and notes, search semantically, and explore how concepts connect through the knowledge graph.

Implementation

Install the SDK

npm install @memsolus/sdk

Initialize the client

import { Memsolus } from '@memsolus/sdk';

const memsolus = new Memsolus({
apiKey: process.env.MEMSOLUS_API_KEY,
});

const USER_ID = 'dev_personal';

Store technical notes as memories

Store individual facts, decisions, and notes directly:

await memsolus.memories.add({
content:
'PostgreSQL BRIN indexes work well for time-series data with natural insertion order. ' +
'Used this on the events table in the analytics service — reduced index size by 90%.',
userId: USER_ID,
metadata: {
topic: 'postgresql',
project: 'analytics-service',
},
});

await memsolus.memories.add({
content:
'Decided to use Zod for runtime validation instead of class-validator. ' +
'Zod composes better with TypeScript inference and does not require decorators.',
userId: USER_ID,
metadata: {
topic: 'typescript',
decision: true,
},
});

Ingest documents and files

For longer documents like README files, architecture docs, or blog posts, use data ingestion:

// Ingest a URL
await memsolus.ingestion.ingestUrl({
url: 'https://docs.postgresql.org/16/indexes-brin.html',
userId: USER_ID,
metadata: { topic: 'postgresql', source: 'official-docs' },
});

// Ingest raw text (e.g., content from a local file)
import { readFileSync } from 'fs';

const archDoc = readFileSync('./architecture-decision-record.md', 'utf-8');

await memsolus.ingestion.ingestText({
content: archDoc,
userId: USER_ID,
metadata: { topic: 'architecture', project: 'backend-migration' },
});

Search with semantic and keyword modes

Find knowledge by meaning, not just exact words:

// Semantic search — finds conceptually related memories
const semanticResults = await memsolus.memories.search({
query: 'database indexing strategies for large tables',
userId: USER_ID,
mode: 'semantic',
limit: 5,
});

semanticResults.data.forEach((memory) => {
console.log(`[${memory.score.toFixed(2)}] ${memory.content}`);
});

// Hybrid search — combines semantic and keyword matching
const hybridResults = await memsolus.memories.search({
query: 'Zod validation TypeScript',
userId: USER_ID,
mode: 'hybrid',
limit: 5,
});

Explore the knowledge graph

Discover connections between concepts:

// Find entities related to a topic
const graphResults = await memsolus.graph.search({
query: 'PostgreSQL',
userId: USER_ID,
});

graphResults.nodes.forEach((node) => {
console.log(`${node.name} (${node.type})`);
});

// Traverse from a specific entity to find related concepts
const postgresNode = graphResults.nodes[0];

const related = await memsolus.graph.traverse({
entityId: postgresNode.id,
userId: USER_ID,
depth: 2,
});

related.edges.forEach((edge) => {
console.log(`${edge.from} --[${edge.relation}]--> ${edge.to}`);
});
// => PostgreSQL --[used_in]--> analytics-service
// => PostgreSQL --[related_to]--> BRIN indexes
// => analytics-service --[uses]--> time-series data

Get your compiled knowledge profile

Retrieve everything compiled into a structured document:

const knowledge = await memsolus.knowledge.get({
userId: USER_ID,
merged: true,
});

console.log(knowledge.content);
// => Structured markdown with all your technical knowledge,
// organized by topic and with key decisions highlighted

Export your knowledge base

Export all your knowledge to Markdown for backup or offline use:

const exportJob = await memsolus.exports.create({
userId: USER_ID,
format: 'markdown',
});

// Poll for completion
let exportResult = await memsolus.exports.get(exportJob.id);

while (exportResult.status === 'pending' || exportResult.status === 'processing') {
await new Promise((resolve) => setTimeout(resolve, 2000));
exportResult = await memsolus.exports.get(exportJob.id);
}

console.log('Export ready:', exportResult.downloadUrl);

CLI Script Example

Here is a complete script to build a knowledge base from a directory of Markdown files:

import { readFileSync, readdirSync } from 'fs';
import { join, extname } from 'path';
import { Memsolus } from '@memsolus/sdk';

const memsolus = new Memsolus({ apiKey: process.env.MEMSOLUS_API_KEY });
const USER_ID = 'dev_personal';
const NOTES_DIR = './notes';

async function ingestNotesDirectory(): Promise<void> {
const files = readdirSync(NOTES_DIR).filter((f) => extname(f) === '.md');

console.log(`Ingesting ${files.length} files...`);

for (const file of files) {
const content = readFileSync(join(NOTES_DIR, file), 'utf-8');
const topic = file.replace('.md', '');

await memsolus.ingestion.ingestText({
content,
userId: USER_ID,
metadata: { topic, source: 'local-notes' },
});

console.log(`Ingested: ${file}`);
}

console.log('Done. Memsolus will process and index your notes automatically.');
}

ingestNotesDirectory().catch(console.error);

Run it:

MEMSOLUS_API_KEY=msk_live_... npx tsx ingest-notes.ts

What's Next