Data Privacy and Audit Logging
Privacy by design, data classification and minimization, consent, data subject rights, pseudonymization, retention, and designing tamper-evident audit logs.
Privacy by design principles
- Data minimization: collect only what is needed for a stated purpose.
- Purpose limitation and consent: record legal basis/consent per purpose; honour withdrawals.
- Classification: public, internal, confidential, restricted (PII, financial, health).
- Pseudonymization and anonymization: replace identifiers in analytics; anonymized data must not be re-identifiable.
- Retention and deletion: define retention per data category; automate deletion.
- Data subject rights: access, rectification, erasure, portability (GDPR); similar rights in India's DPDP Act 2023, CCPA/CPRA and others.
- Residency and transfers: where data is stored and processed; cross-border transfer mechanisms.
Architecture patterns
| Need | Pattern |
|---|---|
| Find all personal data | Data catalog with PII discovery (Macie, Purview, Sensitive Data Protection) |
| Erase a customer everywhere | Event-driven deletion (CustomerErasureRequested) with confirmations from each system; crypto-shredding (delete per-customer key) for backups and logs |
| Analytics without identities | Tokenize/pseudonymize at ingestion into the lake |
| Consent enforcement | Central consent service; downstream systems check purpose before processing |
Audit logging
Audit logs record who did what, to which resource, when, from where, with what result, for security-relevant and business-critical actions (logins, permission changes, data exports, money movements, admin actions).
{
"ts": "2026-11-21T09:14:02.331Z",
"actor": { "type": "user", "id": "u-7731", "ip": "10.2.3.4", "session": "s-91" },
"action": "customer.export",
"resource": { "type": "customer", "id": "c-55102" },
"result": "success",
"reason": "DSAR-2026-1182",
"traceId": "4bf92f3577b34da6"
}Tamper evidence: write-once storage (S3 Object Lock, immutable Blob, locked buckets), hash chaining, separate account/project with restricted access, and forwarding to a SIEM. Do not put sensitive payloads in audit logs.
Interview questions and answers
How do you implement "right to be forgotten" in a microservices system with backups?
Publish an erasure event; each service owning personal data deletes or anonymizes it and confirms; track completion centrally. For backups and immutable logs, use crypto-shredding (destroy the customer's encryption key) or document retention-based expiry where law allows, and ensure restores re-apply deletions.