Compliance Module

GDPR, CCPA, and PDPA compliance automation — regulations, DSR handling, consent management, data retention, inventory, and report generation.

The Compliance module is SCRIPE's built-in regulatory compliance engine. It helps platform operators and their tenants stay compliant with major data protection laws (GDPR, CCPA, PDPA) through automated tools for managing data subject requests, consent records, retention policies, and generating audit-ready compliance reports.

What is the Compliance Module?

The Compliance module provides six interconnected sub-systems that cover the full compliance lifecycle. Instead of building compliance tooling from scratch, SCRIPE tenants get a production-ready system that tracks, automates, and reports on their data protection obligations.

  • Data Subject Requests

    Handles Subject Requests including Export, Erasure, Rectification, and Restriction with full lifecycle tracking and SLA monitoring.

  • Consent Management

    Immutable tracking of consent states, snapshots, and audit trails for GDPR Article 6 and CCPA compliance.

  • Retention Policies

    Enforces data destruction policies based on configurable retention periods with automated Delete or Anonymize actions.

  • Data Inventory

    Maps sensitive PII locations across modules — required for GDPR Article 30 Records of Processing Activities (RoPA).

  • Compliance Reports

    Generates async audit-ready reports (GDPR Overview, DSR Summary, Consent Audit, Retention Analysis, Data Inventory Export).

  • Webhook Events

    11 real-time webhook events covering DSR lifecycle, consent changes, retention enforcement, and report generation.

Six Sub-Systems

Each sub-system handles a specific compliance domain:

Data Inventory — A registry of all personal data categories the platform processes. — Maps sensitive PII locations across modules
Identity Module — Provides User/Admin context & Auth
Entitlements Module — Feature-gates compliance capabilities
Data Subject Requests (DSR) — Manages rights requests from data subjects (export, erasure, rectification, restriction). — Handles Subject Requests (Export, Erasure, Rectification)
Consent Management — Records, tracks, and audits user consent grants and withdrawals. — Immutable tracking of consent states & snapshots
Data Retention Policies — Defines how long data is kept and what happens when it expires (delete or anonymize). — Enforces data destruction policies based on age
Compliance Reports — Generates async audit-ready reports (GDPR Overview, DSR Summary, Consent Audit, etc.). — Generates RoPA and DPIA compliance reports

Supported Regulations

SCRIPE's Compliance module supports enforcement of these major data protection regulations. Each regulation is pre-seeded with its SLA deadlines and penalty structures.

RegulationRegion / JurisdictionResponse SLAMaximum Penalty
GDPREuropean Union (EU/EEA)30 days€20M / 4% revenue
CCPA / CPRACalifornia, USA45 days$7,500 / violation
LGPDBrazil15 days2% revenue (R$50M cap)
POPIASouth Africa30 daysR10M / imprisonment
PDPASingapore30 daysSGD 1M

Backend Architecture

The Compliance backend follows the standard SCRIPE 3-project module layout (Domain / Application / Infrastructure) with a dedicated ComplianceDbContext and ComplianceController.

ComplianceDbContext.csC#
public class ComplianceDbContext : DbContext
{
    public DbSet<DataSubjectRequest> DsrRequests { get; set; }
    public DbSet<DsrModuleExecution> DsrModuleExecutions { get; set; }
    public DbSet<DsrStatusHistory> DsrStatusHistories { get; set; }
    public DbSet<ConsentRecord> ConsentRecords { get; set; }
    public DbSet<ConsentPurpose> ConsentPurposes { get; set; }
    public DbSet<ConsentSnapshot> ConsentSnapshots { get; set; }
    public DbSet<RetentionPolicy> RetentionPolicies { get; set; }
    public DbSet<RetentionExecution> RetentionExecutions { get; set; }
    public DbSet<DataInventoryItem> DataInventoryItems { get; set; }
    public DbSet<ComplianceReport> ComplianceReports { get; set; }
    public DbSet<RegulationProfile> RegulationProfiles { get; set; }
}

CQRS Commands & Queries

The Compliance module uses the standard SCRIPE mediator CQRS pattern. Commands handle write operations and Queries handle read operations, each with dedicated FluentValidation validators.

TypeHandlerDescription
CommandSubmitDsrCommandSubmits a new Data Subject Request with validation and SLA calculation
CommandReviewDsrCommandReviews and updates the status of a DSR (approve, reject, complete)
CommandRecordConsentCommandRecords a consent grant with full audit metadata (IP, user agent, version)
CommandUpdateRetentionPolicyCommandUpdates retention policy configuration (days, action, active status)
QueryGetDsrListQueryLists all DSRs with pagination, filtering by status/type/regulation
QueryGetConsentAnalyticsQueryAggregates consent statistics by purpose, status, and time period
QueryGetComplianceDashboardQueryReturns a summary dashboard with counts across all compliance sub-systems

Frontend Architecture

The frontend is organized as six independent sub-modules under src/modules/compliance/, each with its own domain, data, and presentation layers following the View/ViewModel pattern.

ComponentResponsibility
DsrListViewModelHandles the pagination, filtering, and assignment of incoming Data Subject Requests.
ConsentRecordViewRenders the immutable consent snapshot alongside user agent and timestamp metadata.
Module StructureText
src/modules/compliance/
├── di.ts                       # Dependency Injection container
├── index.ts                    # Public exports
├── dashboard/                  # Dashboard sub-module
│   └── src/presentation/views/
├── dsr/                        # Data Subject Requests
│   └── src/{domain,data,presentation}/
├── consent/                    # Consent Management
│   └── src/{domain,data,presentation}/
├── retention/                  # Retention Policies
│   └── src/{domain,data,presentation}/
├── inventory/                  # Data Inventory
│   └── src/{domain,data,presentation}/
└── reports/                    # Compliance Reports
    └── src/{domain,data,presentation}/

API Endpoints Overview

All endpoints are under /api/v1/compliances/ and require authentication with the compliance.view permission.

MethodEndpointDescriptionAuth
GET/api/v1/compliance/regulationsList all regulation profiles configured for the platform🔒 Required
POST/api/v1/compliance/dsrSubmit a new Data Subject Request (Export, Erasure, Rectification, Restriction)🔒 Required
GET/api/v1/compliance/dsrList all DSRs with pagination, filtering by status/type/regulation🔒 Required
POST/api/v1/compliance/dsr/{id}/reviewReview a DSR — approve, reject, or mark as completed with resolution notes🔒 Required
POST/api/v1/compliance/consentRecord a new consent grant with full audit metadata🔒 Required
GET/api/v1/compliance/consent/analyticsRetrieve consent analytics (grant/withdrawal rates by purpose)🔒 Required
GET/api/v1/compliance/retentionList all retention policies with enforcement status🔒 Required
PUT/api/v1/compliance/retentionUpdate a retention policy (days, action, active status)🔒 Required
GET/api/v1/compliance/data-inventoryList all data inventory items (GDPR Article 30 RoPA)🔒 Required
GET/api/v1/compliance/reportsList all compliance reports with status and type filters🔒 Required
GET/api/v1/compliance/reports/{id}/downloadDownload a generated report in CSV, JSON, XLSX, or PDF format🔒 Required
POST/api/v1/compliance/reports/generateQueue a new async compliance report generation job🔒 Required
GET/api/v1/compliance/dashboardRetrieve the compliance dashboard summary (counts, SLA status, alerts)🔒 Required

Webhook Events

The Compliance module fires 11 real-time webhook events that external systems can subscribe to. Events are auto-registered via the ComplianceWebhookEventCatalog and dispatched through the IWebhookDispatcher pipeline.

Event KeyCategoryDescription
compliance.dsr_submittedCompliance DSRFired when a new Data Subject Request is submitted
compliance.dsr_status_changedCompliance DSRFired when a DSR status transitions (Pending → InProgress → Completed/Rejected)
compliance.dsr_completedCompliance DSRFired when a DSR is fully completed (data exported, erased, or rectified)
compliance.dsr_erasure_confirmedCompliance DSRFired when an erasure DSR is confirmed by an admin (nuclear action)
compliance.dsr_cancelledCompliance DSRFired when a DSR is cancelled before completion
compliance.consent_grantedCompliance ConsentFired when a user grants consent for a specific purpose
compliance.consent_withdrawnCompliance ConsentFired when a user withdraws previously granted consent
compliance.retention_policy_updatedCompliance RetentionFired when a retention policy configuration is updated
compliance.retention_execution_completedCompliance RetentionFired when a retention enforcement job completes execution
compliance.report_generatedCompliance ReportsFired when a compliance report generation completes successfully
compliance.report_failedCompliance ReportsFired when a compliance report generation fails

Quick Start Guide

  1. Seed Compliance Data

    Run the development seeder to populate regulation profiles, sample consent purposes, and retention policies for your test environment.
    Shell
    scripe db seed --dev -m Compliance
  2. Configure Regulation Profiles

    Navigate to Compliance → Regulations in the admin panel. Enable the regulations your platform operates under (GDPR, CCPA, PDPA). Each regulation defines the SLA deadlines and penalty structures that will be enforced.
  3. Submit a Test DSR

    Create a Data Subject Request to test the full lifecycle. The system will validate the request, calculate the SLA deadline, and make it available for assignment to a compliance officer.
    JSON
    POST /api/v1/compliance/dsr
    {
      "requestType": "Access",
      "regulationCode": "GDPR",
      "subjectEmail": "user@example.com"
    }
  4. Record Consent & Configure Retention

    Set up consent purposes (Marketing, Analytics, Third-Party) and configure retention policies for each data category. The retention enforcement job will automatically apply the configured actions when data ages past the retention period.
  5. Generate a Compliance Report

    Queue an async compliance report. The report will be generated in the background and appear in the Reports list once ready. Download it in CSV, JSON, XLSX, or PDF format.
    JSON
    POST /api/v1/compliance/reports/generate
    {
      "reportType": "DSR_Summary",
      "periodStart": "2026-01-01",
      "periodEnd": "2026-05-01"
    }

Security Considerations

Compliance data is among the most sensitive in the platform. All endpoints are protected by JWT authentication, role-based authorization, and encrypted ID transit. Personal data in DSRs and consent records is subject to field-level security restrictions.

  • Recommended Practices

    • Enable field-level security for PII fields in DSR responses
    • Configure webhook secrets for all compliance event subscriptions
    • Set retention policies for compliance data itself (meta-compliance)
    • Review audit logs regularly for unauthorized access attempts
  • Anti-Patterns to Avoid

    • Never expose DSR endpoints without AdminOnly authentication
    • Never skip consent version tracking — it invalidates the audit trail
    • Never hard-delete compliance records — always use soft-delete
    • Never bypass the webhook dispatcher for compliance events