Repository navigation
Scenario 1 Knowledge Base Building
Martin Schultheiss edited this page Nov 25, 2025
·
1 revision
Learn how to use Context Processor to organize and enhance a documentation knowledge base.
This scenario walks through:
- Creating multiple contexts (documentation articles)
- Organizing with tags and relationships
- Searching and filtering
- Updating and managing contexts
- Discovering related content
Time: ~10 minutes | Complexity: Beginner
You're building a technical documentation knowledge base:
- Multiple articles and guides
- Need to organize by topic
- Want to discover relationships between articles
- Need to update content over time
- Want to search efficiently
import { ContextProcessor } from "context-processor";
const processor = new ContextProcessor();
// Article 1: React Basics
const reactBasics = processor.save({
title: "React Fundamentals",
content: "React is a JavaScript library for building user interfaces with components...",
tags: ["react", "basics", "javascript"],
metadata: { category: "Frontend", difficulty: "Beginner" }
});
// Article 2: React Hooks
const reactHooks = processor.save({
title: "React Hooks Guide",
content: "Hooks allow you to use state in functional components...",
tags: ["react", "hooks", "advanced"],
metadata: { category: "Frontend", difficulty: "Intermediate" }
});
// Article 3: TypeScript
const typescript = processor.save({
title: "TypeScript for React",
content: "TypeScript adds type safety to JavaScript...",
tags: ["typescript", "react", "types"],
metadata: { category: "Frontend", difficulty: "Intermediate" }
});
console.log("Created 3 knowledge base articles");// List all React-related articles
const reactDocs = processor.search({ tags: ["react"] });
console.log(`Found ${reactDocs.length} React articles`);
// List all beginner content
const beginnerDocs = processor.list()
.filter(doc => doc.metadata?.difficulty === "Beginner");
console.log(`Found ${beginnerDocs.length} beginner articles`);
// Show all available tags
const allDocs = processor.list();
const allTags = new Set(allDocs.flatMap(doc => doc.tags));
console.log("Available tags:", Array.from(allTags));Apply pre-processing to improve searchability:
// Re-save with clarification strategy
processor.save({
id: reactBasics.id,
title: "React Fundamentals",
content: reactBasics.content,
tags: ["react", "basics", "javascript"],
metadata: reactBasics.metadata
}, "search_optimized");
console.log("Enhanced with search optimization");Find related articles:
// Articles related to reactHooks
const hooks = processor.load(reactHooks.id);
const relatedByTag = processor.search({ tags: hooks.tags })
.filter(doc => doc.id !== hooks.id);
console.log(`Found ${relatedByTag.length} related articles`);// Update existing content
const updated = processor.save({
...reactHooks,
content: reactHooks.content + "\n\nUpdated with new examples.",
tags: [...reactHooks.tags, "updated-2025"]
});
// Delete when no longer needed
processor.delete(typescript.id);
console.log("Knowledge base updated!");✅ Organize - Use tags and metadata for structure
✅ Enhance - Apply strategies for better searchability
✅ Discover - Find relationships between content
✅ Manage - Update and delete as needed
✅ Scale - Easy to handle hundreds of articles
- Try Scenario 2 - Process individual content
- Review API Reference
- Check Troubleshooting
Ready for more? Let's process some content in Scenario 2!