<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr" -->

---
title: How To Build Your Own RAG AI System - Better Results...
description: A comprehensive walkthrough of building a RAG (Retrieval Augmented Generation) system that ingests YouTube videos and blog articles, enabling semantic search...
canonical: https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How To Build Your Own RAG AI System - Better Results Than Claude | daily.dev
og:description: A comprehensive walkthrough of building a RAG (Retrieval Augmented Generation) system that ingests YouTube videos and blog articles, enabling semantic search...
og:url: https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr
og:image: https://api.daily.dev/og/posts/dXLhgtpRR.png
og:image:alt: How To Build Your Own RAG AI System - Better Results Than Claude
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How To Build Your Own RAG AI System - Better Results Than Claude

**[Web Dev Simplified](https://daily.dev/sources/wds)** · 187 min read · 10 upvotes · 0 comments

## Summary

A comprehensive walkthrough of building a RAG (Retrieval Augmented Generation) system that ingests YouTube videos and blog articles, enabling semantic search with timestamp-level precision. The tutorial covers the full production pipeline using Next.js, Neon (PostgreSQL with vector search), Vercel workflows for durable background tasks, Drizzle ORM, and Better Auth for GitHub OAuth. Key practices demonstrated include upfront project planning before using AI, typed environment variables with T3 Env, branch protection rules, separate dev/prod environments, and using AI coding agents with skills/context files for targeted code generation rather than blind prompting.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=1mvlBz6pj1I>

## Questions this post answers

### How should I chunk blog articles for a RAG system to get good retrieval quality?

Chunk blog content by H2 heading boundaries rather than fixed-size windows, so each chunk contains contextually related text under a single heading. This keeps chunks naturally sized when articles have many headings, gives the embedding model coherent, topically-consistent text per chunk, and improves retrieval accuracy compared to arbitrary splitting.

_Developers refining RAG chunking strategies can find implementation walkthroughs like this one on daily.dev._

### Why would a vector search return no results even though the query looks correct with Drizzle and pgvector?

A common cause is using the wrong cosine similarity formula: pgvector's cosine distance operator gives distance, not similarity, so similarity must be computed as one minus the cosine distance rather than dividing or applying extra transformations. Also ensure the pgvector extension is created via a migration and that embedding dimensions (1024 for a local Qwen model versus 1536 for OpenAI's text-embedding-3-small) match exactly what's stored in the schema.

_Anyone debugging pgvector similarity queries can track fixes like this by following daily.dev for database and search content._

### How can I keep local AI coding costs down while still deploying production-grade embeddings?

Run a lightweight local embedding model such as a 609MB Qwen model in a tool like LM Studio during development, then switch to a hosted API like OpenAI's text-embedding-3-small in production by making the embedding provider configurable through an environment variable. This avoids per-request costs while iterating locally, as long as embedding dimensions are fixed to match whichever provider is used in production.

_Teams weighing local versus hosted embedding models can compare approaches through daily.dev's developer content._

## Similar posts on daily.dev

- [How to Build an AI-Powered RAG Search Application with Next.js, Supabase, and OpenAI](https://daily.dev/posts/how-to-build-an-ai-powered-rag-search-application-with-next-js-supabase-and-openai-twprkjxz1) · freeCodeCamp · 3 upvotes · 0 comments
- [Chat with Your Documents: A Practical Guide to RAG Using the New Laravel AI SDK](https://daily.dev/posts/chat-with-your-documents-a-practical-guide-to-rag-using-the-new-laravel-ai-sdk-xrytwkwo0) · Tighten · 0 upvotes · 0 comments
- [Building a RAG Application with Spring Boot, Spring AI, MongoDB Atlas Vector Search, and OpenAI](https://daily.dev/posts/building-a-rag-application-with-spring-boot-spring-ai-mongodb-atlas-vector-search-and-openai-vhyy5w1do) · InfoQ · 2 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql), [#nextjs](https://daily.dev/tags/nextjs), [#rag](https://daily.dev/tags/rag), [#vector-search](https://daily.dev/tags/vector-search), [#drizzle](https://daily.dev/tags/drizzle)

[View this post on daily.dev](https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How To Build Your Own RAG AI System - Better Results Than Claude","url":"https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr"},"datePublished":"2026-07-14T16:10:12.928Z","dateModified":"2026-09-13T20:53:20.149Z","description":"A comprehensive walkthrough of building a RAG (Retrieval Augmented Generation) system that ingests YouTube videos and blog articles, enabling semantic search...","image":"https://i.ytimg.com/vi/1mvlBz6pj1I/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/1mvlBz6pj1I/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Web Dev Simplified","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Web Dev Simplified","logo":"https://media.daily.dev/image/upload/s--dXRQOCB9--/f_auto/v1718347713/logos/wds","url":"https://daily.dev/sources/wds"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":10},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql,nextjs,rag,vector-search,drizzle","timeRequired":"PT187M","video":{"@type":"VideoObject","name":"How To Build Your Own RAG AI System - Better Results Than Claude","description":"A comprehensive walkthrough of building a RAG (Retrieval Augmented Generation) system that ingests YouTube videos and blog articles, enabling semantic search...","thumbnailUrl":"https://i.ytimg.com/vi/1mvlBz6pj1I/sddefault.jpg","uploadDate":"2026-07-14T16:10:12.928Z","duration":"PT187M","url":"https://api.daily.dev/r/dXLhgtpRR","embedUrl":"https://www.youtube.com/embed/1mvlBz6pj1I"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Web Dev Simplified","item":"https://daily.dev/sources/wds"},{"@type":"ListItem","position":3,"name":"How To Build Your Own RAG AI System - Better Results Than Claude"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-build-your-own-rag-ai-system---better-results-than-claude-dxlhgtprr#faq","mainEntity":[{"@type":"Question","name":"How should I chunk blog articles for a RAG system to get good retrieval quality?","acceptedAnswer":{"@type":"Answer","text":"Chunk blog content by H2 heading boundaries rather than fixed-size windows, so each chunk contains contextually related text under a single heading. This keeps chunks naturally sized when articles have many headings, gives the embedding model coherent, topically-consistent text per chunk, and improves retrieval accuracy compared to arbitrary splitting. Developers refining RAG chunking strategies can find implementation walkthroughs like this one on daily.dev."}},{"@type":"Question","name":"Why would a vector search return no results even though the query looks correct with Drizzle and pgvector?","acceptedAnswer":{"@type":"Answer","text":"A common cause is using the wrong cosine similarity formula: pgvector's cosine distance operator gives distance, not similarity, so similarity must be computed as one minus the cosine distance rather than dividing or applying extra transformations. Also ensure the pgvector extension is created via a migration and that embedding dimensions (1024 for a local Qwen model versus 1536 for OpenAI's text-embedding-3-small) match exactly what's stored in the schema. Anyone debugging pgvector similarity queries can track fixes like this by following daily.dev for database and search content."}},{"@type":"Question","name":"How can I keep local AI coding costs down while still deploying production-grade embeddings?","acceptedAnswer":{"@type":"Answer","text":"Run a lightweight local embedding model such as a 609MB Qwen model in a tool like LM Studio during development, then switch to a hosted API like OpenAI's text-embedding-3-small in production by making the embedding provider configurable through an environment variable. This avoids per-request costs while iterating locally, as long as embedding dimensions are fixed to match whichever provider is used in production. Teams weighing local versus hosted embedding models can compare approaches through daily.dev's developer content."}}]}
```

