Saltar al contenido principal

Audit Logging Architecture

How entity changes are tracked for compliance and traceability.

Overviewโ€‹

The audit logging system records:

  • Who changed what entity
  • What changed (old vs new values)
  • When it changed
  • IP address and request context

Activity Log Flowโ€‹

ActivityLog Entityโ€‹

ColumnTypeDescription
idUUIDLog entry ID
entitystringEntity name
entityIdUUIDID of changed entity
actionenumCREATED, UPDATED, DELETED
actorTypeenumUSER, SYSTEM
actorIdUUIDUser who made the change
dataJSONNew values
previousDataJSONOld values
ipAddressstringClient IP
createdAtdatetimeTimestamp

Using the Decoratorโ€‹

@ActivityLog('TASK_UPDATED')
@Put(':id')
async update(@Param('id') id: string, @Body() dto: UpdateTaskDTO) {
return this.taskService.update(id, dto);
}

Querying Logsโ€‹

GET /api/activity-log?entity=Task&entityId=uuid&action=UPDATED