CR-ARC-004 · SOLUTION ARCHITECTURE & DIAGRAMS

Solution Architecture & Diagrams

System context, container & component architecture, event-trigger flow, deployment topology and key data flows for the Engagement & Loyalty Platform, deployed inside the the Bank-controlled environment.

ConfidentialVersion: 1.1Style: C4 + flowsDate: 19 Jul 2026

Architecture Principles

#PrincipleImplication
1Bank-controlled dataAll PII & transactions remain inside the Bank; only catalogue/fulfilment calls leave via controlled APIs.
1bEvent-triggered engagementBank events drive rewards in real time; trigger rules & prize tables are configuration, not code.
2Configuration over codeRules, campaigns, catalogue & templates are data; changes need no redeploy.
3Event-driven & idempotentTransactions processed via queues with idempotency keys → exactly-once accrual.
4Modular servicesIndependent, independently scalable services per domain.
5Ledger as source of truthImmutable, auditable double-entry-style loyalty ledger.
6Secure by designZero-trust, RBAC, encryption, masking, full audit (see CR-SEC-009).
7ObservableCentral logs, metrics, traces, health & alerts.

System Context (C4 — Level 1)

the Bank-controlled environment Bank Event Sourcesreg·activation·UPI·FD CBS / Card Systemtxn, customer, card Transaction Switchposted txns the Bank IdP (SSO)admin auth the Bank's mobile app / Channelsapp · net-banking :4005 Engagement & Loyalty Platform event triggers · scratch cards milestones · accrual · ledger redemption · admin · MIS Reward Cataloguepartner inventory Voucher Fulfilmentissuance APIs Notification GatewaysSMS·email·push·WA
Figure 1 — System context. The Engagement Suite sits inside the the Bank boundary; bank event sources POST events to it, and only catalogue, fulfilment and notification calls cross the boundary over controlled APIs.
Engagement Suite corethe Bank systemExternal partner

Container Architecture (C4 — Level 2)

Engagement & Loyalty Platform — services & data stores (inside the Bank) API Gateway Event Ingestion/events · triggers Event Bus / Queue Trigger Engine+ Accrual Campaign Service Ledger Service Redemption Service Scratch Card Svc+ Milestone Engine Notification Service Admin / RBAC Reporting / MIS Recon & Audit Admin Web Customer API Ledger DB Config DB Catalogue DB Analytics Store Cache (Redis) Fulfilment APIs Notification GW
Figure 2 — Container view. Stateless services scale independently behind the gateway; the Ledger DB is the system of record. Only Fulfilment & Notification egress the boundary.

Event-Trigger Flow (Scratch Card Issue & Reveal)

The heart of the Engagement Suite: external bank systems POST lifecycle events to POST /api/v1/events; the trigger engine resolves the account, evaluates active trigger rules (and advances milestones), and on a match issues a scratch card with its prize drawn at issue time and stored hidden. The customer reveals it in the the Bank's mobile app app via POST /api/v1/scratch-cards/:id/scratch, which posts an idempotent points credit to the ledger (for POINTS prizes). Every step is idempotent — event by eventRef, ledger writes by key evt:{eventRef}:{triggerId} / scr:{scratchCardId}.

Bank Systemsemit events POST /eventsidempotent (eventRef) Trigger Evaluationrules · milestones Scratch Card Issueprize drawn, hidden App: revealscratch-to-reveal Ledgeridempotent ACCRUAL POST /scratchreveal prize ~50% scratched POINTS credit
Figure 2b — Event-trigger flow: bank systems → POST /api/v1/events → trigger evaluation → scratch card issue (prize hidden) → app reveal → ledger credit. Spend accrual (Figure 3) continues in parallel and feeds spend milestones via the internal CARD_SPEND source.
Engagement Suite coreApp / bank system

Component Inventory (Apps & Services)

Runtime components and their ports. core-api mounts the new event/trigger/scratch-card/milestone modules and enables CORS for the app, portal and admin origins.

ComponentPortRole
core-api3001NestJS core; accrual, ledger + events / triggers / scratch-cards / milestones; CORS for :4002, :4005, :5173.
config-service3004Config, capabilities, approvals, audit.
mis-reporting3005MIS & reporting.
merchant-service3006Merchant onboarding & funded offers.
campaign-engine3103Campaign evaluation.
loyalty-scheduler3104Batch jobs; also expires overdue scratch cards in the daily run.
axis-txn-provider3101Transaction provider (renamed from iob-txn-provider).
axis-comms-gateway3102Comms gateway (renamed from iob-comms-gateway).
transaction-simulator4001Transaction simulator.
rewards-portal4002Rewards portal; ?card= deep link + Scratch Cards & Milestones sections.
comms-viewer4003Comms viewer.
sample-feeder4004Sample event/data feeder.
axis-bank-app4005NEW — the Bank's mobile app sample app: triggers events & renders the scratch-card journey.
admin-dashboard5173Vite admin; Triggers & Scratch Cards pages.

Accrual Component & Sequence

Txn Source Ingestion Eligibilityvalidate Rule Enginecalculate Ledger Notify+ campaign deduperulespointspost On reversal: Ingestion → Ledger reversal entry (idempotent, references original).
Figure 3 — Accrual pipeline: ingest → validate → calculate → post → notify; idempotency keys guarantee exactly-once crediting.

Points Lifecycle & State Machine

Every accrued point lot moves through an explicit, auditable lifecycle. Each transition is a ledger_entry on the immutable ledger; the point_balance buckets (pending, available, locked, lifetime) are projections of the current state across a customer's lots.

Pendingtxn posted Availableaccrued Lockedredeem hold Redeemeddebited Reversedrefund/clawback ExpiredFIFO validity Fulfilledterminal eligible redeem debit release on fail expiry sweep
Figure 4 — Points lifecycle. Solid = happy path; dashed = compensating / time-driven transitions. Locked points release back to Available on fulfilment failure; Available points clawback to Reversed on transaction reversal; un-redeemed lots Expire on FIFO validity.
StateBalance bucketEntered byExits to
PendingpendingTransaction ingested, awaiting eligibility/settlement window.Available · Reversed
AvailableavailableAccrual posted (ACCRUAL credit).Locked · Reversed · Expired
LockedlockedRedemption request reserves points (hold).Redeemed · Available (release)
Redeemed—Atomic debit committed (REDEMPTION debit).Fulfilled · Available (compensation)
Reversed—REVERSAL entry referencing original (clawback/refund).terminal
Expired—EXPIRY sweep at lot validity end (FIFO).terminal

Domain Events & Outbox

Services communicate state changes as immutable domain events published via the transactional outbox: each state change writes its business row and an outbox_event row in the same DB transaction; a relay drains the outbox to the bus (Kafka/RabbitMQ) at-least-once. Consumers are idempotent on event_id, giving effectively-once processing without distributed transactions.

Servicedomain txn outbox_eventsame DB commit Relay / CDCpoll · publish Event Bus … atomic consumers (idempotent)
Figure 5 — Transactional outbox: business row and event committed together, then relayed to the bus; consumers dedupe on event id.
EventProducerKey consumersEffect
TransactionIngestedingestion-svcaccrual-svcTriggers eligibility & rule evaluation.
PointsAccruedledger-svccampaign-svc, notification-svc, reporting-svcUpdates balance projection, milestone progress, statements.
AccrualReversedledger-svccampaign-svc, notification-svc, reconClawback; recomputes affected milestone progress.
MilestoneUnlockedcampaign-svcledger-svc, notification-svcPosts bonus accrual; sends reward notification.
RedemptionRequestedredemption-svcledger-svcLocks points (reservation/hold).
PointsLockedledger-svcredemption-svcConfirms hold; saga proceeds to fulfilment.
RedemptionFulfilledredemption-svcledger-svc, notification-svc, reporting-svcCommits debit; issues voucher; confirms to customer.
RedemptionFailedredemption-svcledger-svc, notification-svc, reconTriggers compensation (release lock); logs exception.
PointsExpiredledger-svcnotification-svc, reporting-svcPosts EXPIRY entries; reduces available balance.
SettlementGeneratedmerchant-svcreporting-svc, financeMerchant-funded liability billed for period.

Redemption Saga & Compensation

Redemption spans the Ledger and an external fulfilment partner, so it is orchestrated as a saga by redemption-svc: a reversible lock → debit → fulfil sequence with an explicit compensation path. The lock keeps the customer's available balance correct while the (slower, externally-dependent) fulfilment completes, and guarantees no points are lost or double-spent if a step fails (FR-M4-05, NFR-04).

Customer API Redemption (saga) Ledger Fulfilment partner Notification 1 OTP 2 lock 3 fulfil (idempotent) 4 voucher / status 5 commit debit 6 confirm C. on fail/timeout → release lock (compensate), notify, log recon exception
Figure 6 — Redemption saga. Steps 1–6 are the happy path; path C is the compensating transaction that releases the lock and reverses any partial effect. The fulfil call carries the redemption idempotency key so partner retries never double-issue.
  1. Authorise — Customer selects a reward in the the Bank channel; step-up OTP (FR-M4-04) verified; eligibility & available balance checked against Ledger & Catalogue.
  2. Lock — Redemption-svc reserves points (Available → Locked); RedemptionRequested/PointsLocked events emitted.
  3. Fulfil — Partner voucher API or CBS credit instruction (statement credit / cashback) invoked with the redemption idempotency key, timeout & circuit breaker.
  4. Commit — On success the locked points are debited (Locked → Redeemed), voucher stored in the vault, history updated, RedemptionFulfilled emitted.
  5. Compensate — On failure/timeout the saga releases the lock (Locked → Available), emits RedemptionFailed, notifies the customer and logs a reconciliation exception. Slow-but-not-failed fulfilment is parked and retried (graceful degradation) rather than auto-reversed.

Deployment Topology

the Bank Data Centre / Private Cloud (VPC) — segmented zones DMZ / Edge zone WAF + Load Balancer API Gateway Reverse Proxy Application zone (K8s / containers) Service pods Workers Event Bus / Message Queue Admin Web Schedulers Data zone (restricted) Ledger DB (HA, encrypted) Config / Catalogue DB Analytics / Warehouse Backup / DR replica
Figure 7 — Three-zone deployment (DMZ, Application, Data) within the the Bank VPC. East-west traffic restricted by network policies; egress only to approved partner endpoints.

Integration Patterns

PatternUsed forNotes
Batch file (SFTP)Daily txn / master loadsChecksums, control totals, idempotent re-load.
Streaming / queueNear-real-time txns & eventsAt-least-once delivery + idempotency keys.
Synchronous RESTCustomer redemption, adminOAuth2/mTLS, timeouts, circuit breakers.
Webhooks/callbacksFulfilment statusSigned payloads, retry with backoff.
Outbox patternReliable event publicationTransactional outbox → bus → consumers.

Secured Integration & Signature Verification

Value-bearing calls that cross a trust boundary — redemption requests from the Bank channels, fulfilment callbacks from partners, and CBS credit instructions — are authenticated and integrity-protected at the application layer on top of mTLS. Each request carries a digital signature (HMAC-SHA256, or RSA-PSS/ES256 by key id), a nonce and a timestamp; the gateway and target service verify signature + nonce + timestamp window before any side effect, then apply the idempotency key. Responses on the redemption path and inbound webhooks are likewise signed. Scheme, headers and worked examples are in CR-API-006; key management & rotation in CR-SEC-009.

the Bank trust boundary (mTLS between zones) the Bank Channelsigns request Gateway + Serviceverify 1 KeyId → key 2 timestamp ±300s 3 nonce (anti-replay) 4 signature compare 5 idempotency key Processledger / saga Vault / KMSkeys · rotation Fulfilment partnerallow-listed CBS credit / Notifysigned instr. signed ok signed response (reject: SIGNATURE_INVALID / _EXPIRED / NONCE_REPLAYED) verify key mTLS+sig signed webhook Partner boundary
Figure 10 — Secured integration. A signed request is verified (KeyId → key, timestamp window, nonce anti-replay, signature compare, idempotency) before processing; the response and any partner webhook are signed, and egress to partners is mTLS + signed to allow-listed endpoints. Keys are resolved from Vault/KMS.
Engagement Suite corethe Bank system / VaultExternal partner

Caching & Data Consistency

The Ledger is the single source of truth; point_balance is a read model (CQRS-style projection) maintained from ledger entries, and Redis caches hot reads. To keep these consistent the platform applies write-through invalidation keyed to ledger commits.

Read model / cacheBuilt fromConsistency & invalidation
point_balance (projection)PointsAccrued/Reversed/Expired, redemption commitsUpdated in the same transaction as the ledger entry (or via outbox consumer); reconciled nightly against the ledger entry-sum — divergence raises an alert.
Balance cache (Redis)point_balance projectionInvalidated on every ledger commit for the account; short TTL backstop; cache-aside read with single-flight to avoid stampede.
Catalogue cache (Redis)reward_catalogue, stockTTL + explicit bust on catalogue/stock change events; stock decrements are authoritative in DB, not cache.
Rules / config cacheaccrual_rule, config_paramVersioned; busted on activation (maker-checker) so rule changes take effect without redeploy.
Read-your-writes: redemption eligibility and atomic debit read the authoritative ledger/balance row (not the cache) under row-level locking, so a stale cache can never permit a negative balance (FR-M3-05).

Reconciliation & Settlement

Two scheduled control flows close the loop between the Engagement Suite, source systems and partners (FR-M8-02, FR-M5-02). Both write to the reconciliation / recon_exception and settlement tables and feed the exception workflow.

Daily reconciliation Source / fulfilment Recon enginematch · compare Ledger totals Exceptionsworkflow · ageing MIS / alerts variance → exception Periodic merchant settlement Eligible funded txnsmerchant_txn_map Settlement runcompute liability settlement_lineper merchant/period Statement / billingto finance
Figure 8 — Reconciliation matches source/fulfilment counts against ledger totals and ages exceptions; settlement aggregates merchant-funded eligible transactions into per-merchant billing.

Resilience & Scaling

Scalability & Capacity

Capacity targets are derived from the NFRs (NFR-01..03): 10M+ cards, 50M+ monthly transactions, accrual ≤ 2s (API) / ≥ 1,000 txn/s (batch), redemption P95 ≤ 1.5s.

10M+
cards / accounts
50M+
txns / month (~1.9k/s peak)
1,000+
batch accrual txn/s
≤1.5s
redemption P95
DimensionStrategy
Service scalingStateless pods scale horizontally; HPA on CPU and on Kafka consumer lag / queue depth; batch workers scale up during ingestion windows and down after.
ThroughputPartitioned Kafka topics keyed by account_id preserve per-account ordering while parallelising across consumers; accrual is embarrassingly parallel per account.
Data growthledger_entry & transaction range-partitioned by month (see CR-DAT-005); cold partitions archived to the warehouse; read replicas for reporting/balance reads.
Sharding pathAccount-id is the natural shard key should a single Postgres cluster be outgrown; the projection model isolates write hotspots from read traffic.
BackpressureAt-least-once + idempotency lets the system shed load to the queue under spikes; redemption degrades gracefully (park & retry) if fulfilment is slow.
Autoscaling triggersQueue lag > threshold, CPU > 70%, P95 latency SLO burn; scale-in guarded by cool-down to avoid flapping during batch.

Observability & SLOs

Per NFR-09, the platform emits the three pillars plus health and alerting (Prometheus/Grafana, ELK, OpenTelemetry — see CR-APP-007). Every request and event carries X-Request-Id/trace context for end-to-end correlation across services and the bus.

SignalWhat is captured
LogsStructured JSON with correlation id, actor, masked identifiers; financial & config events also written to the immutable audit_log.
MetricsRED/USE per service; domain KPIs: accrual lag, accrual error rate, redemption success %, fulfilment latency, queue depth, points-liability.
TracesDistributed traces across gateway → service → DB → bus → consumer; saga spans for redemption.
HealthLiveness/readiness probes; synthetic checks for redemption & balance read paths.
AlertsSLO burn-rate alerts, recon variance, budget threshold breach, DLQ growth, partner circuit-breaker open, signature-failure / nonce-replay spikes.
Audit trail vs. operational logs. Security, financial and config events additionally write to a separate tamper-evident, append-only audit_log (hash-chained / WORM) that is forwarded to the the Bank SIEM; access to logs and audit records is itself logged. Full retention, what-is-logged and SIEM detail in CR-SEC-009.
SLOTargetTied to
Redemption availability99.9%NFR-03
Redemption latency (P95)≤ 1.5sNFR-01
Accrual freshness (near-real-time)≤ 2s API / streaming lag < 60sNFR-01
Ledger ↔ balance integrity0 unreconciled at nightly closeNFR-04/06

High Availability & Disaster Recovery

The platform runs active across availability zones within the primary the Bank site with an active-passive secondary site for DR, meeting RPO ≤ 15 min and RTO ≤ 2 h (NFR-10).

Primary site (active) — multi-AZ Services AZ-a/b/c Ledger DB (primary) Sync replicaAZ failover Bus (replicated) DR site (passive) — warm standby Services (scaled-down) Ledger DB (standby)async replicate Backups / WALPITR async (RPO ≤ 15m)
Figure 9 — Multi-AZ active primary with synchronous in-site replica for HA and an async-replicated warm DR site for regional failover.
AspectApproachTarget
In-site HAMulti-AZ stateless pods; synchronous DB replica; replicated bus; auto-failover.99.9% (NFR-03)
DR failoverWarm standby site, async replication, DNS/GSLB cutover, runbook + periodic drill (PRE-PROD).RTO ≤ 2 h
Data lossAsync replication + WAL/PITR backups.RPO ≤ 15 min (NFR-10)
DegradationRead-only balance/catalogue browsing remains available if write path is impaired; redemptions queued.graceful

Technology Mapping

Concrete stack choices are detailed in CR-APP-007 (Application Structure & Tech Stack); data design in CR-DAT-005; security zoning in CR-SEC-009.