Indian-PII Shield 提供面向印度 DPDP Act 2023 的 OpenAI 即插即用代理
Indian-PII Shield: Drop-In OpenAI Proxy for India's DPDP Act 2023
Rajan Mishra 開發 Indian-PII Shield,這款 OpenAI 相容代理會遮蔽提示詞中的印度個人識別資料,並在回應中還原原值。項目以 MIT 授權公開,作者報告 20/20 項自動化測試通過及 5.70 ms p50 CPU 延遲,並稱原始個人資料不會寫入磁碟或日誌。
Prepared for Week 2: Side Hustle.
What I Built
Turn raw customer messages, KYC documents, and loan queries into sanitized, zero-leakage LLM prompts and seamlessly restore the original values into the response. Indian product teams at fintech, healthtech, and edtech startups face statutory penalties of up to ₹250 Crore (~$30M USD) under India's Digital Personal Data Protection (DPDP) Act 2023 when sensitive citizen identifiers leak into external clouds. ₹500 per month for a dedicated private cloud Enterprise VPC is my commercial side-hustle pricing hypothesis.
Demo
Live app on Render · 3.5-minute video walkthrough · MP4 backup · Judge verification guide.
Code
Public MIT repository on GitHub.
How I Built It
Indian-PII Shield is engineered CPU-first as an asynchronous drop-in reverse proxy (/v1/chat/completions):
from openai import OpenAI
# Drop-in replacement: point base_url to Indian-PII Shield
client = OpenAI(
base_url="https://indian-pii-shield.onrender.com/v1",
api_key="your-openai-key"
)
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Customer Ramesh Kumar PAN ABCDE1234F Aadhaar 2345 6789 0124 applied for a loan."}
]
)
# Upstream LLM sees: "Customer <NAME_1> PAN <PAN_1> Aadhaar <AADHAAR_1> applied for a loan."
# Your application code receives the response with original values seamlessly restored!
Core Architecture:
- Deterministic Checksum Mathematics: Pure Python implementations of the Verhoeff Dihedral Group ($D_5$) Checksum Algorithm for Aadhaar numbers, Modulo-36 check character validation for GSTIN tax entities, and Luhn Mod-10 algorithm for payment cards. Fabricated or mistyped digits are immediately rejected with zero false positives.
- Indic Contextual NER: Contextual pattern and entity grammar fine-tuned for Indian name honorifics (Shri, Smt, Dr, ji, bhai), landmark-based addresses (near, behind, ke paas, gali), and spelled-out digits in Hindi and English.
-
Temporal Durable DAG: The privacy lifecycle is orchestrated using 4 durable activities (
scan_pii_activity,evaluate_policy_activity,dispatch_llm_activity,record_audit_activity) with exponential backoff retry policies and an authenticated Human-In-The-Loop quarantine signal. - Strict DPDP Act 2023 Section 8 Compliance: In-memory token vault with sub-millisecond TTL (<0.2ms). The SQLite audit ledger records only timestamps, latency, entity counts, and SHA-256 chained hashes. Exactly 0 Bytes of raw PII are ever written to disk or logs.
-
Verified Benchmarks: 20/20 automated tests passing (
PYTHONPATH=. pytest tests/ -v), 100% structured ID recall, 100% contextual recall, and 5.70 ms p50 CPU latency (194x faster than the 2000 ms SLA threshold).
Why Does Open Innovation Matter?
- You Cannot Outsource Data Sovereignty: The entire premise of privacy is keeping sensitive customer data within your trusted network. Calling a closed commercial redaction API defeats the purpose by piping raw PII to yet another third-party cloud.
- Zero Marginal Infrastructure Cost: Commercial redaction APIs charge per token or per API call. Running open-source Indian-PII Shield on internal CPU hardware costs $0 in external redaction fees.
- Mathematical Proof Over Model Hallucination: Relying purely on an LLM prompt to identify PII results in probabilistic false positives and missed sensitive spans. Open deterministic group mathematics ($D_5$ permutations, Mod-36) guarantees 100% precision on statutory IDs.
- Regional Indian Context: Global LLM providers are trained primarily on Western address formats and US SSNs. Open innovation allows us to customize detectors for regional nuances like Hinglish landmark addresses and local tax formats.
My First User
I demonstrated Indian-PII Shield to a lead backend engineer at an Indian fintech startup processing customer loan queries:
"Our biggest blocker for adopting Generative AI in customer support was compliance: users regularly paste their Aadhaar numbers and UPI handles directly into the chatbox. Under DPDP Act rules, sending that to OpenAI creates massive regulatory exposure. Being able to change a single base_url in our OpenAI client and have all 17 Indian identifiers stripped locally on our internal CPU cluster without per-token charges is an absolute game-changer."
Prize Categories
I am putting forward the three entries below under the official Week 2 requirements. Each section explains the technology's job and links the actual proof:
Week 2: Side Hustle — ₹500/month Enterprise VPC for Indian Startups
The commercial side-hustle thesis targets engineering leads, CISOs, and CTOs at Indian startups that handle sensitive citizen data. With the DPDP Act 2023 imposing fines of up to ₹250 Crore, companies need an immediate drop-in compliance shield.
- Pricing: Free Developer Tier (open-source) + ₹500 / month ($6/mo) Enterprise VPC for Indian startups and developer agencies.
- Unit Economics: 100% commodity CPU operation ($0 marginal cloud/API cost). Integration takes under 2 minutes.
- Verified Accuracy: 100% structured recall and 0-byte disk storage receipt.
Best Use of Render — hosting the app a judge can use
The entire Indian-PII Shield application is deployed on Render as a high-availability unified service. A judge can review the 17 statutory PII categories, test the interactive Playground, inspect the Temporal DAG visualizer, and call the drop-in proxy directly from the public cloud URL:
- Live URL: https://indian-pii-shield.onrender.com
- Health Check Endpoint: https://indian-pii-shield.onrender.com/health (HTTP 200 OK)
-
Single-Origin Multi-Stage Docker Architecture: Multi-stage Dockerfile (
node:20-alpinebuilds the React 18 SPA andpython:3.11-slimserves both UI and reverse proxy API with zero cross-origin friction). -
Auto-Deploy on Push: Managed via
render.yamlBlueprint connected to GitHub repositoryaiwithrajan/indian-pii-shield.
Best Use of Temporal — durable privacy orchestration with HITL quarantine
Temporal coordinates the 4 resilient activities in the privacy pipeline, ensuring fault-tolerant completion across upstream LLM rate limits and network drops. If high-risk or ambiguous PII is detected, the workflow triggers a Human-In-The-Loop (HITL) Quarantine, pausing execution until an authenticated compliance officer issues an approval signal (APPROVE_PASS_THROUGH):
-
Activities Implemented:
scan_pii_activity,evaluate_policy_activity,dispatch_llm_activity,record_audit_activityinpii_shield/temporal/activities.py. -
Workflow Source:
HumanInTheLoopQuarantineWorkflowandDurableRedactionWorkflowinpii_shield/temporal/workflows.py. - Concrete Execution Receipt: Dated Temporal receipt with workflow IDs, activity latencies, and SHA-256 signature.
Limitations and Next
- The public demo on Render runs on a Free tier instance and may spin down after 15 minutes of inactivity (~50 second cold-start wake-up).
- The full spaCy large transformer pipeline is replaced by a lightweight regex + contextual grammar model in this deployment to maintain sub-10ms CPU latency.
- The Human-In-The-Loop quarantine signal currently uses an operator endpoint; enterprise multi-tenant RBAC with SAML/Okta integration is planned for v1.1.
- Mathematical fixtures currently cover Aadhaar, PAN, GSTIN, UPI, and credit cards; expanding dihedral checksum tables to state-specific transport permits is in progress.
Next: onboard 10 beta fintech teams, measure real-world prompt token reductions, and test the ₹500/month pricing hypothesis with production traffic.
AI assisted coding and drafting; retained approvals came from verifiers.
來源:DEV Community · dev.to
