Infrastructure medium complexity backend
1
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

Scheduled background job that runs nightly to materialize expense aggregate metrics and statistical baseline values into the expense_summary_snapshots table. Reduces dashboard query latency by replacing ad-hoc aggregation over large claim datasets with simple snapshot reads supplemented by a same-day real-time delta.

Feature: Reimbursement Overview

expense-aggregate-scheduler

Responsibilities

  • Run nightly SQL aggregation over expense_claims and expense_items grouped by organization_id and time period
  • Upsert computed aggregate rows into the expense_summary_snapshots materialized table
  • Compute and persist rolling average and standard deviation baselines per organization for the anomaly detection layer
  • Log execution status and surface failures via existing monitoring infrastructure

Interfaces

run(): Promise<void>
aggregateForOrg(orgId: string): Promise<ExpenseSummarySnapshot>
computeBaseline(orgId: string): Promise<AnomalyBaseline>
onFailure(err: Error): void

Relationships

Dependencies (1)

Components this component depends on

Related Data Entities (1)

Data entities managed by this component