Event Flows

All events flow through the default EventBridge bus for the region. The Insight Service is both a producer (income signal, insight availability) and a consumer (new account events and institution changes from the Transactions Service, and its own income events routed internally to the funds-notifier).

Events Produced

Source Detail-Type Emitted By Description

insight-service.income

income_txn

prod-insight-income-signaller

Emitted for each transaction on the prod-txn-floatme-transactions Kinesis stream that has a negative amount (credit) and is dated today in the America/Chicago timezone. The event detail is the full Transaction object from the FloatMe transaction model.

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.

income_txn Payload

{
  "source": "insight-service.income",
  "detail-type": "income_txn",
  "detail": {
    "transaction_id": "...",
    "user_id": "...",
    "amount": -15000,
    "date": "2024-01-15",
    "account_id": "...",
    "name": "EMPLOYER DIRECT DEP"
  }
}

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.

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

Three EventBridge rules are owned by this service. All 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

income_detected_rule

{
  "detail-type": ["income_txn"],
  "source": ["insight-service.income"],
  "detail": {
    "amount": [{"numeric": ["<", -11999]}]
  }
}
Field Value

Target queue

prod-income-event-tap

Consumer Lambda

prod-insight-funds-notifier

Amount filter

amount < -11999 cents (i.e. income exceeds $119.99); the threshold is the cc_notification_limit Terraform variable (default: 11999)

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)


Full Routing Diagram

                        ┌─────────────────────────────────────────┐
                        │         EventBridge (default bus)        │
                        └────────────────┬────────────────────────┘
                                         │
          ┌──────────────────────────────┼──────────────────────────────┐
          │                              │                              │
          ▼                              ▼                              ▼
  balance_alert_rule          income_detected_rule        account_change_detected_rule
  source: txn-service.feeder  source: insight-service     source: txn-service.api
  detail-type: new_account    detail-type: income_txn     detail-type: new_bank_account_added
  (no detail filter)          amount < -11999 cents       (no detail filter)
          │                              │                              │
          ▼                              ▼                              ▼
  prod-insight-               prod-income-                prod-insight-institution-
  balance-alert-event-tap     event-tap                   change-handler-sqs-tap
          │                              │                              │
          ▼                              ▼                              ▼
  prod-insight-               prod-insight-               prod-insight-institution-
  balance-alert               funds-notifier              change-handler

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

prod-insight-income-signaller  ──► insight-service.income / income_txn ──► default bus
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).