Service Layer medium complexity backend
0
Dependencies
7
Dependents
13
Entities
0
Integrations

Description

Shared backend helper injected into sensitive domain services (user management, role assignment, organization settings) to emit append-only audit events. Enforces immutability - no UPDATE or DELETE path exists.

Feature: Audit Log

audit-log-service

Sources & reasoning

Core service implementing the append-only event emission pattern. Injected at the service layer of all sensitive domain operations. Also handles streaming CSV export to avoid memory limits on high-volume organizations.

No source references — this artifact was included based on reasoning alone (see above).

Responsibilities

  • Accept structured audit event payloads and persist to audit_logs table
  • Enforce append-only constraint - no update or delete operations
  • Scope all entries to the current organization tenant
  • Record actor_id, actor_role, action_type, target_entity, target_id, organization_id, and timestamp
  • Log Global Admin support-access sessions automatically

Interfaces

log(event: AuditEvent): Promise<void>
query(filters: AuditFilters, cursor?: string): Promise<AuditLogPage>
exportCsv(filters: AuditFilters): AsyncIterable<Buffer>