
Building Modular React Blocks with WCAG AAA Accessibility Using Agent Skills
Where to Put Skills in Your Project Most agents look for project skills inside a hidden folder at th...
Loading page...

Published on: 11 November 2026
You can break down this code for your readers into four key architectural steps:
const basicInfo = await BasicInfoModel.findOne().select('name email bio about_me phone linked_in_url github_url website_url').lean().exec();
const document = [
`My Name is ${basicInfo.name}`,
`My Email Address is ${basicInfo.email}`,
...
]Why it matters: Vector databases don't query raw JSON properties as effectively as natural language prose. This step extracts fields from your MongoDB document and formats them into readable, self-contained template sentences.
const doc = MDocument.fromText(document.join('\n'));
const chunks = await doc.chunk({
strategy: 'recursive',
separators: ['\n\n', '\n', ' '],
maxSize: 500,
overlap: 32
});Why it matters: Large documents need to be split into manageable segments (maxSize: 500 characters) so that semantic searches pinpoint exact contexts. The overlap: 32 ensures context isn't lost across chunk boundaries.
const {embeddings} = await embedMany({
values: chunkTexts,
model: ollama.embedding('nomic-embed-text')
});Why it matters: This translates chunks of text into high-dimensional numerical arrays (vectors) using an embedding model (here, running locally via Ollama with nomic-embed-text).
await VectorStoreModel.deleteMany({ source: 'basic-info' });
const docToInser = chunkTexts.map((text, index) => ({
docId: `basic-info:${index.toString()}`,
source: 'basic-info',
text,
vector: embeddings[index],
chunkIndex: index
}));
await VectorStoreModel.insertMany(docToInser);Why it matters: Idempotency is crucial for seeding scripts. It first deletes stale vectors matching the 'basic-info' source tag, maps the generated embeddings to structured objects, and bulk-inserts them back into MongoDB for rapid $vectorSearch execution later.

Where to Put Skills in Your Project Most agents look for project skills inside a hidden folder at th...

Designing dynamic forms that scale efficiently while managing validation can be tricky. React Hook F...

In a modern development context, i18n (internationalization) is used to make applications adaptable ...