This starter project provides a robust template for building a custom ChatGPT-style documentation search application using Next.js, OpenAI, and Supabase. It leverages advanced AI capabilities to offer intelligent search functionality over your .mdx documentation files.Key features include: Intelligent Document Processing: Automatically processes .mdx files from your pages directory, chunking them into manageable sections for efficient indexing. OpenAI Embeddings: Utilizes OpenAI's API to create vector embeddings for each document section, capturing semantic meaning. Supabase & pgvector: Stores these high-dimensional embeddings in a PostgreSQL database, enhanced with the pgvector extension, enabling fast and accurate vector similarity searches. Real-time Search: At runtime, user queries are converted into embeddings, which are then used to perform a vector similarity search against your stored document embeddings. This retrieves the most relevant content sections. Contextual AI Responses: The retrieved relevant document content is injected into OpenAI GPT-3 text completion prompts, allowing the AI to generate highly contextual and accurate answers. Streamed Responses: Responses from the OpenAI API are streamed directly to the client, providing a dynamic and responsive user experience. The project outlines a clear workflow: Build Time: Documentation files are pre-processed, and their embeddings are generated and stored in Supabase's PostgreSQL database. A checksum mechanism ensures embeddings are only regenerated when files change. Runtime: User queries trigger an Edge Function that generates a query embedding, performs a vector similarity search in the database, and then uses the retrieved context to formulate a completion request to OpenAI, streaming the AI's response back to the user. This template is ideal for developers looking to quickly implement an AI-powered search solution for their documentation, knowledge bases, or any collection of text-based content, offering a powerful way to enhance user interaction and information retrieval.
Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates





