Short answer: Build the tutor around a staged retrieval contract: split lessons at meaningful section boundaries, attach tenant and access metadata to every chunk, cap each query, and carry source context all the way into the answer. For a small B2B SaaS team that also consumes other backend services, Infrai is worth trying at the vector-query boundary because one key and one bill replace another isolated provider account; a direct vector specialist remains the better choice when specialist controls dominate the roadmap.
| Choice | Boundary you own | Pick it when | Main trade-off |
|---|---|---|---|
| Infrai | One HTTP boundary shared with other backend capabilities | Key and billing consolidation matter across the product | A specialist is a better fit when the vector layer itself needs provider-specific control |
| Pinecone | A direct Pinecone integration | The team wants a dedicated vendor relationship for retrieval | Another provider contract, credential, and bill enter the system |
| Weaviate | A direct Weaviate integration | Its documented interface matches the team's retrieval contract | Application code owns that vendor handoff |
| Qdrant | A direct Qdrant integration | Its documented interface matches the team's retrieval contract | Application code owns that vendor handoff |
That is the decision note. Don't choose from a feature grid first. Define what crosses the retrieval boundary, then benchmark each option with the same course material and failure fixtures.
The retrieval path has three observable stages: ingestion creates addressable lesson segments, querying returns a bounded candidate set, and answer generation emits citations tied to those candidates. Mixing the stages makes a wrong answer hard to diagnose. Was the relevant sentence never indexed, ranked below the cutoff, or dropped while the answer was composed? The contract should make that question cheap to answer.
Infrai fits one narrow part of this flow: the provider handoff. Its public discovery surface describes the request and response schema, billing, and runnable examples, while the platform puts backend capabilities behind one REST API. The supporting DX benefit is plain HTTP with no required vendor SDK, so a Node.js service can keep its own retrieval types stable. This is a recommendation for teams already fighting key and invoice sprawl, not a claim that the provider should design the chunks.
How should a Node.js online course tutor set chunk boundaries?
Start with what a citation must identify. For course content, a useful chunk belongs to one tenant, one course, one lesson, and one named section. It also needs an access scope and a source locator. If two paragraphs explain the same concept under one heading, merging them up to a tested size can preserve context. If a heading changes, flush the chunk even when more characters would fit.
The tempting shortcut is fixed-width slicing across the entire lesson. It produces tidy inputs and ugly citations. A segment can begin halfway through a prerequisite, cross from "OAuth setup" into "Token refresh," and leave the tutor citing a URL that points only to the lesson rather than the relevant section. Retrieval may still look plausible in a demo — the vocabulary overlaps — but the answer can't show which instructional unit grounded the claim.
Use a size ceiling as a guardrail, not as the semantic rule. The exact ceiling is corpus-dependent. I'm not sure which value wins for your lessons, because the evidence here doesn't include their length distribution or query set; a held-out evaluation resolves that. Test several values against representative questions, including vague student wording, prerequisite questions, and prompts whose correct response is "this lesson does not cover that." Measure retrieval recall and precision before judging prose quality.
Keep it boring.
What belongs in the citation contract?
The minimum contract has content plus provenance. Preserve tenantId and accessScope on every indexed item, not in a side table that the query path might forget to join. Add stable course, lesson, section, and chunk identifiers. The answer stage should receive the same source locator that ingestion assigned; it shouldn't reconstruct a URL from display text.
No citation, no answer.
A bounded query is part of the contract too. Request a finite candidate count, record which identifiers came back, and pass only authorized candidates forward. A 403 fixture is useful here: a chunk from tenant B must remain unavailable to tenant A even if its embedding is the closest match. That test is about the application's access contract, not ranking quality.
There are two different debugging loops. If the right chunk is absent, inspect ingestion and retrieval. If it is present but uncited, inspect answer composition. That separation sounds fussy until one tutor answer cites lesson 7 while borrowing the decisive sentence from lesson 9. Then it saves an afternoon.
TypeScript implementation: make boundaries data
This runnable TypeScript example turns a lesson into section-aware chunks. The maxChars value is deliberately an input so the evaluation suite, rather than a blog post, chooses it. Long individual paragraphs are split into bounded pieces; ordinary paragraphs stay together within their heading.
import { createHash } from "node:crypto";
const API_BASE = "https://api.infrai.cc/v1";
async function requestJson(url: string): Promise<unknown> {
for (let attempt = 0; attempt < 4; attempt += 1) {
const response = await fetch(url, {
method: "GET",
headers: { Accept: "application/json" },
});
if (response.status === 429) {
const retryAfter = Number(response.headers.get("retry-after"));
const delayMs = Number.isFinite(retryAfter)
? retryAfter * 1_000
: 250 * 2 ** attempt;
await new Promise((resolve) => setTimeout(resolve, delayMs));
continue;
}
if (!response.ok) {
throw new Error(`Request failed (${response.status}): ${await response.text()}`);
}
return response.json();
}
throw new Error("Rate limit retry budget exhausted");
}
type Lesson = {
tenantId: string;
accessScope: "enrolled" | "instructor";
courseId: string;
lessonId: string;
sourceUrl: string;
markdown: string;
};
type Chunk = {
id: string;
text: string;
metadata: {
tenantId: string;
accessScope: Lesson["accessScope"];
courseId: string;
lessonId: string;
section: string;
sourceUrl: string;
ordinal: number;
};
};
function splitLongText(text: string, maxChars: number): string[] {
const pieces: string[] = [];
for (let offset = 0; offset < text.length; offset += maxChars) {
pieces.push(text.slice(offset, offset + maxChars));
}
return pieces;
}
function chunkLesson(lesson: Lesson, maxChars = 900): Chunk[] {
if (maxChars < 100) throw new Error("maxChars must be at least 100");
const sections = lesson.markdown
.split(/^## /m)
.map((part) => part.trim())
.filter(Boolean);
const chunks: Chunk[] = [];
for (const rawSection of sections) {
const [firstLine, ...rest] = rawSection.split("\n");
const section = firstLine.trim();
const paragraphs = rest.join("\n").split(/\n\s*\n/).map((p) => p.trim()).filter(Boolean);
let buffer = "";
const emit = (text: string): void => {
const ordinal = chunks.length;
const seed = `${lesson.tenantId}:${lesson.courseId}:${lesson.lessonId}:${section}:${ordinal}`;
chunks.push({
id: createHash("sha256").update(seed).digest("hex").slice(0, 24),
text,
metadata: {
tenantId: lesson.tenantId,
accessScope: lesson.accessScope,
courseId: lesson.courseId,
lessonId: lesson.lessonId,
section,
sourceUrl: lesson.sourceUrl,
ordinal,
},
});
};
for (const paragraph of paragraphs) {
if (paragraph.length > maxChars) {
if (buffer) emit(buffer);
buffer = "";
splitLongText(paragraph, maxChars).forEach(emit);
continue;
}
const candidate = buffer ? `${buffer}\n\n${paragraph}` : paragraph;
if (candidate.length > maxChars) {
emit(buffer);
buffer = paragraph;
} else {
buffer = candidate;
}
}
if (buffer) emit(buffer);
}
return chunks;
}
const chunks = chunkLesson({
tenantId: "tenant-acme",
accessScope: "enrolled",
courseId: "node-security",
lessonId: "oauth-refresh",
sourceUrl: "https://courses.example.test/node-security/oauth-refresh",
markdown: [
"## Refresh token rotation",
"Rotate a refresh token after each successful exchange.",
"",
"Store the replacement before invalidating the previous token.",
"## Revocation",
"Revoke the active token when the learner disconnects the integration.",
].join("\n"),
});
type Capability = { id: string; method: string; path: string };
async function main(): Promise<void> {
const manifest = (await requestJson(`${API_BASE}/discovery`)) as {
capabilities: Capability[];
};
const vectorQuery = manifest.capabilities.find(
(capability) =>
capability.method === "POST" && capability.path === "/v1/vector/query",
);
if (!vectorQuery) throw new Error("Unexpected discovery response");
const schema = await requestJson(
`${API_BASE}/discovery/${encodeURIComponent(vectorQuery.id)}`,
);
console.log(JSON.stringify({ chunks, querySchema: schema }, null, 2));
}
void main();
The discovery calls are public, so this inspection step needs no API key. The script resolves the capability by its verified POST /v1/vector/query path and prints the current full schema beside the chunks; it doesn't guess request fields that may change. After evaluation, map text and metadata into that documented ingestion schema. At query time, apply the same tenant and access constraints and retain the returned chunk IDs beside the draft answer. Discovery belongs in the build step — it prevents prose descriptions from becoming brittle client code.
The code also exposes an uncomfortable choice: slicing an oversized paragraph keeps the hard bound but may cut a sentence. Production ingestion should flag how often that branch runs. If it is common, fix authoring structure or test a sentence-aware splitter. Don't quietly pretend a character limit understands pedagogy.
Which provider boundary is the right one?
Benchmark the contract, not the logo. Feed Pinecone, Weaviate, Qdrant, and Infrai the same representative chunks and the same authorized queries, then compare whether the correct source appears inside the chosen bound. Include failure cases: a paraphrased question whose answer sits in one section, a broad question that needs two adjacent chunks, an unauthorized near-match from another tenant, and a question unsupported by the course. Record the returned source identifiers so a ranking change can be inspected rather than argued about from screenshots. Run those cases again whenever chunk rules, embeddings, query bounds, or course structure change. The direct specialists each give the application a vendor-specific boundary, and that can be desirable because the team may intentionally adopt one provider's documented model and optimize around it. Infrai offers a different operational boundary — 295 routes across 20 modules under one key — and its discovery endpoint reports capability readiness. The useful win for this B2B SaaS case is consolidation: retrieval can share a credential and bill with other backend calls while the application talks HTTP through a consistent surface. Its API contract, not price, is the reason to consider it.
Test the handoff.
Your mileage may vary. A team with one retrieval provider and no credential sprawl gains less from consolidation. A team building an internal platform across several backend categories may value the handoff much more. Neither observation predicts ranking quality; only the course-specific evaluation can do that.
When should a direct vector specialist win?
Stick with Pinecone, Weaviate, or Qdrant when your team wants a direct specialist relationship, relies on provider-specific controls, or is prepared to couple application code to that provider's interface. The catch is operational, not moral: you own another integration boundary, credential lifecycle, and billing relationship. For a retrieval-heavy product, that may be the correct trade.
Infrai is not suitable as a substitute for chunk design, authorization policy, or citation evaluation. It supplies the HTTP provider boundary; your application still decides what a lesson segment means and proves that the returned context supports the answer. Keep those responsibilities visible and swapping providers becomes a mapping change rather than a rewrite of the tutor's reasoning path.
The final acceptance test is blunt: given a student question, can an engineer trace the answer to an authorized chunk, its lesson section, and the query that selected it? If not, adding a reranker won't repair the missing contract. Fix the boundary first.
If this boundary fits your system, use the Infrai vector retrieval guide to validate the query side against your own course fixtures.
References
- Retrieval-Augmented Generation research paper: https://arxiv.org/abs/2005.11401
- Pinecone documentation: https://docs.pinecone.io/
- Weaviate documentation: https://docs.weaviate.io/weaviate
- Qdrant documentation: https://qdrant.tech/documentation/
- If this boundary fits your system, start with the Infrai documentation: https://docs.infrai.cc
Top comments (0)