The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
Documentation Embeddings Generation System
Verify against live code before depending on any path here. Search
infrastructure is on the known-issues.md list
(decoupled from the markdown export pipeline and considered fragile) —
check there before building on it.
Overview
The documentation embeddings generation system processes various documentation sources and uploads their metadata to a database for semantic search functionality. The system is located in apps/docs/scripts/search/ and works by:
- Discovering content sources from multiple types of documentation
- Processing content into structured sections with checksums
- Generating embeddings using OpenAI's text-embedding-ada-002 model
- Storing in database with vector embeddings for semantic search
Architecture
Main Entry Point
apps/docs/scripts/search/generate-embeddings.ts- Main script that orchestrates the entire process- Supports
--refreshflag to force regeneration of all content
Content Sources (sources/ directory)
Base Classes
BaseLoader- Abstract class for loading content from different sourcesBaseSource- Abstract class for processing and formatting content
Source Types
Markdown Sources (
apps/docs/scripts/search/sources/markdown.ts)- Processes
.mdxfiles from guides and documentation - Extracts frontmatter metadata and content sections
- Processes
Reference Documentation (
apps/docs/scripts/search/sources/reference-doc.ts)- OpenAPI References - Management API documentation from OpenAPI specs
- Client Library References - JavaScript, Dart, Python, C#, Swift, Kotlin SDKs
- CLI References - Command-line interface documentation
- Processes YAML/JSON specs and matches with common sections
GitHub Discussions (
apps/docs/scripts/search/sources/github-discussion.ts)- Fetches troubleshooting discussions from GitHub using GraphQL API
- Uses GitHub App authentication for access
Partner Integrations (
apps/docs/scripts/search/sources/partner-integrations.ts)- Fetches approved partner integration documentation from Supabase database
- Technology integrations only (excludes agencies)
Processing Flow
- Content Discovery: Each source loader discovers and loads content files/data
- Content Processing: Each source processes content into:
- Checksum for change detection
- Metadata (title, subtitle, etc.)
- Sections with headings and content
- Change Detection: Compares checksums against existing database records
- Embedding Generation: Uses OpenAI to generate embeddings for new/changed content
- Database Storage: Stores in
pageandpage_sectiontables with embeddings - Cleanup: Removes outdated pages using version tracking
Database Schema
pagetable: Stores page metadata, content, checksum, versionpage_sectiontable: Stores individual sections with embeddings, token counts
Related
known-issues.md— search infrastructure fragility.llm-agent-parity.md—searchDocscaveats for agents.graphql-endpoint.md— thesearchDocsquery that reads these embeddings.build-pipeline.md— embeddings are generated offline (pnpm run embeddings, run by.github/workflows/search.yml), not as part of the site build.