<?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: Vishal Prajapati</title>
    <description>The latest articles on DEV Community by Vishal Prajapati (@piiguardrails).</description>
    <link>https://dev.to/piiguardrails</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%2F4113099%2F38efb587-8be6-49b2-ae8d-8ae93a53be3e.png</url>
      <title>DEV Community: Vishal Prajapati</title>
      <link>https://dev.to/piiguardrails</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/piiguardrails"/>
    <language>en</language>
    <item>
      <title>Building an Air-Gapped, &lt;25ms Local Privacy Gateway for LLMs (HIPAA, GDPR etc)</title>
      <dc:creator>Vishal Prajapati</dc:creator>
      <pubDate>Mon, 07 Sep 2026 04:35:37 +0000</pubDate>
      <link>https://dev.to/piiguardrails/building-an-air-gapped-25ms-local-privacy-gateway-for-llms-hipaa-gdpr-etc-2g5j</link>
      <guid>https://dev.to/piiguardrails/building-an-air-gapped-25ms-local-privacy-gateway-for-llms-hipaa-gdpr-etc-2g5j</guid>
      <description>&lt;h1&gt;
  
  
  Building an Air-Gapped, &amp;lt;25ms Local Privacy Gateway for LLMs (HIPAA, GDPR, SOC 2)
&lt;/h1&gt;

&lt;p&gt;Over the past year, nearly every enterprise engineering team has attempted to build with frontier models like OpenAI, Claude, or Azure OpenAI.&lt;/p&gt;

&lt;p&gt;Yet, a staggering number of these projects never make it to production. Why? &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compliance.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The moment customer names, Social Security Numbers, credit card numbers, or protected health information (PHI) enter the prompt pipeline, legal and compliance teams hit the emergency brakes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"Under HIPAA, GDPR, and SOC 2, we are strictly prohibited from transmitting unmasked customer data outside our private network perimeter."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Many commercial "AI privacy solutions" attempt to solve this by asking you to route your raw data through &lt;em&gt;their&lt;/em&gt; cloud proxy. But replacing one third-party risk with another isn't real enterprise security.&lt;/p&gt;

&lt;p&gt;In this article, I will break down the architecture and implementation of &lt;strong&gt;PII Guardrail Studio&lt;/strong&gt; — a 100% local, air-gapped reverse privacy proxy and encrypted token vault designed to run entirely inside your private VPC.&lt;/p&gt;




&lt;h2&gt;
  
  
  🛡️ Core Architectural Principles
&lt;/h2&gt;

&lt;p&gt;When designing a privacy gateway for production LLM pipelines, three constraints are non-negotiable:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. 100% Offline &amp;amp; Air-Gapped (Zero Telemetry)
&lt;/h3&gt;

&lt;p&gt;The gateway must operate without phoning home to any external license server, analytics endpoint, or cloud dependency. If deployed in an isolated Kubernetes pod with network_mode: none, it must function with zero degradation.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Sub-25ms In-Memory Detection Latency
&lt;/h3&gt;

&lt;p&gt;Running heavy NLP models locally often introduces hundreds of milliseconds of overhead. By leveraging a C-optimized, regex-compiled boundary engine with 30+ entity recognizers, detection and substitution run in under 25ms on standard commodity hardware.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Bi-Directional Reversible Tokenization
&lt;/h3&gt;

&lt;p&gt;Masking PII is only half the battle. If a user asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"What medication should be prescribed to Patient Robert Vance?"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The model cannot answer accurately if the patient's identity is completely stripped. Instead, the proxy performs cryptographic token substitution:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Raw Sensitive Prompt]
       │
       ▼
[Local Privacy Gateway (&amp;lt;25ms)]
       │ (Scrubbed with &amp;lt;PERSON_1&amp;gt;, &amp;lt;SSN_1&amp;gt;)
       ▼
[External LLM API (OpenAI/Claude)]
       │ (Response contains &amp;lt;PERSON_1&amp;gt;)
       ▼
[Local Gateway Token Vault]
       │ (Restores &amp;lt;PERSON_1&amp;gt; ➔ "Robert Vance")
       ▼
[Final User Response]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🔐 The Encrypted Token Vault (SQLCipher AES-256)
&lt;/h2&gt;

&lt;p&gt;When the gateway maps "Robert Vance" to , where is that mapping stored?&lt;/p&gt;

&lt;p&gt;In PII Guardrail Studio, mappings are never held in plain text. They are committed to a local SQLCipher database encrypted at rest with AES-256, verified via SHA-256 digests, and bound offline using Ed25519 node-locking.&lt;/p&gt;

&lt;p&gt;Even if a malicious actor accesses the physical disk or container volume, the mapping table is unreadable without the node key.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 Quickstart: Running It Locally in 30 Seconds
&lt;/h2&gt;

&lt;p&gt;The gateway can be deployed in two primary ways:&lt;/p&gt;

&lt;h3&gt;
  
  
  Option A: Via pip (Python 3.10+)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install the official PyPI package&lt;/span&gt;
pip &lt;span class="nb"&gt;install &lt;/span&gt;piiguardrails

&lt;span class="c"&gt;# Boot the engine and launch the Studio UI&lt;/span&gt;
piiguardrails
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This immediately initializes the encrypted vault and launches the interactive dashboard at &lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;http://localhost:8000&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Option B: Via Docker (Production VPC &amp;amp; Kubernetes)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8000:8000 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;/data:/app/data &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; pii-guardrail-studio &lt;span class="se"&gt;\&lt;/span&gt;
  piiguardrails/enterprise-pii-guardrail:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  💻 Code Example: Intercepting Prompts in Python
&lt;/h2&gt;

&lt;p&gt;Once the gateway is running at localhost:8000, you can integrate it into any existing Python pipeline using standard httpx or requests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;httpx&lt;/span&gt;

&lt;span class="c1"&gt;# 1. Raw prompt containing sensitive PII/PHI
&lt;/span&gt;&lt;span class="n"&gt;raw_prompt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"""&lt;/span&gt;&lt;span class="s"&gt;
Patient Sarah Lin (DOB: 1984-06-12, SSN: 394-20-8192) was admitted to St. Jude Memorial.
Contact her at slin@stjude-health.org regarding medical charts.
&lt;/span&gt;&lt;span class="sh"&gt;"""&lt;/span&gt;

&lt;span class="c1"&gt;# 2. Intercept and mask before calling external APIs
&lt;/span&gt;&lt;span class="n"&gt;mask_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8000/mask&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;raw_prompt&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="n"&gt;masked_data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;mask_response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Masked Prompt for OpenAI/Claude:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;masked_data&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;masked_text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Patient &amp;lt;PERSON_1&amp;gt; (DOB: &amp;lt;DOB_1&amp;gt;, SSN: &amp;lt;SSN_1&amp;gt;) was admitted to &amp;lt;HOSPITAL_1&amp;gt;.
Contact her at &amp;lt;EMAIL_1&amp;gt; regarding medical charts.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Unmasking the Model Response:
&lt;/h3&gt;

&lt;p&gt;When the model returns its completion containing , simply pass it back to the local unmask endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;llm_reply&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Follow up with &amp;lt;PERSON_1&amp;gt; regarding dietary restrictions.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;

&lt;span class="n"&gt;unmask_response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;httpx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;http://localhost:8000/unmask&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;llm_reply&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Restored Response:&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;unmask_response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()[&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;unmasked_text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;span class="c1"&gt;# Output: "Follow up with Sarah Lin regarding dietary restrictions."
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🎁 Community Launch Gift
&lt;/h2&gt;

&lt;p&gt;To celebrate the v2.0 release, you can grab a Free 6-Month Enterprise Evaluation Key (valid through March 31, 2027) directly on the homepage. It unlocks unlimited request throughput, unrestricted payload size, and all 30+ entity recognizers.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔗 Resources &amp;amp; Getting Involved
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;GitHub Repository: &lt;a href="https://github.com/piiguardrails/piiguardrails" rel="noopener noreferrer"&gt;https://github.com/piiguardrails/piiguardrails&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Live Interactive Sandbox: &lt;a href="https://piiguardrails.com" rel="noopener noreferrer"&gt;https://piiguardrails.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;PyPI Package: &lt;a href="https://pypi.org/project/piiguardrails/" rel="noopener noreferrer"&gt;https://pypi.org/project/piiguardrails/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Video Walkthrough: &lt;a href="https://youtu.be/w4i2gAFit_E" rel="noopener noreferrer"&gt;https://youtu.be/w4i2gAFit_E&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are building privacy-sensitive LLM applications, try running it locally and let me know your thoughts on the detection engine and roadmap!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>python</category>
      <category>security</category>
    </item>
  </channel>
</rss>
