Skip to content

Scenario 1 Knowledge Base Building

Martin Schultheiss edited this page Nov 25, 2025 · 1 revision

Scenario 1: Building a Knowledge Base

Learn how to use Context Processor to organize and enhance a documentation knowledge base.

Overview

This scenario walks through:

  1. Creating multiple contexts (documentation articles)
  2. Organizing with tags and relationships
  3. Searching and filtering
  4. Updating and managing contexts
  5. Discovering related content

Time: ~10 minutes | Complexity: Beginner


The Use Case

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

Step 1: Create Your Documentation

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");

Step 2: Organize with Tags

// 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));

Step 3: Enhance with Processing

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");

Step 4: Discover Relationships

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`);

Step 5: Update and Manage

// 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!");

Key Takeaways

✅ 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


Next Steps


Ready for more? Let's process some content in Scenario 2!

Clone this wiki locally