CR-APP-007 · APPLICATION STRUCTURE & TECH STACK

Application Structure & Tech Stack

Service decomposition, technology choices, repository & folder structure, frontend/admin apps, environments and CI/CD.

ConfidentialVersion: 1.0Date: 06 Jun 2026

Service Decomposition

Engagement & Loyalty Platform is composed of independently deployable services aligned to the container architecture. Each owns its data and exposes versioned APIs.

ServiceResponsibilityOwns (data)
ingestion-svcReceive/validate/dedupe transactions; publish events.transaction_raw, ingestion_batch, outbox
accrual-svcEligibility + rule evaluation + point calc.accrual_rule, rule_version (read txn)
campaign-svcCampaigns, milestones, segments, enrolment.campaign, milestone, segment, enrolment
ledger-svcImmutable ledger & balance projection.ledger_entry, point_balance, point_lot
redemption-svcBurn, OTP, fulfilment orchestration, vouchers.redemption, voucher, fulfilment_request
catalogue-svcReward catalogue & partner inventory.reward_catalogue, partner
merchant-svcMerchant onboarding, funded offers, settlement.merchant, merchant_offer, settlement
notification-svcTemplates, triggers, channel dispatch, status.notification_template, notification_log, consent
admin-svcRBAC, maker-checker, budgets, config.app_user, role, approval_request, budget, config_param
reporting-svcMIS, reconciliation, audit query.report_run, reconciliation, audit_log (read)
engagement-svcBank-event ingestion (POST /api/v1/events), trigger-rule evaluation, scratch-card issue/reveal, milestone progress.bank_event, trigger_rule, scratch_card, milestone_def, milestone_progress
gatewayEdge routing, authN, rate-limit, request-id.—

Frontend / Client Applications

AppUsersStackNotes
Admin Web PortalBank teamsReact + TypeScript, Vite, TailwindCampaign builder, catalogue, approvals, MIS dashboards.
Customer Rewards UICardholdersEmbedded web / SDK in the Bank app & net-bankingthe Bank-branded; consumes Customer API.
Support ConsoleSupport agentsModule within Admin WebCustomer 360, history, adjustments (maker-checker).
the Bank App (sample) axis-bank-app :4005Demo / cardholdersNode + Express, phone-frame web UIthe Bank's mobile app-style journey: UPI / bills / card activation / FD actions fire bank events; scratch-card reveal & milestone progress; deep-links to the Bank Rewards portal (:4002).

Technology Stack

LayerChoice (recommended)Rationale / alternatives
Service runtimeNode.js (LTS) + TypeScript + NestJS  DecidedTeam expertise → faster delivery & maintainability; one language across services & UI. NestJS gives DI, RBAC guards, idempotency/audit interceptors & OpenAPI generation.
Language & runtime detailTypeScript (strict), Node.js LTSStrict types + generated API types; integer/BigInt money & points (never floats).
Async / batch workersBullMQ / worker_threadsAccrual ingestion, expiry & settlement run as workers/streams — keep the API event loop free.
API styleREST + OpenAPI 3.1Broad compatibility; gRPC optional intra-service.
Primary datastorePostgreSQL (HA)ACID ledger, JSONB for flexible config.
CacheRedisBalances, catalogue, sessions, rate-limit.
MessagingApache Kafka or RabbitMQEvent-driven, at-least-once + idempotency.
Analytics storeColumnar warehouseMIS & reporting at scale.
Search (optional)OpenSearchCatalogue / log search.
FrontendReact + TypeScript + TailwindReusable component system.
ContainerisationDocker + KubernetesOn the Bank private cloud / DC.
IaCTerraform + HelmReproducible environments.
CI/CDGitLab CI / JenkinsPer bank tooling.
ObservabilityPrometheus + Grafana + ELK + OpenTelemetryMetrics, logs, traces.
SecretsVault / KMSKey & secret management.
Backend language decision — Node.js. The platform standardises on Node.js (LTS) + TypeScript + NestJS. The workload is I/O-bound (APIs, PostgreSQL, queues, partner/gateway calls) — Node's strength — and the NFRs (≥1,000 txn/s, ≤1.5s P95) are met by scaling stateless services horizontally with account-keyed partitions and dedicated batch workers. Python or Go are not required. If advanced ML personalisation is added later it can run as a separate Python service behind an API, with no change to the core stack.
Node.js engineering guardrails: (1) represent money in minor units and points as integers/BigInt — never JS floats for financial math; use a decimal library only for ratios/FX. (2) Run accrual ingestion, expiry & settlement as workers/streams (BullMQ / worker_threads) so the API event loop is never blocked. (3) Enable strict TypeScript, generate types from the OpenAPI contract, and enforce the idempotency + transactional-outbox patterns. PostgreSQL remains the ACID system of record.

Repository & Folder Structure

Polyrepo or monorepo per the Bank preference. Reference monorepo layout:

chegrewards/
├─ services/
│  ├─ gateway/
│  ├─ ingestion-svc/
│  ├─ accrual-svc/
│  │  ├─ src/
│  │  │  ├─ api/            # controllers, DTOs
│  │  │  ├─ domain/         # rules, entities, value objects
│  │  │  ├─ application/    # use-cases / services
│  │  │  ├─ infra/          # db, queue, clients
│  │  │  └─ config/
│  │  ├─ test/              # unit + integration
│  │  └─ Dockerfile
│  ├─ campaign-svc/   ledger-svc/   redemption-svc/
│  ├─ catalogue-svc/  merchant-svc/ notification-svc/
│  ├─ admin-svc/      reporting-svc/
├─ apps/
│  ├─ admin-web/            # React admin portal (+ Event Triggers & Scratch Cards pages)
│  ├─ customer-rewards-ui/  # embeddable rewards UI/SDK
│  └─ axis-bank-app/        # the Bank's mobile app sample app (:4005) — events, scratch cards, milestones
├─ libs/
│  ├─ shared-domain/        # common types, money, points
│  ├─ auth/                 # OIDC/OAuth helpers, RBAC
│  ├─ messaging/            # bus client, outbox
│  └─ observability/
├─ db/
│  ├─ migrations/           # versioned schema (Flyway/Liquibase)
│  └─ seeds/
├─ deploy/
│  ├─ helm/                 # charts per service
│  ├─ terraform/            # infra
│  └─ k8s/
├─ contracts/
│  └─ openapi.yaml          # API contract
├─ docs/                    # this documentation suite
└─ .ci/                     # pipelines

Internal Service Layering

Each service follows a clean/hexagonal layering: api (transport) → application (use-cases) → domain (business rules, framework-free) → infra (DB, queue, external clients). This keeps the rule engine and ledger logic testable and independent of frameworks.

Deployment Topology & Right-Sizing

The platform is architected as a modular monolith ("modulith") plus a small set of independently-scalable deployables — not fine-grained microservices on day one. The ~12 modules above are logical boundaries (NestJS modules with clean api→application→domain→infra layering); they are deployed as a few physical services and split further only when a real throughput, SLA or independent-deploy need emerges.

Monorepo is the decision and scales indefinitely here. Repository layout is a code-organisation choice and is orthogonal to runtime scale — throughput is handled by how services/workers are deployed and scaled, not by the repo. The monorepo stays.
DeployableContains (logical modules)Scaling driver
core-apiaccrual ingest endpoint, ledger, campaign, redemption, admin, customer, engagement (bank events, trigger rules, scratch cards, milestones) (synchronous APIs)Request rate (HPA on CPU/RPS)
worker tierbatch statement ingestion, accrual processing, expiry, settlement, notification dispatch (async, queue-driven)Queue depth / batch windows
customer-api optionalcustomer-facing reads & stubbed/real redemptionPublic exposure isolation
gatewayedge routing, authN, rate-limit, signature pre-checksIngress
demo / companion appstransaction simulator (:4001), rewards portal (:4002), comms viewer (:4003), sample feeder (:4004), axis-bank-app (:4005, NEW) — the Bank's mobile app sample appCompanion scope (separate)
bank-side simulatorsaxis-txn-provider (:3101) and axis-comms-gateway (:3102) — renamed from iob-txn-provider / iob-comms-gatewayCompanion scope (separate)
Engagement module (new in core-api). core-api gains an Engagement module exposing POST /api/v1/events (idempotent by eventRef), GET /api/v1/events, GET /api/v1/triggers, GET/POST /api/v1/scratch-cards (+ /:id/scratch) and GET /api/v1/milestones. It evaluates trigger rules against bank events (USER_REGISTERED, CARD_ACTIVATED, KYC_COMPLETED, UPI_TRANSACTION, BILL_PAYMENT, SALARY_CREDIT, FD_BOOKED) and internal CARD_SPEND milestones, issuing scratch cards or direct points through the same immutable ledger. CORS is enabled for http://localhost:4002, :4005 and :5173.

Extraction path: if accrual throughput, an independent release cadence, or a hard latency SLA demands it, accrual-svc (or ledger-svc, notification-svc) is lifted out of core-api into its own deployable — cheap, because the module boundary and the event/outbox contract already exist. The Architecture (CR-ARC-004) container view shows these as logical services; this section governs how they map to running processes.

Scale & Batch Card-Statement Processing

Target load: ~2M transactions/day (~60M/month), bursty around statement batches. This is comfortable for Node.js + PostgreSQL when the batch path is built deliberately and kept separate from the realtime accrual path.

~2M
transactions / day
≥1,000
txn/s sustained (batch)
monthly
ledger / txn partitions
≤1.5s
redemption P95
ConcernDesign
Bulk ingestionStatement files streamed & loaded via COPY / batched multi-row inserts (never row-by-row API calls); chunked into work units.
Async accrualIngested rows enqueued (Kafka/Bull) and processed by a horizontally-scaled worker pool; autoscale on queue lag.
Exactly-onceIdempotency key = external_txn_ref; safe to retry/replay a batch with no double-credit.
Checkpoint / resumeBatches track per-chunk offsets; a failed/long run resumes mid-file rather than restarting.
BackpressureBounded queues & consumer concurrency protect the DB; producers slow when consumers lag.
PartitioningMonthly range partitions on transaction/ledger_entry/audit_log keep inserts & queries fast; old partitions archived.
Scheduling & isolationHeavy statement runs scheduled off-peak in the worker tier; the realtime/near-real-time accrual path (API/stream) is unaffected.
Workload fitBulk accrual is I/O-bound (DB writes) — Node's strength; CPU-light rule evaluation. No need for Go/Python at this scale.
Bottom line: a modular monolith + worker tier in a monorepo comfortably processes a couple of million transactions/day with batch statement runs. Microservice extraction is available as a deliberate, low-cost step when (and only when) the numbers justify it.

Environments

EnvironmentPurposeData
DEVDevelopment & unit/integration tests.Synthetic.
SITSystem integration with bank stubs/sandboxes.Masked / synthetic.
UATBusiness acceptance & pilot.Masked production-like.
PRE-PRODPerformance, DR & security validation.Masked.
PRODLive, inside the Bank environment.Real (tokenised).

CI/CD & Quality Gates

Configuration & Feature Management

Runtime behaviour is config-driven (see CR-CFG-008): accrual rules, campaigns, catalogue, templates and system parameters are data, changeable without redeploy. Feature flags gate progressive rollout of new capabilities.