Adam BlansettSenior Full-Stack & AI Engineer
DevOps & Security
11 min read
Adam Blansett

Self-Hosted AI Data Governance: Checksum PII Tokenization, Undoable Jaro-Winkler Merges, and PostgreSQL Schema Audits

How ai-data-governance combines Luhn/Mod-97 checksum PII detection, reversible HKDF/Fernet vault tokenization, undoable Jaro-Winkler/Soundex deduplication, E.164/USPS normalizers, and PostgreSQL DDL hygiene audits.

Data GovernanceHKDF/FernetDeduplicationPostgreSQLSchema HygieneFastAPIFour-Eyes RBAC

Growing databases accumulate messy operational debt: untagged PII columns sitting in analytics tables, duplicate customer profiles with conflicting phone numbers, unindexed foreign keys causing sequential-scan hotspots, and risky one-off cleanup scripts with no rollback path.

AI Data Governance & Cleanup Platform (source on GitHub) addresses database hygiene through deterministic checksum validators, reversible cryptography, and four-eyes governance inside a FastAPI, async SQLAlchemy 2.0, PostgreSQL (`pgvector`), and 7-tab React 18 console.

Checksum-Validated PII Scanning & Reversible HKDF/Fernet Tokenization#

Under `/api/v1/pii/*`, regex detectors and offline heuristic NER pair with Luhn payment-card and Mod-97 IBAN checksum validation so arbitrary order IDs do not trigger false alerts. Findings can be handled with `redact`, `mask`, `hash`, or reversible HKDF/Fernet vault `tokenize` paired with audited `detokenize` endpoints.

Undoable Jaro-Winkler Dedup Merges & Non-Destructive Normalizers#

The `/api/v1/dedup/*` engine clusters candidate duplicates using blocking keys, Jaro-Winkler distance, token-set matching, and Soundex phonetic keys, computing survivorship rules with field provenance and undoable HITL merge snapshots. In parallel, `/api/v1/normalizers/*` previews non-destructive standardizations across emails, E.164 phone numbers, USPS addresses, taxonomies, null sentinels, whitespace, and ISO dates.

PostgreSQL DDL/Catalog Schema Audits & Encrypted Live Connectors#

Under `/api/v1/schema-audit/*` and `/api/v1/connectors/*`, Fernet-encrypted SQLite and PostgreSQL connectors perform live introspection and sampling while the schema analyzer inspects DDL and live catalog telemetry for structural and performance defects:

schema_audit_checks.txt
- Orphaned or unindexed foreign keys -> emits CREATE INDEX CONCURRENTLY remediation SQL
- Sequential-scan hotspots & unused indexes -> ranks query-plan impact
- Missing primary keys & untagged PII columns -> flags governance policy gaps
- Retention SLA violations -> surfaces archival/cleanup candidates for steward sign-off
  • Four-Eyes Governance & RBAC (`/api/v1/auth/*`, `/governance/*`): Enforces HS256 JWT + API-key RBAC (`viewer`, `analyst`, `steward`, `admin`) with four-eyes approval separation.
  • Observability, Compliance Exports & Guardrails: Emits `structlog` JSON logs, enforces pure ASGI security headers and sliding-window rate limiting, defaults `LLM_REDACT_PII_FOR_CLOUD=true` alongside local Ollama/mock adapters, and exports Markdown, CSV, and JSON compliance reports (`/api/v1/reports/*`).
Zero-Regret Cleanups: Combining non-destructive normalization previews, reversible HKDF/Fernet tokens, and transactional HITL rollback lets data stewards clean legacy tables without risking permanent data corruption.

Tackling database hygiene, PII tokenization, or PostgreSQL schema remediation? Explore my Software Architecture and AI Engineering services or book a consultation.

Applied Architecture

Production Case Studies & Capabilities

Explore how these engineering patterns are deployed in production systems and available through client engagements.

Case Study

AI Data Governance & Cleanup Platform

An open-source Python 3.12 (FastAPI), async SQLAlchemy 2.0 + PostgreSQL/pgvector, and React 18 data governance console combining Luhn/Mod-97 PII detection and HKDF/Fernet vault tokenization with undoable Jaro-Winkler/Soundex merges, non-destructive normalizers, live DB connectors, and PostgreSQL DDL hygiene audits.

Read Case Study
Related Engineering Service

Software Architecture & System Design

Fast-moving teams frequently accrue hidden architectural liabilities: tangled domain logic, unmaintainable monoliths, or over-engineered microservices that paralyze development.

Related Engineering Service

AI Engineering & LLM Integration

Many AI initiatives fail in production due to prompt fragility, high token latency, hallucination risks, and lack of structured evaluation. I bridge the gap between experimental LLM prompts and deterministic software engineering.

Frequently Asked Questions

How does ai-data-governance avoid false positives when scanning tables for PII?
Instead of relying on loose numeric regexes alone, /api/v1/pii/* pairs pattern matching and offline heuristic NER with mathematical Luhn checksum validation for payment cards and Mod-97 checksum validation for IBANs alongside SSN, email, phone, API key, and IPv4 detectors.
What makes duplicate record merges safe to run on production datasets?
The /api/v1/dedup/* workflow computes field-level provenance using blocking keys, Jaro-Winkler, token-set similarity, and Soundex, routes merge proposals through four-eyes HITL approvals, and persists snapshots so merges are cleanly undoable.
How does the platform connect to external PostgreSQL or SQLite databases safely?
Live connector credentials under /api/v1/connectors/* are encrypted at rest with Fernet, scoped behind four-eyes RBAC (viewer, analyst, steward, admin), and executed transactionally with rollback support.
Share this technical guide

Need Help Solving This in Your Application?

I partner with founders, executives, and engineering leaders to design architectures, resolve production bottlenecks, and deliver resilient software.

Related Technical Articles

DevOps & Security
12 min read

Automating Compliance, Data Governance, QA, and IT Operations with Guarded Self-Hosted AI

How deterministic policy scanners, legal-hold DSAR blocks, HKDF/Fernet PII tokenization, SCIM 2.0 dry-run diffs, and OpenAPI E2E test synthesis power internal governance and release engineering safely.

SOC 2 ComplianceData GovernanceSCIM 2.0Release EngineeringPII TokenizationDSARSecurity Scanners
Read Article