Skip to main content

Overview

The GDPR compliance endpoints (/api/v1/users/me/*) require persistent storage to meet data subject rights requirements under GDPR Articles 15, 16, 17, 20, and 21. CRITICAL: In-memory storage is NOT production-ready and will cause data loss on server restart, violating GDPR compliance requirements.
PostgreSQL storage backend is fully implemented as of ADR-0041 (2025-11-02). See ADR-0041: PostgreSQL GDPR Storage for architecture details.

GDPR Data Subject Rights Flow

Environment Variables

Required Configuration

Set these environment variables in your production deployment:

Development/Testing

For local development and testing only:

Storage Backend Options

PostgreSQL provides ACID compliance and is ideal for GDPR data subject rights. Fully implemented as of ADR-0041.
Production Ready: PostgreSQL storage backend is fully implemented with factory pattern, migrations, and comprehensive testing.
Configuration:
Architecture Benefits (see ADR-0041):
  • ACID Compliance: Atomic GDPR Article 17 deletions across all data
  • Cost-Effective: 14x cheaper than Redis for 7-year retention (50/monthvs50/month vs 720/month)
  • Audit Trail: Time-series queries for compliance reports
  • Already in Stack: Keycloak and OpenFGA use PostgreSQL
  • 5-10ms Latency: Acceptable for user-initiated GDPR operations
Database Schema: The PostgreSQL schema includes 5 tables optimized for GDPR compliance:
Kubernetes Deployment: The schema is deployed via ConfigMap in Kubernetes:
The ConfigMap is defined in deployments/base/postgres-gdpr-schema-configmap.yaml and automatically applied during PostgreSQL initialization. Factory Pattern Usage:

Option 2: Redis

Redis provides fast, persistent key-value storage suitable for consent management. Configuration:
Implementation Required:
  1. Create RedisConsentStore class
  2. Use Redis hashes for user profiles: user:profile:{user_id}
  3. Use Redis hashes for consents: user:consents:{user_id}
  4. Configure TTL if retention policies apply
Example Implementation:

Production Guard

The application includes a runtime guard that prevents startup if:
Error Message:

Migration Checklist

Before deploying GDPR endpoints to production:
  • Set ENVIRONMENT=production
  • Set GDPR_STORAGE_BACKEND=postgres
  • Configure GDPR_POSTGRES_URL connection string
  • Deploy PostgreSQL GDPR schema (see Kubernetes deployment section)
  • Apply postgres-gdpr-schema-configmap.yaml to create database tables
  • Run database migrations from migrations/ directory (if any schema updates)
  • Test data subject rights workflows (see Testing section)
  • Verify data is persisted across pod/container restarts
  • Configure automated backups (daily PostgreSQL dumps recommended)
  • Configure retention policies (see Data Retention section)
  • Document data retention periods in privacy policy
  • Update privacy policy with GDPR data subject rights
  • Test GDPR API endpoints (see GDPR API Reference)
  • Verify audit logging for all GDPR operations
New in v2.8.0: PostgreSQL storage is fully implemented and production-ready. The factory pattern automatically initializes the correct storage backend based on GDPR_STORAGE_BACKEND environment variable.

Database Migrations

The migrations/ directory contains schema migrations for PostgreSQL GDPR storage:
Applying Migrations Manually:
Automated Migration (Kubernetes): Migrations are automatically applied via the postgres-gdpr-schema ConfigMap during PostgreSQL StatefulSet initialization. See deployments/base/postgres-statefulset.yaml for implementation details.
Future schema changes will be added as numbered migrations. Always apply migrations in sequential order.

GDPR Compliance Requirements

Data Retention

Configure retention policies based on your legal requirements:

Audit Trail

All GDPR operations are logged with:
  • User ID
  • Operation type (access, rectification, erasure, etc.)
  • Timestamp
  • GDPR article (15, 16, 17, 20, 21)
Log Example:

Data Deletion (Article 17)

When users exercise right to erasure:
  1. User profile and preferences are deleted
  2. Consent records are deleted
  3. Audit logs are anonymized (user_id replaced with hash)
  4. Sessions are revoked
  5. Conversations are deleted
Retention for Compliance: Some data may be retained for legal/compliance reasons:
  • Anonymized audit logs (for GDPR compliance proof)
  • Aggregated analytics (no PII)
  • Financial records (tax law requirements)

Testing

Unit Tests

Integration Tests

Test with real database:

Production Guard Test

Verify production guard:

Deployment Examples

Docker Compose

Kubernetes

Troubleshooting

Error: “GDPR endpoints use in-memory storage”

Cause: GDPR_STORAGE_BACKEND not set or set to “memory” Solution:

Error: “RuntimeError: CRITICAL: GDPR endpoints cannot use in-memory storage”

Cause: Running in production with memory backend Solution: Change backend or environment:

Data Loss on Restart

Cause: Using in-memory storage in non-development environment Solution: Migrate to PostgreSQL or Redis immediately

References

Support

For implementation assistance:
  1. Check existing issues: https://github.com/vishnu2kmohan/mcp-server-langgraph/issues
  2. Create new issue with gdpr and compliance labels
  3. Include environment details and error messages