Compliance

Compliance gives operators security, RBAC, audit-log, and retention views without mixing them into unrelated modules.

On this page

Where to look

AreaMaintainer reference
Routes
Implementation referencesrc/app/(dashboard)/admin/security, src/app/(dashboard)/admin/audit-log
Security overview
Implementation referencesrc/features/compliance/server/security/queries.ts
Permission matrix
Implementation referencesrc/features/compliance/server/permissions/matrix-query.ts
Audit
Implementation referencesrc/features/compliance/server/audit/query.ts, redaction.ts, descriptions.ts, values.ts
Retention
Implementation referencesrc/features/compliance/server/retention/service.ts
Shared
Implementation referencesrc/features/compliance/shared/types.ts, formatters.ts
UI
Implementation referencesrc/features/compliance/ui/security-dashboard.tsx, audit-log-client.tsx
Implementation reference3 areas

These Product code locations explain how the documented behavior is implemented. Expand them when you are ready to customize or maintain this area.

Security and audit surfaces

Admin pages render security overview, permission matrix, audit log, and retention status.

  • src/app/(dashboard)/admin/security/page.tsx
  • src/app/(dashboard)/admin/audit-log/page.tsx
  • src/features/compliance/ui/security-dashboard.tsx
  • src/features/compliance/ui/audit-log-client.tsx

Compliance reads

Security, permission, and audit queries keep admin reporting server-owned and role-aware.

  • src/features/compliance/server/security/queries.ts
  • src/features/compliance/server/permissions/matrix-query.ts
  • src/features/compliance/server/audit/query.ts

Redaction and retention

Audit redaction and retention services preserve useful context without exposing sensitive payloads.

  • src/features/compliance/server/audit/redaction.ts
  • src/features/compliance/server/audit/descriptions.ts
  • src/features/compliance/server/retention/service.ts

Reference paths are relative to the Shipflash-Product checkout.

Compliance reporting flow

  1. 1

    Gate admin routes

    Security and audit surfaces should only render after server-side access checks.

    Relevant Product code
    • src/app/(dashboard)/admin/security/page.tsx
    • src/lib/auth/guards/route.ts
  2. 2

    Read security and permission state

    Dashboard cards and permission matrix exports are assembled from compliance-owned server queries.

    Relevant Product code
    • src/features/compliance/server/security/queries.ts
    • src/features/compliance/server/permissions/matrix-query.ts
  3. 3

    Redact audit fields by role

    Audit descriptions, values, and redaction helpers keep logs useful without exposing raw sensitive payloads.

    Relevant Product code
    • src/features/compliance/server/audit/query.ts
    • src/features/compliance/server/audit/redaction.ts
    • src/features/compliance/server/audit/values.ts
  4. 4

    Run retention as protected work

    Retention cleanup is handled by the compliance service behind the protected cron route.

    Relevant Product code
    • src/features/compliance/server/retention/service.ts

Audit redaction branch

Use this example as a starting point, then adapt it to your product's rules and configuration.

Profile audit entries preserve role changes but remove raw metadata and sensitive state.

ts
if (entry.entityType === "profile") {
  return {
    ...entry,
    actorEmail: maskedActorEmail,
    targetLabel: maskedTargetLabel,
    description: maskedDescription,
    metadata: {},
    beforeState: pickObjectKeys(entry.beforeState, ["role"]),
    afterState: pickObjectKeys(entry.afterState, ["role"]),
    redacted: true,
  };
}
Source reference
  • src/features/compliance/server/audit/redaction.ts

Compliance rules

  • Keep admin-only pages behind server-side role checks.
  • Do not log secrets, raw tokens, or full provider payloads.
  • Preserve stable identifiers in audit entries.
  • Treat retention work as operational work and make it easy to verify.