Service Layer medium complexity backend
1
Dependencies
1
Dependents
11
Entities
0
Integrations

Description

Core backend service responsible for writing audit log entries and querying them for the admin UI. Implements a fire-and-forget write queue to ensure audit logging is non-blocking. Enforces immutability - no delete or update operations are exposed via the API.

Feature: Audit Log

audit-service

Responsibilities

  • Write audit log entries asynchronously via an in-process queue
  • Expose paginated, filterable query API for admin log retrieval
  • Enforce tenant isolation - all queries scoped to organization_id
  • Support CSV/JSON export generation for filtered log sets
  • Validate and sanitize ip_address, user_agent, and JSONB fields on write

Interfaces

log(entry: AuditLogEntry): void
query(filters: AuditLogFilters, pagination: Pagination): Promise<AuditLogPage>
exportLogs(filters: AuditLogFilters, format: 'csv' | 'json'): Promise<Buffer>
getEventTypes(): string[]

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component

Sub-Components (1)

Audit Write Queue
component low

In-process async queue that buffers audit log writes and flushes them to the database without blocking the originating request. Provides resilience against transient database errors via retry with exponential backoff.

  • Accept fire-and-forget log entries from callers
  • Batch-flush entries to the database at configurable intervals
  • Retry failed writes with exponential backoff up to a configured limit