- 1. Core Statutory Pillars of the DPDP Act for Software Engineers
- Key Technical Mandates:
- 2. Consent State Machine & Audit Trail Schema (PostgreSQL)
- Production Consent Ledger Database Schema
- 3. Right to Erasure: Building the Cascade Deletion Pipeline
- The DPDP Deletion Workflow:
- Cryptographic Erasure (Crypto-Shredding)
- 4. PII Redaction & Tokenization Architecture (Python)
- 5. Cyberfact Security DPDP Compliance Engineering Audits
The enactment of Indiaβs Digital Personal Data Protection Act, 2023 (DPDP Act) marks a historic transformation in how digital enterprises operating within the Indian sovereign cyber territory collect, process, store, and dispose of personal data. With statutory penalties reaching up to INR 250 Crores ($30 Million USD) per violation, compliance is no longer a check-the-box legal exerciseβit is a core engineering and data architecture imperative.
Engineering teams can no longer store customer mobile numbers, Aadhaar details, PAN cards, or email addresses in unencrypted relational database columns, nor can marketing teams ingest user telemetry without granular, verifiable, and revocable consent records.
This engineering guide provides the technical architecture, database schemas, and cryptographic pipelines required to achieve 100% compliance with the DPDP Act 2023.
1. Core Statutory Pillars of the DPDP Act for Software Engineers
The Act introduces specific legal roles that map directly to technical architecture tiers:
[ DATA PRINCIPAL ] ββ(Customer / Citizen)
β
βΌ (Granular, Itemized, Multilingual Consent)
[ DATA FIDUCIARY ] ββ(Your Enterprise / Application Platform)
β
βΌ (Contractually Bound API Pipeline)
[ DATA PROCESSOR ] ββ(Cloud Providers: AWS / GCP / Payment Gateways / SaaS)
Key Technical Mandates:
- Notice & Consent Architecture: Consent must be granular, informed, unconditional, and available in English and the 22 languages specified in the Eighth Schedule of the Indian Constitution.
- Right to Erasure / Right to be Forgotten: Data Fiduciaries must permanently delete personal data upon withdrawal of consent or once the specified processing purpose is fulfilled.
- Data Minimization & Storage Limitation: Data must not be retained indefinitely; automated data lifecycle pruning pipelines must be enforced.
- Breach Notification to DPBI & Data Principals: Mandatory prompt reporting of personal data breaches to the Data Protection Board of India (DPBI) and impacted users.
2. Consent State Machine & Audit Trail Schema (PostgreSQL)
Consent cannot be a simple boolean flag (has_accepted_terms = true) stored on the user row. Enterprises must maintain an immutable, versioned event log tracking every consent grant, modification, and revocation.
Production Consent Ledger Database Schema
CREATE TABLE consent_records (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
data_principal_id UUID NOT NULL,
purpose_code VARCHAR(64) NOT NULL, -- e.g., 'CORE_SERVICE', 'MARKETING_SMS', 'ANALYTICS'
notice_version VARCHAR(16) NOT NULL, -- e.g., 'v2.1'
language_code VARCHAR(8) NOT NULL DEFAULT 'en', -- e.g., 'hi', 'en', 'bn'
status VARCHAR(16) NOT NULL, -- 'ACTIVE', 'REVOKED', 'EXPIRED'
ip_address INET NOT NULL,
user_agent TEXT NOT NULL,
granted_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
revoked_at TIMESTAMPTZ,
proof_signature VARCHAR(256) NOT NULL -- Cryptographic HMAC of the consent event
);
-- Fast lookup index for active processing authorization
CREATE INDEX idx_active_consent ON consent_records (data_principal_id, purpose_code)
WHERE status = 'ACTIVE';
3. Right to Erasure: Building the Cascade Deletion Pipeline
When a customer exercises their statutory Right to Erasure, an enterprise cannot simply delete a row in the primary database while leaving PII stranded inside database backups, analytical data lakes (Snowflake / BigQuery), and third-party SaaS tools (Mixpanel, HubSpot).
The DPDP Deletion Workflow:
[ User Requests Erasure ] ββ> [ Consent Gateway / Privacy API ]
β
βΌ
[ Emit Asynchronous Event: UserErasureRequested ]
β
βββββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββ
βΌ βΌ βΌ
[ Primary PostgreSQL DB ] [ Analytical Lakehouse ] [ Cloud Backup Scrubbing ]
Anonymize / Delete PII Hash User ID in Parquet Mark User Encryption Key
Keep Financial Audit Tx Purge historical rows as DELETED in KMS
Cryptographic Erasure (Crypto-Shredding)
Because deleting individual rows from immutable write-once backups (such as air-gapped S3 snapshots) is technically impossible without rebuilding the entire backup snapshot, enterprises implement Crypto-Shredding:
- Every Data Principalβs PII is encrypted with a unique per-user Data Encryption Key (DEK).
- When the user requests erasure, the enterprise permanently destroys that userβs specific DEK in KMS.
- Without the key, the encrypted PII residing in historical backups becomes mathematically irreversible ciphertext, satisfying statutory erasure mandates.
4. PII Redaction & Tokenization Architecture (Python)
Before application logs are shipped to centralized logging clusters (Elasticsearch, Datadog, CloudWatch), automated tokenization filters must scrub sensitive Indian PII identifiers (Aadhaar numbers, PAN cards, phone numbers, email addresses).
import re
class PIIFilter:
# Regex patterns for Indian Statutory Identifiers
AADHAAR_REGEX = r'\b[2-9]{1}[0-9]{3}\s[0-9]{4}\s[0-9]{4}\b'
PAN_REGEX = r'\b[A-Z]{5}[0-9]{4}[A-Z]{1}\b'
PHONE_REGEX = r'\b(?:\+91|91)?[6-9]\d{9}\b'
EMAIL_REGEX = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
@classmethod
def redact_log_line(cls, log_message: str) -> str:
redacted = re.sub(cls.AADHAAR_REGEX, '[REDACTED_AADHAAR]', log_message)
redacted = re.sub(cls.PAN_REGEX, '[REDACTED_PAN]', redacted)
redacted = re.sub(cls.PHONE_REGEX, '[REDACTED_PHONE]', redacted)
redacted = re.sub(cls.EMAIL_REGEX, '[REDACTED_EMAIL]', redacted)
return redacted
5. Cyberfact Security DPDP Compliance Engineering Audits
Cyberfact Security bridges the gap between legal privacy mandates and technical implementation:
- Data Flow Mapping & Inventory Audits: Mapping all PII ingress, processing, storage, and egress points.
- Crypto-Shredding & Erasure Pipeline Architecture: Designing automated deletion workers across databases and cloud storage.
- Full VAPT Compliance Certification: Verifying that consent mechanisms and security controls withstand adversarial penetration testing.
Schedule a DPDP Act technical readiness review with Founder Saket Choudhary on WhatsApp (+91 82520 02914).
Founder and Lead Security Architect at Cyberfact Security. Specializing in offensive penetration testing (VAPT), distributed cloud architectures, and hardened full-stack engineering for high-growth enterprises.
Initiate a Technical Audit or Custom Engineering Scope
Cyberfact Security delivers certified VAPT audits, source code reviews, and enterprise software engineering for institutions across India. Direct technical engagements with Founder Saket Choudhary.




