Balance Alerts

site-insight-balance-alert sends a low-balance push notification when a user’s newly linked main account is below their configured threshold and they are float-eligible. It consumes new_account events (txn-service.feeder) tapped to SQS — see Events. The message detail is a Transactions Service account (user_id, is_main, balances).

Flow

Messages in a batch are processed concurrently; each account runs the Guards in order and stops silently at the first that applies.

  1. Evaluate the available balance, or current when available is zero.

  2. Take the per-user lock in the locks table (schema); released when the message finishes.

  3. Read the alert entity and apply the cooldown guard.

  4. Read low_balance_alert from user-balance-settings (schema) and apply the opt-out and threshold guards.

  5. Call Underwriting FloatRequest with amount 0 and apply the eligibility guard.

  6. Write the alert entity (alert_sent: true, balances, threshold).

  7. When NOTIFICATION_FLAG is true, dispatch the low_balance_alert Segment event with new_available_balance and new_current_balance in dollars. Metric insight.balance.alerts.

Source: pkg/balance-alert/processor.go

Guards

Guard Skip when

Disregard

Balance above $50.00, account is not is_main, or available + current == 0

Cooldown

alert.alert_sent is true and alert.updated_date is within the last 7 days

Opted out

low_balance_alert is null

Above threshold

Balance above low_balance_alert (dollars, compared in cents)

Not eligible

Underwriting approved == false

Source: pkg/balance-alert/models.go, pkg/balance-alert/processor.go

Any error (lock, DynamoDB, settings, Underwriting, Segment) fails the batch item; the message retries up to 5 times before the DLQ. The alert row is written before the Segment call, so the cooldown applies even if delivery fails.