Foundational Agentic RAG is a template-level framework for building secure, document-grounded AI assistants using Retrieval-Augmented Generation (RAG) and agentic reasoning. Designed with scalability and modularity in mind, it enables individuals or organizations to index internal knowledge (PDFs only) and interact with it through a conversational UI. The system is powered by OpenAIβs GPT models, FAISS vector search, LangChain/LangGraph for agent behavior, and a customizable Vite + React frontend with Clerk authentication.
Large Language Models (LLMs) are powerful, but they donβt "know" your private documents by default. Retrieval-Augmented Generation (RAG) fixes that, and Foundational Agentic RAG goes a step further by embedding an agent that can reason through intermediate steps to better answer complex queries.
Instead of just stuffing chunks of documents into prompts, this framework enables a more thoughtful and context-aware interaction with your PDFs, all while being adaptable to your organizationβs branding, models, or access controls.
SOURCE_DOC_DIR
).source_indexing.py
or run_indexing.sh
extracts content and creates a vector index using OpenAI embeddings.IMAGE_DIR
).FAISS_INDEX_DIR
).TOP_K
), and system prompt customization.Foundational Agentic RAG is more than just a chatbot over documents, it's a ready-to-deploy framework that brings the power of LLMs and structured retrieval to real-world use cases. Whether you're an individual exploring agent-based AI, or an organization wanting a secure, private assistant over internal documentation, this project gives you the tools to build fast, think smart, and scale confidently.
Traditional RAG systems retrieve information and immediately use it to answer queries. In contrast, this project implements an agentic RAG using a ReAct-style loop, enabling the agent to reason through multiple steps, akin to a chain-of-thought, before responding. This leads to more accurate, context-sensitive answers.
This decision enhances security, consistency, and content control. Since only the owner uploads documents and runs the indexing script, the application is not meant for end-user file uploads. This suits internal tools or static knowledge bases, but may not fit customer-facing use cases requiring personalized document interactions.
Since all documents are pre-indexed and never leave the ownerβs environment unless explicitly routed through APIs like OpenAI, the system can be deployed in controlled, private infrastructure. Clerk's configurable authentication supports compliance needs such as enterprise SSO, audit trails, and identity verification protocols.
Fine-tuned models may outperform in extremely domain-specific or stylistically rigid tasks (e.g., legal or medical advice) where retrieval context isnβt enough. However, for dynamic or mixed-topic knowledge bases, a RAG system remains more flexible and cost-effective.
The system is modular and horizontally scalable. The vector index (FAISS) can be hosted on higher-end storage or converted into a persistent DB-backed vector store. LangChain supports multiple backends, and the React + FastAPI architecture supports containerization, CI/CD, and horizontal scaling. That said, for extremely large corpora or real-time streaming retrieval, some engineering work (like using distributed vector databases or caching layers) would be needed.
Highly customizable. The system prompt and few-shot examples are directly editable in the backend (app.py
, in rag_agent_node
). Role-based instruction styles can also be used to shape tone, verbosity, or response structure.
The frontend allows visual and brand customization through:
src/colors.css
(theme colors)index.html
and manifest.json
(name, metadata)favicon.ico
, logo192.png
, logo512.png
)App.jsx
This allows teams to re-skin and rebrand the app without modifying functionality.
OPENAI_MODEL
and/or OPENAI_EMBEDDING_MODEL
in the .env
file.backend/entities/llm.py
with LangChain-compatible wrappers for the new provider - although it must support Image Input if your documents contain images.Very easy. Environment variables handle most deployment-level customization:
ORG_NAME
AGENT_NAME
OPENAI_MODEL
, EMBEDDING_MODEL
SOURCE_DOC_DIR
, IMAGE_DIR
, FAISS_INDEX_DIR
CLERK_PEM_PUBLIC_KEY
, CLERK_PUBLISHABLE_KEY
App.jsx
, favicon, manifest, and color definitions (src/colors.css
)This makes the project a plug-and-play foundation for any brand/organisation.
Extremely flexible. Clerk supports a wide range of sign-in methods including email/password, magic link, Google, Outlook, and SSO providers. Configuration is done via the Clerk dashboard β no code changes are needed to support different auth methods, making it ideal for deployments across diverse environments.
Special thanks to the open-source community behind: