Technical Architecture Implications

Technical Architecture Implications

Privacy regulations fundamentally impact application architecture. Data minimization principles influence database schema design, encouraging developers to carefully consider what data is truly necessary. Purpose limitation affects how data flows between services and which components can access specific data types. Storage limitation requires implementing data retention policies and automated deletion processes.

Security requirements from both regulations mandate encryption in transit and at rest, access controls, and audit logging. Privacy by design means considering privacy implications from the earliest stages of development, not as an afterthought. This might involve techniques like differential privacy, homomorphic encryption, or privacy-preserving analytics that provide insights without exposing individual data.

// Privacy-focused data architecture example
class PrivacyAwareDataStore {
  constructor() {
    this.dataClassifications = {
      'email': { category: 'PII', retention: 365, purposes: ['authentication', 'communication'] },
      'ipAddress': { category: 'PII', retention: 30, purposes: ['security', 'analytics'] },
      'purchaseHistory': { category: 'Behavioral', retention: 730, purposes: ['personalization', 'analytics'] },
      'deviceId': { category: 'Technical', retention: 180, purposes: ['analytics', 'performance'] }
    };
  }
  
  // Store data with privacy metadata
  async storeData(userId, dataType, value, purpose) {
    const classification = this.dataClassifications[dataType];
    
    // Verify purpose is allowed
    if (!classification.purposes.includes(purpose)) {
      throw new Error(`Purpose '${purpose}' not allowed for ${dataType}`);
    }
    
    // Encrypt PII data
    const encrypted = classification.category === 'PII' 
      ? await this.encrypt(value) 
      : value;
    
    // Store with metadata for compliance
    const record = {
      userId,
      dataType,
      value: encrypted,
      purpose,
      collectedAt: new Date().toISOString(),
      expiresAt: this.calculateExpiration(classification.retention),
      consentId: await this.getActiveConsent(userId, purpose),
      encrypted: classification.category === 'PII'
    };
    
    await this.db.store(record);
    
    // Set up automatic deletion
    this.scheduleDataExpiration(record);
  }
  
  // Implement data portability
  async exportUserData(userId, format = 'json') {
    const userData = await this.db.getAllUserData(userId);
    
    // Decrypt PII data for export
    const decrypted = await Promise.all(
      userData.map(async (record) => {
        if (record.encrypted) {
          record.value = await this.decrypt(record.value);
        }
        // Remove internal metadata
        delete record.consentId;
        delete record.encrypted;
        return record;
      })
    );
    
    // Format according to request
    if (format === 'json') {
      return JSON.stringify(decrypted, null, 2);
    } else if (format === 'csv') {
      return this.convertToCSV(decrypted);
    }
  }
}