CR-HLD-012 · HIGH-LEVEL DESIGN

High-Level Design

Consolidated design that bridges the SRS to development — module designs, key algorithms, end-to-end flows, design decisions and how the platform realises its non-functional targets.

ConfidentialVersion: 1.0Status: Pre-development baselineDate: 06 Jun 2026

Purpose & References

This HLD turns the requirements in the SRS (CR-SRS-003) into a design developers can build against. It complements — and does not repeat — the Architecture (CR-ARC-004), DB Schema (CR-DBS-013) and API Spec (CR-API-006). Build tracking is governed by the Module Dev Checklist (CR-DCL-014).

Design Goals

#GoalHow it is met
1Correct, auditable pointsImmutable ledger as system of record; balances are a reconciled projection; exactly-once via idempotency keys.
2Configurable, no redeployRules/campaigns/catalogue/tiers/templates are versioned data; maker-checker gated.
3Bank-controlled dataAll PII/txn data inside the Bank; only catalogue/fulfilment/notification egress.
4Scalable & resilientEvent-driven, stateless services, partitioned ledger, sagas with compensation.
5Comprehensive rewardsEarn (base→tier→merchant-funded), tiers, pooling/transfer, redemption everywhere, integrity controls.

Logical View

Thirteen functional modules over four data domains, fronted by an API gateway and an event bus. See Architecture Figures 1–2 for context & container views.

M1
Accrual Engine
M2
Campaign & Milestone
M3
Loyalty Ledger
M4
Redemption & Fulfilment
M5
Merchant-Funded
M6
Communication
M7
Admin & Governance
M8
MIS, Recon & Audit
M9
Customer Experience
M10
Tiers & Status
M11
Integrity & Risk
M12
Transfer, Pooling & Partners
M13
Engagement: Triggers, Scratch Cards & Milestones

Module Designs

M1 — Accrual Engine

Responsibility: turn eligible transactions into ledger credits. Inputs: transaction events. Outputs: PointsAccrued / AccrualReversed events & ledger entries. Owns: accrual_rule, rule_version.

Earn calculation algorithm

# pseudocode — evaluated per eligible transaction
points = 0
if not eligible(txn): record(excluded); return
base = floor(txn.amount / rule.per_amount) * rule.points
mult = 1
if matches(txn, rule.accelerator): mult *= rule.factor          # MCC/merchant/channel
mult *= tier_multiplier(account.active_tier)                    # M10
points = round(base * mult, rule.rounding)
points += active_campaign_bonus(txn, account)                   # M2 hooks
points = apply_caps(points, account, rule.caps)                 # per txn/day/cycle/lifetime
post_ledger(account, +points, ref=txn.id, rule=rule.id, idem=txn.ext_ref)
Idempotency: idempotency_key = external_txn_ref. Re-delivery returns the original posting; reversal posts a compensating entry referencing the original (FR-M1-07).

M2 — Campaign & Milestone Engine

Evaluates rules (segment + spend + count + MCC/merchant + channel + period, AND/OR groups), tracks per-customer progress, unlocks rewards once, enforces budgets with auto-pause. Owns: campaign, milestone, segment, campaign_enrolment, milestone_progress. Listens to accrual/transaction events; emits MilestoneUnlocked. Lifecycle rewards (welcome/anniversary/birthday/surprise) are date/event-triggered campaigns.

M3 — Loyalty Ledger

Append-only entries (ACCRUAL/REDEMPTION/REVERSAL/EXPIRY/ADJUSTMENT/CLAWBACK/TRANSFER/MIGRATION). point_balance (available/pending/locked/lifetime) is a projection rebuilt & reconciled nightly. Expiry uses FIFO over point_lot. See lifecycle state machine in Architecture §Points Lifecycle.

Atomic redemption debit

BEGIN
  SELECT available FROM point_balance WHERE account_id=? FOR UPDATE
  IF available < needed: ROLLBACK; raise INSUFFICIENT_BALANCE
  INSERT ledger_entry(REDEMPTION debit, locked)            # lock first
  UPDATE point_balance SET available-=needed, locked+=needed
COMMIT
# then fulfil (saga); on success → commit lock to redeemed; on failure → reverse

M4 — Redemption & Fulfilment

Orchestrates burn as a saga: authorise → lock points → fulfil (voucher API / CBS credit / POS) → commit, with compensation on failure (auto-reverse + notify). Supports partial & points+cash, auto-redeem, charity, EMI waiver and partner transfer. See Architecture §Redemption Saga.

M5 — Merchant-Funded

Onboards merchants, configures funded offers, attributes eligible transactions, computes funded liability, generates settlement. Owns: merchant, merchant_offer, settlement.

M6 — Communication

Template engine (variables, locale, channel rendering) triggered by domain events; dispatches via the Bank gateways (Push/SMS/Email/WhatsApp/In-App) honouring consent & quiet hours; records delivery status. See Architecture §Domain Events.

M7 — Admin & Governance

RBAC (SSO + scopes), maker-checker workflow (segregation of duties), budgets and system parameters. Every change versioned and audited.

M8 — MIS, Reconciliation & Audit

Read-model reporting from the analytics store; nightly reconciliation of ledger vs source & fulfilment with exception workflow; immutable audit query. See Architecture §Reconciliation & Settlement.

M9 — Customer Experience

Customer API + embeddable the Bank-branded UI for points, catalogue, redemption and voucher vault inside the Bank channels.

M10 — Tiers & Status

Scheduled tier evaluation against tier_rule (qualification window, spend/points thresholds), upgrade/downgrade with grace, tier benefits feeding the accrual multiplier. Emits TierChanged → comms.

M11 — Integrity & Risk

Clawback on fraud/chargeback (compensating ledger entries), velocity/abuse controls on earn & referral, negative-balance recovery and a points-dispute workflow.

M12 — Transfer, Pooling & Partners

Family/supplementary pooling (account_pool), member gifting/transfer (points_transfer), partner-programme transfer at configured ratios (partner_program), and referral rewards.

M13 — Engagement: Event Triggers, Scratch Cards & Milestones

Responsibility: ingest external bank events and convert them into engagement rewards. Inputs: POST /api/v1/events (USER_REGISTERED, CARD_ACTIVATED, KYC_COMPLETED, UPI_TRANSACTION, BILL_PAYMENT, SALARY_CREDIT, FD_BOOKED) plus internal CARD_SPEND after each posted card transaction. Outputs: issued scratch cards, direct point grants and milestone progress; ledger credits post through M3 with idempotency keys (scr:{scratchCardId}, evt:{eventRef}:{triggerId}). Owns: bank_event (unique event_ref — replay-safe), trigger_rule (conditions JSONB: first_occurrence, min_amount_minor, max_per_window; weighted prize table), scratch_card (prize drawn hidden at issue; reveal idempotent; expires 30 days, 409 after expiry), milestone_def, milestone_progress (lifetime/weekly/monthly windows).

End-to-End Flows (design summary)

FlowPathKey guarantees
EarnTxn → ingest → eligibility → rule+tier+campaign → ledger credit → notifyExactly-once; auditable; cap-bounded.
Milestone unlockAccrual/txn events → progress update → threshold met → reward grant → notifyOnce-per-customer; budget-guarded.
RedeemRequest → OTP → lock → fulfil → commit / compensateAtomic; auto-reverse on failure.
ExpiryNightly batch → FIFO lots due → expiry entries → near-expiry nudgesGrace-aware; reconciled.
Tier reviewScheduled eval → upgrade/downgrade w/ grace → benefit change → notifyDeterministic; auditable.
SettlementAttribute funded txns → compute liability → settlement reportReconciled; idempotent re-run.
Event → scratch cardBank event → trigger match → scratch card issued (prize drawn hidden) → reveal → ledger credit → notifyReplay-safe on eventRef; reveal idempotent; expiry-guarded.

Key Design Decisions

IDDecisionRationale
ADR-01Immutable ledger + projected balancesAuditability & integrity; balances rebuildable from entries.
ADR-02Event-driven with transactional outboxReliable, decoupled processing; no lost events.
ADR-03Idempotency keys on all value mutationsExactly-once accrual/redemption under retries.
ADR-04Saga + compensation for redemptionSafe distributed burn across ledger & external fulfilment.
ADR-05Config-as-data + maker-checker + versioningNo-deploy changes with governance & rollback.
ADR-06Monthly range-partitioning of ledger/txnScale to 50M+ txn/month; efficient archival.
ADR-07Tokenised identifiers, in-bank deploymentData residency & reduced PCI scope.

Error Handling & Idempotency Strategy

NFR Realisation

NFRDesign mechanism
Performance / throughputStateless services, account-keyed partitions, caching, batch workers.
Integrity (exactly-once)Idempotency keys + outbox + atomic ledger debit.
Availability / DRMulti-AZ active, warm DR, RPO ≤15m / RTO ≤2h (see Architecture §HA/DR).
Security / residencyIn-bank zones, mTLS, RBAC, tokenisation, audit (see CR-SEC-009).
ObservabilityLogs/metrics/traces + SLOs (see Architecture §Observability).

Assumptions & Open Items