CR-FLW-016 · USER FLOWS, DATA FLOWS & SEQUENCE DIAGRAMS

User Flows, Data Flows & Sequence Diagrams

End-to-end journeys and Mermaid sequence/flow diagrams for every core path in the Engagement & Loyalty Platform platform.

ConfidentialVersion: v1Date: 07 Jun 2026

Reading this document

This document is the single visual reference for how value moves through the Engagement & Loyalty Platform. The core diagrams describe paths that exist in the running system: a card swipe becoming points, a UPI transaction becoming a scratch card, points becoming a voucher, a refund clawing points back, a campaign budget being consumed, and a configuration or campaign activation passing through maker-checker before it goes live (campaign lifecycle approval is enforced via config-service apply-change).

Status note: two flows shown here run on-demand rather than on a schedule today — points expiry (EXPIRY entries / EXPIRY_NUDGE comms) and periodic tier re-evaluation. The expiry window is configured per accrual rule, but the FIFO expiry batch job and the scheduler/cron that would fire these automatically are roadmap. Treat the expiry/nudge steps as the target design.

The diagrams are authored in Mermaid and render in your browser. Where a diagram needs the network (the Mermaid CDN) and it is unavailable, the raw source is shown instead so the flow is never lost.

Actors

The same cast appears across most flows. Knowing each participant once makes every later diagram readable at a glance.

ActorRole in the platformMaps to
CardholderThe the Bank credit card customer who earns and redeems points.End user
the Bank CBS / Txn sourceCore Banking / the axis-txn-provider that emits authorised transactions, reversals and refunds.axis-txn-provider
Core APIIngest → accrual → ledger → balance. The accrual brain and system of record owner.core-api :3001 · /api/v1
Campaign EngineEvaluates campaigns, milestones and tiers; posts campaign-sourced accruals; consumes budgets.campaign-engine :3002
LedgerThe immutable cr.ledger_entry — every movement of points. System of record.Core API (DB)
RedemptionValidates eligibility and balance, books the debit, triggers fulfilment.redemption-service :3005
Fulfilment PartnerIssues the actual voucher / reward against consumed points.reward-fulfilment-mock
CommsNotifies the customer across SMS / Email / Push / In-App.comms-gateway · comms-viewer
Merchant ServiceMerchant-funded attribution & settlement; fulfilment-partner billing.merchant-service :3006
Admin / Maker / CheckerOperators who configure rules and campaigns under maker-checker control.config-service :3004
the Bank's mobile app appThe the Bank app (sample) where bank events originate — UPI, bill pay, card activation, FD — and where scratch cards are revealed.axis-bank-app :4005
Engagement (Core API)Ingests bank events, evaluates trigger rules & milestones, issues and reveals scratch cards.core-api :3001 · /api/v1/events

Legend

How to read the diagrams.

End-to-end platform data flow

The diagram below is the whole platform on one page: a card swipe enters from the Bank CBS, Core API turns it into a ledger credit and an updated balance, the Campaign Engine layers campaign and milestone rewards on top, and Comms tells the customer. Two branches hang off the spine — redemption (points out) and merchant-funded settlement (money between the Bank and merchants/partners).

flowchart LR
  CH([Cardholder]) -->|card swipe| CBS[the Bank CBS / Txn source]
  CBS -->|POST transactions| CORE[Core API ingest]
  CORE --> ACC[Accrual engine]
  ACC -->|ACCRUAL credit| LED[(Ledger cr.ledger_entry)]
  LED --> BAL[(point_balance projection)]
  CORE -->|txn event| CE[Campaign Engine]
  CE -->|campaign ACCRUAL| LED
  CE -->|milestone unlock| COMMS[Comms gateway]
  BAL -->|balance updated| COMMS
  COMMS --> CH

  BAL -. available .-> RS[Redemption Service]
  RS -->|REDEMPTION debit| LED
  RS -->|issue voucher| FP[Fulfilment Partner]
  FP --> COMMS

  CE -->|funded split| MS[Merchant Service]
  MS --> MTM[(merchant_txn_map)]
  MTM --> SETTLE[Settlement run]
  SETTLE -->|invoice| INV[MID / TID report]
HopWhat movesStore touchedGuarantee
CBS → Core APIAuthorised transaction (amount, MCC, account)—Idempotent ingest
Accrual → LedgerACCRUAL credit (points)cr.ledger_entryExactly-once via idempotency key
Ledger → Balanceavailable += pointscr.point_balanceReconciled projection
Campaign Engine → LedgerCampaign ACCRUALcr.ledger_entrysource_ref cmp:<id>:<acct>:<seq>
Redemption → LedgerREDEMPTION debitcr.redemption + ledgerIdempotency-Key + balance check
Merchant Service → SettlementFunded points → moneycr.merchant_txn_mapAttribution + reconciliation

Cardholder journey (lifecycle)

From the customer's point of view, Engagement & Loyalty Platform is a single continuous loop: spend, earn, watch a milestone fill, unlock a bonus, and finally redeem something tangible. The flow below traces that arc; the prose and touchpoint table beneath it name the notification fired at each beat.

flowchart TD
  A[Enrolment] --> B[First eligible transaction]
  B --> C[Accrual posted: base + MCC + tier]
  C --> D[Milestone progress updated]
  D --> E{Threshold reached?}
  E -->|no| C
  E -->|yes| F[Milestone unlocked: bonus ACCRUAL]
  F --> G[Available balance grows]
  G --> H{Cardholder redeems?}
  H -->|not yet| C
  H -->|yes| I[Redemption booked]
  I --> J[Fulfilment: voucher issued]
  J --> K[Reward delivered to customer]

The journey in words. A new cardholder is enrolled, which creates a cr.loyalty_account in active status. Their first eligible transaction flows in from CBS and Core API posts an ACCRUAL — base earn, plus any MCC accelerator, multiplied by their tier. As more transactions land, the customer climbs toward a milestone (say, ₹50,000 of spend in a quarter). When the threshold is crossed the Campaign Engine fires a milestone unlock and posts a bonus accrual. The growing available balance eventually motivates a redemption; Redemption Service books the debit, the Fulfilment Partner issues a voucher, and Comms delivers it. The loop then repeats.

StageTouchpointNotificationChannel
EnrolmentWelcome to Engagement & Loyalty PlatformWELCOMESMS + Email
First accrualYou earned your first pointsACCRUAL_FIRSTPush + In-App
Ongoing accrualPoints credited for a purchaseACCRUAL_POSTEDIn-App
Milestone nearYou are close to a rewardMILESTONE_NUDGEPush
Milestone unlockBonus points unlockedMILESTONE_UNLOCKSMS + Push
RedemptionRedemption confirmedREDEMPTION_OKSMS + Email
FulfilmentYour voucher is readyVOUCHER_ISSUEDEmail + In-App

Accrual — sequence diagram

Accrual is the platform's heartbeat. A transaction posted to POST /api/v1/transactions resolves the applicable accrual rule (base earn rate × eligible amount), adds MCC accelerators, applies the tier multiplier, and writes a single ACCRUAL credit to the ledger — guarded by an idempotency key so a replayed transaction never double-credits.

sequenceDiagram
  autonumber
  participant CH as Cardholder
  participant CBS as the Bank CBS
  participant API as Core API
  participant AE as Accrual Engine
  participant LED as Ledger
  participant BAL as point_balance
  participant CO as Comms
  CH->>CBS: Card purchase
  CBS->>API: POST /api/v1/transactions (Idempotency-Key)
  Note over API: Dedup on idempotency key
  alt key already seen
    API-->>CBS: 200 (cached result)
  else new transaction
    API->>AE: Resolve accrual rule
    AE->>AE: base earn + MCC accelerator
    AE->>AE: apply tier multiplier
    AE->>LED: Insert ACCRUAL credit (C)
    LED->>BAL: available += points
    BAL-->>API: updated balance
    API->>CO: Trigger ACCRUAL_POSTED
    CO-->>CH: Points credited
    API-->>CBS: 201 Created
  end
Invariant. The ledger entry is the source of truth; cr.point_balance is a reconciled projection. If the projection is ever rebuilt, summing the ledger reproduces available, lifetime_earned and the rest exactly.

Event trigger → scratch card → reveal → ledger credit — sequence diagram

The engagement path is event-led. A bank event (here a UPI payment from the the Bank's mobile app app) hits POST /api/v1/events, deduplicated on eventRef. The Engagement module evaluates matching trigger rules; a match draws a prize immediately (weighted random from the rule's prize table) and issues a scratch card with the prize stored hidden. The customer scratches later — the reveal is idempotent and, for a POINTS prize, posts a single ACCRUAL credit to the same immutable ledger (idempotency key scr:<scratchCardId>).

sequenceDiagram
  autonumber
  participant CH as Cardholder
  participant APP as the Bank's mobile app app
  participant API as Core API
  participant ENG as Engagement module
  participant SC as scratch_card
  participant LED as Ledger
  participant BAL as point_balance
  CH->>APP: Pay via UPI (amount)
  APP->>API: POST /api/v1/events (eventRef, UPI_TRANSACTION)
  Note over API: Dedup on eventRef
  alt eventRef already seen
    API-->>APP: 201 (same response, no new reward)
  else new event
    API->>ENG: Evaluate trigger rules + milestones
    alt trigger matches (e.g. first UPI)
      ENG->>ENG: Draw prize (weighted) from prize table
      ENG->>SC: Insert scratch_card (state ISSUED, prize hidden, expires +30d)
      SC-->>API: scratchCardId
    end
    API-->>APP: 201 { evaluations, scratchCards[] }
    APP-->>CH: "You've won a scratch card!"
  end
  CH->>APP: Scratch to reveal
  APP->>API: POST /api/v1/scratch-cards/:id/scratch
  alt card EXPIRED
    API-->>APP: 409 Conflict (expired)
  else already SCRATCHED
    API-->>APP: 200 (same prize, idempotent)
  else first reveal
    alt prize.kind = POINTS
      API->>LED: Insert ACCRUAL credit (idem scr:<id>)
      LED->>BAL: available += points
    else prize.kind = VOUCHER
      API->>SC: Record voucher label/value (no ledger credit)
    end
    API->>SC: state = SCRATCHED, scratched_at = now
    API-->>APP: 200 { prize, ledgerEntryId?, balance }
    APP-->>CH: Reveal prize + confetti
  end
Idempotency, twice. Both edges are replay-safe: the same eventRef never issues a second card, and scratching an already-revealed card returns the same prize without a second ledger credit. Prize is fixed at issue time, so the reveal is purely presentational for the customer.

Campaign & milestone unlock — sequence diagram

Beyond base earn, the Campaign Engine layers targeted rewards. When Core API emits a transaction event, the engine evaluates every live campaign whose predicate could match — checking MCC, calendar window / day-of-week, and account eligibility — then tests milestone thresholds. A match produces a campaign-sourced ACCRUAL (tagged cmp:<id>:<acct>:<seq>) and consumes from the campaign budget.

sequenceDiagram
  autonumber
  participant API as Core API
  participant CE as Campaign Engine
  participant LED as Ledger
  participant BUD as Budget
  participant CO as Comms
  API->>CE: Transaction event (account, MCC, amount)
  CE->>CE: Evaluate predicate (MCC / day / eligibility)
  alt predicate fails
    CE-->>API: no-op (not eligible)
  else predicate matches
    CE->>CE: Update milestone progress
    alt threshold not yet reached
      CE-->>API: progress recorded
    else milestone threshold reached
      CE->>BUD: Reserve + consume budget
      alt budget exhausted
        BUD-->>CE: rejected (no budget)
        CE->>CO: Trigger MILESTONE_BUDGET_OUT (ops)
      else budget available
        CE->>LED: Insert campaign ACCRUAL (source_ref cmp:id:acct:seq)
        LED-->>CE: credited
        CE->>CO: Trigger MILESTONE_UNLOCK
      end
    end
  end
CheckSourceExample
MCC predicatetxn.mccDining MCCs 5811–5814
Calendar windowcampaign.start/endFestive 01–31 Oct
Eligibilityaccount.tier / segmentSignature & above
Milestone thresholdcumulative spend / count₹50,000 in quarter
Budget guardcampaign budgetStop at allocation cap

Campaign winner & partner fulfilment — sequence diagram

A campaign reward is one of two kinds, decided by reward_def.kind. Points rewards are credited by Engagement & Loyalty Platform itself — an idempotent ACCRUAL ledger entry (key cmp:<id>:<acct>:rule), balance bump, budget consume, customer notified. Non-points rewards (a voucher, gift card, merchandise — funded by the bank or a partner) cannot be paid in points, so the engine records a winner in cr.campaign_winner (status recorded, idempotent on the same key) and calls the fulfilment partner API to deliver it. On success the winner becomes fulfilled with the partner's fulfilment_ref; the partner-API delivery is logged to comms. The runner is triggered either by POST /campaigns/:id/run or automatically by the feed scanner as new transactions post (idempotent per campaign+account, so it is safe to re-run).

sequenceDiagram
  autonumber
  participant SC as Feed Scanner / Run
  participant CE as Campaign Engine
  participant DB as cr.campaign_winner
  participant LED as Loyalty Ledger
  participant FP as Fulfilment Partner (:3103)
  participant CM as Comms Gateway (:3102)
  SC->>CE: runRuleCampaign(campaignId, affectedAccounts)
  loop each matched account
    alt reward_def.kind = points
      CE->>LED: ACCRUAL credit (idem cmp:id:acct:rule)
      CE->>CM: notify "reward unlocked: N points"
    else non-points (voucher / merchandise / partner)
      CE->>DB: INSERT winner (status recorded, idem cmp:id:acct:rule)
      CE->>FP: POST /v1/vouchers/issue {sku, points, accountRef, label} + Idempotency-Key
      FP-->>CE: 200 {voucherId / orderId, voucherMasked}
      CE->>DB: UPDATE winner status=fulfilled, fulfilment_ref
      CE->>CM: log "PARTNER API → issued 
Reward kindRecorded inWho pays itIdempotency
Pointscr.ledger_entry (ACCRUAL)Engagement & Loyalty Platform credits the loyalty balancecmp:<id>:<acct>:rule (unique)
Non-points (voucher / gift card / merchandise)cr.campaign_winner → partnerFulfilment partner API delivers; bank- or partner-fundedWinner row + Idempotency-Key on issue
Swap the mock for a real partner with no code change — the engine posts to REWARD_FULFILMENT_URL (default the local reward-fulfilment-mock); point it at a real partner endpoint to go live. If the partner is unreachable the winner stays recorded and is retried — no points or vouchers are lost. See CR-FPI-015.

Redemption — sequence diagram

Redemption is the points-out path. A request to POST :3005/redemptions with an Idempotency-Key verifies the account is active and that available covers the cost, locks the balance row for the duration of the booking, inserts cr.redemption plus a REDEMPTION debit, then asks the Fulfilment Partner to issue a voucher. The two failure branches — insufficient balance and inactive account — are shown as alt blocks.

sequenceDiagram
  autonumber
  participant CH as Customer
  participant RP as Rewards Portal
  participant RS as Redemption Service
  participant BAL as point_balance
  participant LED as Ledger
  participant FP as Fulfilment Partner
  participant CO as Comms
  CH->>RP: Choose reward, confirm
  RP->>RS: POST /redemptions (Idempotency-Key)
  RS->>BAL: SELECT ... FOR UPDATE
  alt account not active
    BAL-->>RS: status != active
    RS-->>RP: 409 Account not active
    RP-->>CH: Cannot redeem
  else insufficient available
    BAL-->>RS: available < cost
    RS-->>RP: 422 Insufficient balance
    RP-->>CH: Not enough points
  else eligible
    RS->>LED: Insert REDEMPTION debit (D)
    LED->>BAL: available -= ; lifetime_redeemed +=
    RS->>FP: Issue voucher (consumed points)
    FP-->>RS: voucher code
    RS->>CO: Trigger REDEMPTION_OK + VOUCHER_ISSUED
    CO-->>CH: Voucher delivered
    RS-->>RP: 201 Redemption confirmed
  end
Exactly-once. Re-sending the same Idempotency-Key returns the original redemption result instead of debiting twice — safe to retry on any network blip.

Reversal & clawback — sequence diagram

When CBS reports a reversal or refund, points earned on the original transaction must come back. Core API's reverse() posts a REVERSAL debit. If the customer has already spent those points, available cannot go negative — it is clamped at zero and the unrecovered remainder is carried to clawback_pending, then recovered automatically from the next accrual.

sequenceDiagram
  autonumber
  participant CBS as the Bank CBS
  participant API as Core API
  participant LED as Ledger
  participant BAL as point_balance
  CBS->>API: Reversal / refund of original txn
  API->>API: reverse(original_txn)
  API->>LED: Insert REVERSAL debit (D)
  alt available covers reversal
    LED->>BAL: available -= points
    Note over BAL: fully recovered
  else available insufficient
    LED->>BAL: available -> 0 (clamped)
    BAL->>BAL: clawback_pending += remainder
    Note over BAL: remainder owed
    API-->>API: recover on next ACCRUAL
  end
FieldEffect on reversal
availableDecremented, floored at 0
clawback_pendingHolds the unrecovered remainder
Next ACCRUALFirst settles clawback_pending, then credits the rest
Entry typeREVERSAL (txn unwound) vs CLAWBACK (recovery)
See also. The precise clamping order, partial-refund proration and clawback recovery rules are specified in CR-EDG-017 — Edge Cases & Exception Handling.

Merchant-funded settlement & fulfilment-partner billing

Some offers are co-funded. A Myntra 10X offer might be 5X bank-funded plus 5X merchant-funded. The merchant-funded portion is attributed to cr.merchant_txn_map; a periodic settlement run aggregates funded points per merchant and produces an invoice. Separately, fulfilment-partner billing is computed as consumed_points × point_value × (100 − discount)%.

sequenceDiagram
  autonumber
  participant CE as Campaign Engine
  participant MS as Merchant Service
  participant MTM as merchant_txn_map
  participant SET as Settlement Run
  participant FP as Fulfilment Partner
  participant FIN as Finance / Invoice
  CE->>MS: Funded offer split (bank X + merchant Y)
  MS->>MTM: Attribute funded points (MID/TID)
  Note over MTM: per-merchant ledger of funded points
  SET->>MTM: Aggregate funded points for period
  MTM-->>SET: totals by merchant
  SET->>FIN: Generate merchant settlement (MID/TID report)
  FP->>MS: Consumed points for issued vouchers
  MS->>FIN: Bill = consumed × point_value × (100 - discount)%
  FIN-->>MS: Invoice issued
flowchart LR
  T[Funded transaction] --> A[Attribution]
  A --> M[(merchant_txn_map)]
  M --> S[Settlement run]
  S --> R[MID / TID report]
  R --> I[Merchant invoice]
  V[Voucher consumption] --> B[Partner billing]
  B --> I
StepInputOutput
AttributionFunded offer split, MID/TIDRows in cr.merchant_txn_map
Settlement runFunded points for periodPer-merchant totals
Merchant invoiceTotals + MID/TID reportAmount due from merchant
Partner billingconsumed_points, point_value, discountconsumed × point_value × (100 − discount)%

Maker-checker approval — sequence diagram

No configuration, campaign or budget change reaches production unreviewed. A Maker submits a change, which creates a cr.approval_request in pending. A different operator — the Checker / Approver — reviews it and either approves (the change applies and goes live) or rejects (the change is discarded). The state machine beneath the sequence shows the lifecycle.

sequenceDiagram
  autonumber
  participant MK as Maker
  participant CFG as Config Service
  participant AR as approval_request
  participant CK as Checker / Approver
  participant LIVE as Live Config
  MK->>CFG: Submit config / campaign / budget change
  CFG->>AR: Create approval_request (pending)
  AR-->>MK: Submitted, awaiting review
  CK->>AR: Review pending request
  alt approved
    CK->>AR: status = approved
    AR->>LIVE: Apply change
    LIVE-->>CK: Now live
  else rejected
    CK->>AR: status = rejected (reason)
    AR-->>MK: Discarded
  end
stateDiagram-v2
  [*] --> pending : Maker submits
  pending --> approved : Checker approves
  pending --> rejected : Checker rejects
  approved --> [*] : applied to live config
  rejected --> [*] : discarded
Segregation of duties. The Maker and the Checker must be different operators; a request cannot be self-approved. The audit trail records who submitted, who actioned, and when.

Card lifecycle — state diagram

Every loyalty account carries a status in cr.loyalty_account.status that gates what the platform will do for it. The diagram shows the legal transitions; the table records what each state permits for accrual and redemption.

stateDiagram-v2
  [*] --> active : enrolment
  active --> dormant : inactivity
  dormant --> active : reactivation
  active --> blocked : risk / hold
  blocked --> active : unblock
  active --> closed : account closure
  closed --> [*]
StateAccrualRedemptionNotes
activeAllowedAllowedNormal operating state
dormantAllowed (re-activates)Blocked until activeSet after prolonged inactivity
blockedHeldBlockedRisk / fraud / customer hold
closedBlockedBlockedTerminal — no further activity
Guard. Redemption Service explicitly checks status = 'active' before booking a debit (see §6). Accrual continues to post for dormant accounts and flips them back to active.

Notification / comms data flow

Every customer-facing message follows one pipeline: a domain event triggers a template, the template engine renders it for the chosen channel(s), the message is dispatched, and the outcome is written to the notification log for audit and the comms-viewer.

flowchart LR
  EV[Domain event] --> TR[Trigger / router]
  TR --> TE[Template engine]
  TE --> CH{Channel}
  CH -->|SMS| SMS[SMS gateway]
  CH -->|Email| EM[Email]
  CH -->|Push| PU[Push]
  CH -->|In-App| IA[In-App inbox]
  SMS --> LOG[(notification_log)]
  EM --> LOG
  PU --> LOG
  IA --> LOG
  LOG --> VIEW[comms-viewer]
EventTemplateDefault channel
Account enrolledWELCOMESMS + Email
ACCRUAL postedACCRUAL_POSTEDIn-App
Milestone unlockedMILESTONE_UNLOCKSMS + Push
Redemption confirmedREDEMPTION_OKSMS + Email
Voucher issuedVOUCHER_ISSUEDEmail + In-App
Reversal appliedPOINTS_REVERSEDSMS
Points expiring soonEXPIRY_NUDGEPush + Email
Where to go next. For the exact rules behind clamping, partial refunds, expiry, duplicate handling and other corner cases, see CR-EDG-017 — Edge Cases & Exception Handling. For operational procedures — running settlements, actioning approvals, and managing accounts — see CR-AOG-018 — Admin & Operations Guide.