Event Flows

All events flow through the default EventBridge bus for the region. The Insight Service is both a producer (insight availability) and a consumer (new account events and institution changes from the Transactions Service).

Events Produced

Source Detail-Type Emitted By Description

insight-service.miner

user_new_insights_available

prod-insight-miner

Emitted after the miner has processed the last page of insight data for a user. Gated on last_page = true in DynamoDB; not emitted for intermediate pages in a multi-page insight run. The event detail contains user_id and last_page: true.

user_new_insights_available Payload

{
  "source": "insight-service.miner",
  "detail-type": "user_new_insights_available",
  "detail": {
    "user_id": "...",
    "last_page": true
  }
}

Events Consumed

Source Detail-Type Consumed By Description

txn-service.feeder

new_account

prod-insight-balance-alert (via balance_alert_ruleprod-insight-balance-alert-event-tap SQS)

Fired by the Transactions Service feeder when it processes a new account from an existing Plaid connection. The detail contains an account object including user_id, IsMain, and Balances. Triggers a low-balance alert flow.

txn-service.api

new_bank_account_added

prod-insight-institution-change-handler (via account_change_detected_ruleprod-insight-institution-change-handler-sqs-tap SQS)

Fired by the Transactions Service API Lambda when a user explicitly connects a new bank institution. The detail contains user_id and account_id. Triggers employment record invalidation.

txn-service.refiner

user_new_txns_batch_completed

prod-insight-savings-snapshot (via savings_snapshot_ruleprod-insight-savings-snapshot-event-tap SQS)

Fired by the Transactions Service refiner once a user’s transaction batch finishes — only on the last page, and only when the batch contained new transactions, so there is no per-page duplication. A delete-only batch produces no event. The detail is the standard event envelope whose payload is the user ID on its own, not an object. Triggers the monthly savings balance snapshot.

insight-service.income

income_txn

prod-insight-funds-notifier (via income_detected_ruleprod-income-event-tap SQS)

The Insight Service consumes its own income_txn events via an EventBridge rule that adds an amount filter. Only events where amount < -119.99 (i.e. amount < -11999 cents, configurable via cc_notification_limit Terraform variable) reach the funds-notifier.


EventBridge Rules

Two EventBridge rules are owned by this service. Both operate on the default event bus.

balance_alert_rule

{
  "detail-type": ["new_account"],
  "source": ["txn-service.feeder"]
}
Field Value

Target queue

prod-insight-balance-alert-event-tap

Consumer Lambda

prod-insight-balance-alert

Enabled

Always

account_change_detected_rule

{
  "detail-type": ["new_bank_account_added"],
  "source": ["txn-service.api"]
}
Field Value

Target queue

prod-insight-institution-change-handler-sqs-tap

Consumer Lambda

prod-insight-institution-change-handler

Enabled

Controlled by account_change_handler_enabled Terraform variable (enables/disables the rule without destroying it)

savings_snapshot_rule

{
  "detail-type": ["user_new_txns_batch_completed"],
  "source": ["txn-service.refiner"]
}
Field Value

Target queue

prod-insight-savings-snapshot-event-tap

Consumer Lambda

prod-insight-savings-snapshot


Full Routing Diagram

                ┌─────────────────────────────────────────┐
                │         EventBridge (default bus)        │
                └────────────────┬────────────────────────┘
                                 │
          ┌──────────────────────┴───────────────────────┐
          │                                              │
          ▼                                              ▼
  balance_alert_rule                     account_change_detected_rule
  source: txn-service.feeder             source: txn-service.api
  detail-type: new_account               detail-type: new_bank_account_added
  (no detail filter)                     (no detail filter)
          │                                              │
          ▼                                              ▼
  prod-insight-                          prod-insight-institution-
  balance-alert-event-tap                change-handler-sqs-tap
          │                                              │
          ▼                                              ▼
  prod-insight-                          prod-insight-institution-
  balance-alert                          change-handler

Events produced by this service enter the bus from the left:

prod-insight-miner ──► insight-service.miner / user_new_insights_available ──► default bus

The user_new_insights_available event has no consumer rule defined within this service — it is consumed by downstream services (e.g. the Float Service prod-floats-income-event-tap rule).