Learning Retrieval-Augmented Generation (RAG) by building the entire pipeline from scratch.
This project was built to understand how modern Retrieval-Augmented Generation (RAG) systems actually work internally, instead of relying on high-level AI frameworks.
Rather than treating RAG as a black box, I implemented every stage manually---from loading documents to chunking, embedding generation, semantic retrieval, prompt construction, and answer generation.
The goal was not to build the most feature-rich chatbot, but to deeply understand the engineering behind production AI systems.
This repository represents the RAG phase of my AI Engineering learning roadmap.
Instead of simply calling an LLM API, I wanted to understand:
- Document ingestion
- Recursive text chunking
- Embeddings
- Vector representations
- Semantic Search
- Cosine Similarity
- Retrieval Pipelines
- Prompt Construction
- Context Grounding
- Hallucination Reduction
- Embedding Caching
- Modular AI Architecture
β Markdown Loader
β Recursive Chunking
β Gemini Embeddings
β Embedding Cache
β In-Memory Vector Store
β Cosine Similarity Search
β Semantic Retrieval
β Prompt Builder
β Groq LLM Integration
β Interactive CLI Chat
- Node.js
- JavaScript (ES Modules)
- Gemini Embeddings API
- Groq LLM
- @google/genai
- groq-sdk
- @langchain/textsplitters
- Retrieval-Augmented Generation
- Embeddings
- Semantic Search
- Cosine Similarity
- Prompt Engineering
- Chunking
- Metadata
- Vector Search
- Context Grounding
docs/
src/
βββ chat/
βββ embeddings/
βββ llm/
βββ loaders/
βββ persistence/
βββ prompts/
βββ retrieval/
βββ splitters/
βββ vectorstore/
βββ index.js
cache/
README.md
package.json
Decision Reason
Markdown Documents Easy custom knowledge base Recursive Splitter Preserve semantic meaning Gemini Embeddings High-quality semantic vectors Groq Fast inference with generous free tier Local Cache Avoid recomputing embeddings In-Memory Store Learn retrieval before using vector DBs Modular Architecture Separation of concerns
- Retrieval-Augmented Generation (RAG)
- Recursive Chunking
- Embeddings
- Semantic Search
- Cosine Similarity
- Prompt Construction
- Vector Persistence
- Source Attribution
- Embedding Cache
- Retrieval Pipeline
- Understanding vector embeddings
- Selecting chunk size and overlap
- Choosing similarity thresholds
- Preserving metadata through chunking
- Working around Gemini free-tier limits
- Designing a modular AI pipeline
This project taught me that building AI applications involves much more than calling an LLM API.
Key takeaways:
- Why embeddings capture semantic meaning
- Why semantic search outperforms keyword search
- How chunking affects retrieval quality
- How grounding reduces hallucinations
- Why retrieval and generation should be separate
- Why embedding caching improves performance
- How production RAG pipelines are structured
- Markdown documents only
- In-memory vector store
- No authentication
- No Web UI
- No streaming responses
- No hybrid search
- No metadata filtering
These are intentional because the focus of this project was learning core RAG concepts from first principles.
- PDF Loader
- Website Loader
- DOCX Loader
- ChromaDB
- Pinecone
- Qdrant
- FAISS
- Hybrid Search
- Metadata Filtering
- Query Expansion
- Context Compression
- Conversational Memory
- LangChain RAG
- LangGraph
- AI Agents
- MCP
- Production Deployment
- Built a Retrieval-Augmented Generation (RAG) application from scratch using Node.js.
- Implemented document ingestion, recursive chunking, embedding generation, semantic retrieval, prompt construction, and answer generation.
- Developed an embedding cache to eliminate repeated embedding generation and improve startup performance.
- Integrated Gemini Embeddings and Groq LLM to produce grounded responses with source attribution.
This repository is part of my AI Engineering learning roadmap.
- LLM Fundamentals
- Prompt Engineering
β AI Knowledge Base Chat (RAG)
π¬ MovieMind AI
The next project focuses on learning LangChain by building a production-style AI application with:
- Prompt Templates
- Chat Models
- Messages
- LCEL
- Runnable Interface
- Structured Outputs
- Express Backend Architecture
- React Frontend
The long-term roadmap continues into:
- AI Agents
- LangGraph
- MCP
- Local LLMs
- Production AI Engineering
git clone https://github.com/tanishxdev/AI-Knowledge-Base-Chat-RAG
cd AI-Knowledge-Base-Chat-RAG
npm install
npm run devGEMINI_API_KEY=
GROQ_API_KEY=
GROQ_MODEL=Tanish Kumar
GitHub: https://github.com/tanishxdev
Portfolio: https://thisistanishcodelab.vercel.app/
I enjoy learning backend engineering, distributed systems, DevOps, and modern AI engineering by implementing concepts from first principles before using higher-level frameworks. Each repository in this roadmap builds upon the previous one toward production-ready AI systems.
