Service Layer high complexity Shared Component backend
2
Dependencies
17
Dependents
14
Entities
0
Integrations

Description

Core append-only backend utility that writes immutable audit log entries. Called by all authentication flows and every write operation across the platform - this service must never be bypassed. Uses INSERT-only semantics enforced at both the application layer and via a PostgreSQL role restriction. Each entry captures event_type, actor_id, actor_role, target_entity_type, target_entity_id, organization_id, ip_address, user_agent, and a JSON metadata blob.

Feature: Audit Log

audit-service

Responsibilities

  • Write immutable audit log entries using INSERT-only semantics
  • Capture full event context including actor, target, organization, IP, and user agent
  • Operate as a shared utility called by all write operations and auth flows
  • Use the dedicated audit_log write role to enforce append-only database access
  • Support fire-and-forget async writes to avoid blocking the primary operation

Interfaces

log(event: AuditEvent): Promise<void>
logAuthEvent(type: AuthEventType, actorId: string, metadata: object): Promise<void>
logAdminAction(type: AdminActionType, actorId: string, targetEntityType: string, targetEntityId: string, orgId: string, metadata: object): Promise<void>
logDataAccess(actorId: string, targetEntityType: string, targetEntityId: string, orgId: string, metadata: object): Promise<void>