<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nj</title>
    <description>The latest articles on DEV Community by Nj (@njnagaraj).</description>
    <link>https://dev.to/njnagaraj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4189183%2Fbeb5aa0c-9551-4f75-9215-77fe7f8a16ce.png</url>
      <title>DEV Community: Nj</title>
      <link>https://dev.to/njnagaraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/njnagaraj"/>
    <language>en</language>
    <item>
      <title>I built an open-source RAG engine with org-level access control, because I couldn't find one</title>
      <dc:creator>Nj</dc:creator>
      <pubDate>Fri, 16 Oct 2026 15:31:40 +0000</pubDate>
      <link>https://dev.to/njnagaraj/i-built-an-open-source-rag-engine-with-org-level-access-control-because-i-couldnt-find-one-1643</link>
      <guid>https://dev.to/njnagaraj/i-built-an-open-source-rag-engine-with-org-level-access-control-because-i-couldnt-find-one-1643</guid>
      <description>&lt;p&gt;Most open-source RAG tools I tried had the same gap. Either org-level access control sat behind a paid enterprise tier, or everything lived in one shared workspace per team. For a real company, where HR, finance, and engineering can't all see each other's documents, that isn't enough.&lt;/p&gt;

&lt;p&gt;So I built &lt;strong&gt;Production RAG&lt;/strong&gt;, a local-first RAG engine with org support built in, under Apache 2.0.&lt;/p&gt;

&lt;h2&gt;
  
  
  Permissions belong in the query, not after it
&lt;/h2&gt;

&lt;p&gt;Many RAG setups retrieve the top-k chunks and then filter out what the user can't see. That leaks information through ranking, and it returns fewer results than asked for. Production RAG enforces an Org → Department → Team → User hierarchy directly in the SQL WHERE clause, so the user's scope is applied &lt;em&gt;before&lt;/em&gt; anything is ranked.&lt;/p&gt;

&lt;h2&gt;
  
  
  One Postgres, two kinds of search
&lt;/h2&gt;

&lt;p&gt;Dense vectors miss exact IDs, dates, and jargon. Keyword search misses paraphrases. Production RAG runs both inside Postgres, pgvector HNSW for semantic search and Postgres full-text search for keywords, then fuses them with Reciprocal Rank Fusion. A small ONNX cross-encoder reranks the top candidates on CPU. No separate vector database to run.&lt;/p&gt;

&lt;h2&gt;
  
  
  Local-first
&lt;/h2&gt;

&lt;p&gt;It auto-detects a local Ollama and uses local ONNX embeddings, so it runs fully offline with no API keys. If you want a cloud model, OpenAI, Claude, or Gemini plug in with one environment variable.&lt;/p&gt;

&lt;h2&gt;
  
  
  The rest
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Admin / editor / viewer roles and per-user API keys&lt;/li&gt;
&lt;li&gt;Parent-child hierarchical chunking&lt;/li&gt;
&lt;li&gt;SSE token streaming in the web UI&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;rag eval&lt;/code&gt; CLI that reports Recall@K and MRR, plus a sample knowledge base&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Repo: &lt;a href="https://github.com/njNagaraj/RAG-production" rel="noopener noreferrer"&gt;https://github.com/njNagaraj/RAG-production&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd love feedback, especially on the tenancy model. How are you handling document-level permissions in your RAG setups?&lt;/p&gt;

</description>
      <category>rag</category>
      <category>opensource</category>
      <category>python</category>
      <category>postgres</category>
    </item>
  </channel>
</rss>
