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:
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.
| Regulation | Region / Jurisdiction | Response SLA | Maximum Penalty |
|---|---|---|---|
| GDPR | European Union (EU/EEA) | 30 days | €20M / 4% revenue |
| CCPA / CPRA | California, USA | 45 days | $7,500 / violation |
| LGPD | Brazil | 15 days | 2% revenue (R$50M cap) |
| POPIA | South Africa | 30 days | R10M / imprisonment |
| PDPA | Singapore | 30 days | SGD 1M |
Backend Architecture
The Compliance backend follows the standard SCRIPE 3-project module layout (Domain / Application / Infrastructure) with a dedicated ComplianceDbContext and ComplianceController.
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.
| Type | Handler | Description |
|---|---|---|
| Command | SubmitDsrCommand | Submits a new Data Subject Request with validation and SLA calculation |
| Command | ReviewDsrCommand | Reviews and updates the status of a DSR (approve, reject, complete) |
| Command | RecordConsentCommand | Records a consent grant with full audit metadata (IP, user agent, version) |
| Command | UpdateRetentionPolicyCommand | Updates retention policy configuration (days, action, active status) |
| Query | GetDsrListQuery | Lists all DSRs with pagination, filtering by status/type/regulation |
| Query | GetConsentAnalyticsQuery | Aggregates consent statistics by purpose, status, and time period |
| Query | GetComplianceDashboardQuery | Returns 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.
| Component | Responsibility |
|---|---|
| DsrListViewModel | Handles the pagination, filtering, and assignment of incoming Data Subject Requests. |
| ConsentRecordView | Renders the immutable consent snapshot alongside user agent and timestamp metadata. |
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.
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/v1/compliance/regulations | List all regulation profiles configured for the platform | 🔒 Required |
| POST | /api/v1/compliance/dsr | Submit a new Data Subject Request (Export, Erasure, Rectification, Restriction) | 🔒 Required |
| GET | /api/v1/compliance/dsr | List all DSRs with pagination, filtering by status/type/regulation | 🔒 Required |
| POST | /api/v1/compliance/dsr/{id}/review | Review a DSR — approve, reject, or mark as completed with resolution notes | 🔒 Required |
| POST | /api/v1/compliance/consent | Record a new consent grant with full audit metadata | 🔒 Required |
| GET | /api/v1/compliance/consent/analytics | Retrieve consent analytics (grant/withdrawal rates by purpose) | 🔒 Required |
| GET | /api/v1/compliance/retention | List all retention policies with enforcement status | 🔒 Required |
| PUT | /api/v1/compliance/retention | Update a retention policy (days, action, active status) | 🔒 Required |
| GET | /api/v1/compliance/data-inventory | List all data inventory items (GDPR Article 30 RoPA) | 🔒 Required |
| GET | /api/v1/compliance/reports | List all compliance reports with status and type filters | 🔒 Required |
| GET | /api/v1/compliance/reports/{id}/download | Download a generated report in CSV, JSON, XLSX, or PDF format | 🔒 Required |
| POST | /api/v1/compliance/reports/generate | Queue a new async compliance report generation job | 🔒 Required |
| GET | /api/v1/compliance/dashboard | Retrieve 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 Key | Category | Description |
|---|---|---|
| compliance.dsr_submitted | Compliance DSR | Fired when a new Data Subject Request is submitted |
| compliance.dsr_status_changed | Compliance DSR | Fired when a DSR status transitions (Pending → InProgress → Completed/Rejected) |
| compliance.dsr_completed | Compliance DSR | Fired when a DSR is fully completed (data exported, erased, or rectified) |
| compliance.dsr_erasure_confirmed | Compliance DSR | Fired when an erasure DSR is confirmed by an admin (nuclear action) |
| compliance.dsr_cancelled | Compliance DSR | Fired when a DSR is cancelled before completion |
| compliance.consent_granted | Compliance Consent | Fired when a user grants consent for a specific purpose |
| compliance.consent_withdrawn | Compliance Consent | Fired when a user withdraws previously granted consent |
| compliance.retention_policy_updated | Compliance Retention | Fired when a retention policy configuration is updated |
| compliance.retention_execution_completed | Compliance Retention | Fired when a retention enforcement job completes execution |
| compliance.report_generated | Compliance Reports | Fired when a compliance report generation completes successfully |
| compliance.report_failed | Compliance Reports | Fired when a compliance report generation fails |
Quick Start Guide
Seed Compliance Data
Run the development seeder to populate regulation profiles, sample consent purposes, and retention policies for your test environment.Shellscripe db seed --dev -m ComplianceConfigure 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.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.JSONPOST /api/v1/compliance/dsr { "requestType": "Access", "regulationCode": "GDPR", "subjectEmail": "user@example.com" }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.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.JSONPOST /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