How aajil-labs/arabic-pii-py works
apii is a local PII-protection layer for Arabic and Gulf text and documents. Its core workflow detects sensitive spans, applies policy-controlled reversible tokenization, sends only tokenized content through an optional AI proxy, then restores values locally from an encrypted vault. It also exposes document/batch processing, CLI and UI entry points, and Claude Code hooks with a watch view. The graph follows documented workflows and source-index references; dashed links mark optional or incompletely evidenced integrations, and unsampled subsystems are represented only where the README supports them.
Main entry points: anonymizer.py Tokenization & Restore · server.py Proxy Gateway · cli.py CLI · pipeline.py Detection Pipeline
Components 20
Detection
- Detection Pipeline
apii/pipeline.py - Arabic Normalization
apii/normalize.py - PII Recognizers
apii/recognizers - Context Boost
apii/context.py - On-device NER
apii/ner.py - Geo Detection
apii/geo.py - Phrase Suppression
apii/suppressor.py
Redaction & Vault
- Tokenization & Restore
apii/anonymizer.py - Redaction Policy
apii/policy.py - Encrypted Vault
apii/vault.py
User Interfaces
- CLI
apii/cli.py - Web UI
apii/ui.py - Claude Hooks
apii/hook.py - Watch View
apii/watch.py
AI & Documents
- Batch Processing
apii/batch.py - Document Adapters
apii/documents - Proxy Gateway
apii/server.py - Stream Handling
apii/streaming.py
Other components
- User / Client
- AI Provider
Connections 31
- User / Client → CLI: invokes
- User / Client → Web UI: uses
- User / Client → Claude Hooks: installs
- User / Client → Proxy Gateway: routes requests
- CLI → Tokenization & Restore: detects / redacts
apii/cli.py - CLI → Batch Processing: runs batches
apii/cli.py - CLI → Proxy Gateway: starts
apii/cli.py - CLI → Claude Hooks: manages hooks
apii/cli.py - CLI → Web UI: starts
apii/cli.py - Detection Pipeline → Arabic Normalization: normalizes text
apii/pipeline.py - Detection Pipeline → PII Recognizers: runs detection
apii/pipeline.py - Detection Pipeline → Geo Detection: adds detections
apii/pipeline.py - Detection Pipeline → Phrase Suppression: filters spans
apii/pipeline.py - Detection Pipeline → On-device NER: merges NER
- Tokenization & Restore → Detection Pipeline: requests detections
apii/anonymizer.py - Tokenization & Restore → Redaction Policy: applies policy
apii/anonymizer.py - Web UI → Tokenization & Restore: redacts / restores
apii/ui.py - Web UI → Encrypted Vault: loads / saves
apii/ui.py - Web UI → Document Adapters: processes files
apii/ui.py - Claude Hooks → Tokenization & Restore: redacts / restores
apii/hook.py - Watch View → Tokenization & Restore: restores view
apii/watch.py - Watch View → Encrypted Vault: loads records
apii/watch.py - Batch Processing → Tokenization & Restore: redacts content
apii/batch.py - Batch Processing → Document Adapters: adapts files
apii/batch.py - Batch Processing → Encrypted Vault: persists records
apii/batch.py - Document Adapters → Tokenization & Restore: passes extracted text
apii/documents/__init__.py - Proxy Gateway → Tokenization & Restore: redacts requests
apii/server.py - Proxy Gateway → Stream Handling: handles streams
apii/server.py - Proxy Gateway → AI Provider: forwards tokens
- AI Provider → Proxy Gateway: returns reply
- Proxy Gateway → Tokenization & Restore: restores reply
apii/server.py