Metadata-Version: 2.4
Name: bharat-pii
Version: 0.1.2
Summary: India-first PII detection & redaction library
Author: Rahul Sharma
License: MIT License
        
        Copyright (c) 2026 Rahul Sharma
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
        THE SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: regex
Dynamic: license-file

# bharat-pii 🇮🇳
![PyPI](https://img.shields.io/pypi/v/bharat-pii)
![Python](https://img.shields.io/pypi/pyversions/bharat-pii)
![License](https://img.shields.io/pypi/l/bharat-pii)
![CI](https://github.com/rahulsharma4298/bharat-pii/actions/workflows/ci.yml/badge.svg)

India-first PII detection & redaction library for GenAI pipelines.

**bharat-pii** helps detect and redact **Indian-specific sensitive data**
(PAN, Aadhaar, UPI, IFSC, credit cards, etc.) before sending data to LLMs,
logs, or analytics systems.

It is built with a **regex-first, deterministic core** and designed to be
**extensible with ML / Presidio adapters** in the future.

---

## ✨ Features

- 🇮🇳 India-first PII entities
- ⚡ Fast & deterministic (regex + validation)
- 🔒 Credit card detection with strict Luhn validation
- 🔌 Extensible detector architecture
- 🧱 LLM-safe (local by default)
- 🧪 Fully testable
- 📦 uv / PyPI friendly packaging

---

## 📌 Supported Entities

| Entity | Example |
|------|--------|
| PAN | ABCDE1234F |
| Aadhaar | 2345 6789 0123 |
| Indian Phone | +91 9876543210 |
| Credit Card | 4111 1111 1111 1111 |
| UPI ID | rahul@upi |
| IFSC | HDFC0001234 |

---

## 🛣️ Roadmap

Planned additions:
- Email
- Passport
- Driving License
- Entity severity & priority
- Strict vs loose detection modes
- Presidio (ML) adapter
- CLI tool
- PDF / OCR support

---

## 📦 Installation

Using pip:

    pip install bharat-pii

Using uv:

    uv pip install bharat-pii

---

## 🚀 Usage

### Detect PII

    from bharat_pii.api import detect

    text = "Pay 500 to rahul@upi using card 4111 1111 1111 1111"
    results = detect(text)
    print(results)

---

### Redact PII

    from bharat_pii.api import redact

    safe_text = redact("My IFSC is HDFC0001234 and Aadhaar is 2345 6789 0123")
    print(safe_text)

Output:

    My IFSC is ******1234 and Aadhaar is ********0123

---

## 🧠 Design Philosophy

- Regex-first for precision and predictability
- Validation where applicable (e.g. Luhn for cards)
- Pluggable detector architecture
- No cloud dependency
- Minimal and stable API

Ideal for:
- LLM pipelines
- Fintech & healthcare systems
- Logs & analytics
- Internal tools
- Compliance & PII redaction

---

## 🤝 Contributing

Contributions are welcome.  
Please see `CONTRIBUTING.md` for guidelines.

---

## 📄 License

MIT License © Rahul Sharma
