IamBishal
FinTechFeatured

FinClimb Investment App Backend

Gold in small amounts. Money moves checked at every step.

The NestJS backend behind the FinClimb investing app: phone sign-in, profiles and bank accounts, buying and selling digital gold, daily to monthly gold SIPs, payments, payouts and notifications.

FinClimb backend: the line 'Gold in small amounts. Money moves checked at every step.' beside two app screens, buying ₹500 of gold and a ₹50 daily gold SIP, with notices for a paid order allocating gold and a SIP debit buying gold automatically
Role
Backend engineer (sole)
Status
Active
Type
Client product · mobile app backend API

Overview

The problem it solves

FinClimb is an investing app for young salaried Indians who want to start small. Its Android app lets people buy digital gold for as little as a few rupees, sell it back to their bank account, or set up a gold SIP that buys automatically every day, week or month. I built the backend API that the app runs on. The mobile app, the website and the mutual-fund side of FinClimb were built by others; this project is the server.

The backend is a NestJS 11 API with 50 REST endpoints in 11 modules. It handles phone-number sign-in with one-time passwords, an MPIN for quick unlock, profiles and bank accounts, and the full gold lifecycle through the gold partner's API: user registration, live buy and sell prices, price history from hourly to yearly, buying, selling, balances, invested versus current value, and invoices.

Money flows are where the design matters most. A gold purchase is a three-way conversation between the app, the gold partner and the payment gateway, and the backend never takes the app's word for a payment. It locks the price with the partner's rate ID, verifies the order, creates a payment order for the exact amount, and confirms the gold only after it reads the order back from the gateway and sees it paid. A gold SIP is a payment-gateway subscription and mandate: each successful debit arrives as a webhook, is recorded as a SIP transaction, and triggers an automatic gold purchase for that amount, with an email to the user. Users can pause, resume or cancel, and every lookup is scoped to the signed-in user. When someone sells, the confirmed sale immediately gets a payout record marked pending; the gateway's payout webhook later marks it processed or failed, using the gold partner's transaction ID as the reference, so no sale goes untracked between the vault and the bank.

Sessions use short-lived JWT access tokens and 30-day refresh tokens that are stored only as SHA-256 hashes and rotated on every use, with the replacement chain recorded. OTP text messages and transactional emails go through BullMQ queues on Redis with three retries and exponential backoff, so a slow SMS or email provider never slows down a sign-in or a payment. Requests pass through Helmet, a CORS allowlist, strict whitelist validation, a timeout interceptor and one response envelope; users are exposed only by UUID public IDs, and payloads to the gold partner are encrypted with AES-256-CBC.

The code is tested at three levels: Jest unit tests with a 90% coverage gate, integration tests and end-to-end tests that run against real PostgreSQL 18 and Redis containers started by Testcontainers. Schema changes are hand-written TypeORM migrations, never auto-synced.

Topics

  • Fintech
  • Payments
  • Digital Gold
  • Backend API
  • Webhooks
  • Background Jobs

Highlights

What makes it different

  • Paid before allocated

    Gold is confirmed only after the backend reads the payment order back from the gateway and sees it paid; the app's word is never enough.

  • Gold SIPs that run themselves

    Daily, weekly or monthly mandates: each debit arrives by webhook and buys gold automatically, with pause, resume and cancel.

  • Every sale tracked to the bank

    A confirmed sale gets a pending payout record at once; the payout webhook marks it processed or failed.

  • Rotating, hashed sessions

    Short-lived access tokens and single-use refresh tokens stored only as SHA-256 hashes, with the replacement chain recorded.

  • Queues with retries

    OTP texts and emails run on BullMQ with three retries and exponential backoff, off the request path.

  • Tested on real infrastructure

    Unit tests with a 90% coverage gate, plus integration and end-to-end tests on real Postgres and Redis containers.

Features

What it can do

  • Phone-number registration and login with one-time passwords sent by SMS from a queue
  • MPIN set and validate for quick unlock, profile management and logout
  • Bank accounts: add, edit, remove and verify with the payment gateway, addressed by UUID
  • Gold account with the vault partner: registration, balance, transactions, invested versus current value
  • Live buy and sell prices with the partner's rate lock, and price history hourly to yearly
  • Gold buying: verify at the locked rate, payment order, server-side payment check, then confirm and invoice
  • Gold selling with order status and a payout record that tracks the money until it reaches the bank
  • Gold SIPs on payment-gateway subscriptions and mandates, with automatic purchase on every successful debit
  • Webhooks for subscription debits and payout results from the payment gateway
  • Event-driven side effects and BullMQ queues for SMS and Handlebars emails, retried with exponential backoff
  • Helmet, CORS allowlist, whitelist validation, timeouts, one response envelope and a global exception filter
  • Swagger documentation, Winston logging, hand-written migrations and Testcontainers-based tests

Screens

A look inside

01API reference: 50 endpoints, one response shape
02Buying gold: price lock, payment, then allocation
03Gold SIP: mandate, webhook, automatic buy
04Selling gold and tracking the payout
05Sign-in: OTP, MPIN and rotating tokens
06Background jobs and tests

Tech stack

Built with

API
  • NestJS 11
  • TypeScript
  • Express
  • Swagger
  • class-validator
Data
  • PostgreSQL
  • TypeORM
  • Hand-written migrations
Async
  • Redis
  • BullMQ
  • Event emitter
  • Handlebars email templates
Security
  • JWT + Passport
  • Rotating hashed refresh tokens
  • Helmet
  • AES-256-CBC partner payloads
Partners
  • SafeGold
  • Cashfree Payments
  • Cashfree Subscriptions
  • Cashfree Payouts
  • SMS gateway
Quality
  • Jest
  • Testcontainers
  • ESLint
  • Prettier
  • Winston logging

Architecture

How it fits together

A modular NestJS API: every feature follows controller, service, repository, entity. Partner calls and payment checks live in the services; slow work such as SMS and email moves to BullMQ queues.

Challenges

Hard problems along the way

  1. Three parties, one purchase

    The app, the gold partner and the payment gateway each hold part of a purchase. The backend ties them together and allocates gold only after it checks the payment itself.

  2. Money with no app in the loop

    SIP debits arrive by webhook at any hour. Each one is recorded and turned into a gold purchase without the user opening the app.

  3. The gap between vault and bank

    A sale is confirmed by the gold partner before the money moves. Payout records close that gap so every sale can be traced to the bank.

  4. Reliable messages

    OTP texts and emails depend on outside providers. Queues with retries keep sign-in and payments fast even when a provider is slow.

Results

The impact

REST endpoints across 11 modules
50
Partner APIs integrated (gold, payments, SMS, email)
7
Unit-test coverage gate
90%
Retries with backoff on every queued job
3×

What's next

On the roadmap

  1. Automated payout release instead of a manual step
  2. Push notifications for price alerts and SIP debits
  3. Statements and tax reports generated in the background
  4. Admin console for support, grievances and announcements

Bishal SahaLet's build together

Have a system to design, or an AI feature to get right?

Tell me about the problem. You'll get a clear, honest view of the best way forward.

  • Reply within 24 hoursOn business days, with my honest view and a next step.
  • Accepting select engagementsArchitecture, AI features and full builds.
  • Remote, worldwideWorking with startups, SMEs and enterprises.