How tnruok/pii_shield works
PII Shield is a local document privacy pipeline: users submit business documents, receive extracted chunks, have PII detected and replaced with stable placeholders, and get a leakage safety check and masked audit report. Its core processing stages are distinct from its browser-prompt shielding capability, which uses a local bridge. The graph reflects README descriptions and the supplied source excerpts and index; unsampled implementation details and unshown call relationships are not inferred.
Main entry points: gradio_app.py Gradio workflow · merge.py Detection merge · router.py Format router · docx.py DOCX extraction
Components 24
Document extraction
- Format router
extract/router.py - DOCX extraction
extract/docx.py - PDF extraction
extract/pdf.py - PPTX extraction
extract/pptx.py - OCR processing
extract/ocr.py - Image regions
extract/regions.py - Chunk data contract
extract/models.py
PII detection
- Regex rules
detect/rules.py - Local NER
detect/ner.py - Context boosting
detect/context.py - PII validators
detect/validators.py - OCR repair
detect/ocr_repair.py - Suspect OCR
detect/suspect.py - Detection merge
detect/merge.py - Name propagation
detect/propagate.py
Redaction and safety
- Placeholder redaction
redact/redactor.py - Encrypted mappings
redact/mapping.py - Leakage safety check
verify/leakage.py
User interfaces
- Gradio workflow
app/gradio_app.py - Browser extension
extension/content.js - Local extension bridge
extension_server/server.py
Audit reporting
- Masked audit reports
report/report.py
Other components
- Document user
- Browser user
Connections 30
- Document user → Gradio workflow: submits documents
README.md - Gradio workflow → Format router: routes files
app/gradio_app.py - Format router → PDF extraction: dispatches PDF
extract/router.py - Format router → DOCX extraction: dispatches DOCX
extract/router.py - Format router → PPTX extraction: dispatches PPTX
extract/router.py - DOCX extraction → Chunk data contract: creates chunks
extract/docx.py - PDF extraction → Chunk data contract: creates chunks
extract/pdf.py - PPTX extraction → Chunk data contract: creates chunks
extract/pptx.py - DOCX extraction → OCR processing: runs OCR
extract/docx.py - PPTX extraction → OCR processing: runs OCR
extract/pptx.py - PDF extraction → OCR processing: runs OCR
extract/pdf.py - DOCX extraction → Image regions: detects image regions
extract/docx.py - PPTX extraction → Image regions: detects image regions
extract/pptx.py - Gradio workflow → Detection merge: detects PII
app/gradio_app.py - Detection merge → Regex rules: runs rules
detect/merge.py - Detection merge → Local NER: runs NER
detect/merge.py - Detection merge → Context boosting: boosts context
detect/merge.py - Detection merge → Suspect OCR: checks suspect OCR
detect/merge.py - Detection merge → OCR repair: repairs OCR candidates
detect/merge.py - Regex rules → PII validators: validates matches
detect/rules.py - OCR repair → PII validators: validates candidates
detect/ocr_repair.py - Gradio workflow → Name propagation: propagates aliases
app/gradio_app.py - Gradio workflow → Placeholder redaction: redacts chunks
app/gradio_app.py - Placeholder redaction → Encrypted mappings: assigns placeholders
redact/redactor.py - Gradio workflow → Leakage safety check: checks residual PII
app/gradio_app.py - Leakage safety check → Detection merge: re-scans chunks
verify/leakage.py - Gradio workflow → Masked audit reports: generates audit
app/gradio_app.py - Browser user → Browser extension: shields prompts
README.md - Browser extension → Local extension bridge: uses local bridge
README.md - Local extension bridge → Format router: processes documents
extension_server/server.py