Build a Knowledge Base
Create a searchable knowledge base for your team or product documentation using Hypersave.
What You'll Build
- A system to ingest and organize documentation
- Semantic search across all content
- AI-powered question answering
- Automatic entity and fact extraction
Use Cases
- Team wikis and internal documentation
- Product documentation portals
- Customer support knowledge bases
- Research note repositories
Set Up Content Ingestion
Create a script to ingest your existing content:
// ingest.js
const HYPERSAVE_API = 'https://api.hypersave.io';
const API_KEY = process.env.HYPERSAVE_API_KEY;
async function ingestDocument(doc) {
const response = await fetch(`${HYPERSAVE_API}/v1/save`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
content: doc.content,
title: doc.title,
tags: doc.tags,
metadata: {
source: doc.source,
category: doc.category,
lastUpdated: new Date().toISOString()
}
}),
});
return response.json();
}
// Bulk ingest multiple documents
async function bulkIngest(documents) {
const response = await fetch(`${HYPERSAVE_API}/v1/ingest`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
items: documents.map(doc => ({
content: doc.content,
title: doc.title,
tags: doc.tags,
metadata: doc.metadata
})),
async: true
}),
});
return response.json();
}Ingest from URLs
async function ingestFromUrl(url, tags = []) {
const response = await fetch(`${HYPERSAVE_API}/v1/save`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
url,
tags: ['documentation', ...tags]
}),
});
return response.json();
}
// Example: Ingest your docs
const docUrls = [
'https://docs.yourproduct.com/getting-started',
'https://docs.yourproduct.com/api-reference',
'https://docs.yourproduct.com/tutorials',
];
for (const url of docUrls) {
await ingestFromUrl(url, ['product-docs']);
}Create the Search API
// search.js
async function searchKnowledgeBase(query, options = {}) {
const response = await fetch(`${HYPERSAVE_API}/v1/search`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query,
limit: options.limit || 10,
threshold: options.threshold || 0.6,
tags: options.tags,
hybrid: true // Use hybrid search for best results
}),
});
return response.json();
}
async function askQuestion(question) {
const response = await fetch(`${HYPERSAVE_API}/v1/ask`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
query: question,
includeContext: true
}),
});
return response.json();
}Build the Frontend
Create a simple search interface:
// SearchInterface.jsx
import { useState } from 'react';
export default function KnowledgeSearch() {
const [query, setQuery] = useState('');
const [results, setResults] = useState([]);
const [answer, setAnswer] = useState('');
const [loading, setLoading] = useState(false);
const handleSearch = async () => {
setLoading(true);
// Search for relevant documents
const searchRes = await fetch('/api/search', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query })
});
const { results } = await searchRes.json();
setResults(results);
// Get AI answer
const askRes = await fetch('/api/ask', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query })
});
const { answer } = await askRes.json();
setAnswer(answer);
setLoading(false);
};
return (
<div className="max-w-4xl mx-auto p-6">
<h1 className="text-2xl font-bold mb-6">Knowledge Base</h1>
<div className="flex gap-2 mb-6">
<input
type="text"
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search or ask a question..."
className="flex-1 p-3 border rounded-lg"
onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
/>
<button
onClick={handleSearch}
disabled={loading}
className="px-6 py-3 bg-blue-600 text-white rounded-lg"
>
{loading ? 'Searching...' : 'Search'}
</button>
</div>
{answer && (
<div className="bg-blue-50 p-4 rounded-lg mb-6">
<h2 className="font-semibold mb-2">AI Answer</h2>
<p>{answer}</p>
</div>
)}
<div className="space-y-4">
{results.map((result) => (
<div key={result.id} className="border p-4 rounded-lg">
<h3 className="font-semibold">{result.title}</h3>
<p className="text-gray-600 mt-1">{result.content}</p>
<div className="flex gap-2 mt-2">
{result.tags?.map(tag => (
<span key={tag} className="text-xs bg-gray-100 px-2 py-1 rounded">
{tag}
</span>
))}
</div>
</div>
))}
</div>
</div>
);
}Organization Strategies
Using Tags
// Organize by category
const doc = {
content: '...',
tags: [
'category:api-reference',
'product:billing',
'version:v2'
]
};
// Search within a category
const results = await searchKnowledgeBase('authentication', {
tags: ['category:api-reference']
});Using Spaces
Create separate spaces for different knowledge areas:
// Save to specific space
await fetch(`${HYPERSAVE_API}/v1/save`, {
method: 'POST',
headers: { /* ... */ },
body: JSON.stringify({
content: '...',
spaceId: 'space_engineering_docs'
}),
});Best Practices
Knowledge Base Tips:
- Keep documents focused — one topic per document
- Use consistent tagging for easy filtering
- Update documents regularly to keep content fresh
- Add clear titles and descriptions for better search
Next Steps
- RAG Application — Use your knowledge base for AI responses
- Best Practices — Optimize your implementation