# Hedged

> Trading guidance for people who have never hedged anything, served to three clients from one API and one socket gateway.

Fintech · Regulated advice · Web, iOS & Android · [hedged.in](https://hedged.in)

Case study from https://abhishekkolge.dev. Canonical page: https://abhishekkolge.dev/work/hedged

- **Role:** Full-stack: the API, the realtime layer, and the web and mobile clients
- **Team:** 4 engineers · 5 months to launch
- **Stack:** Node.js, Socket.io, MySQL, Next.js, React Native, Docker on AWS

## Problem

Almost everything sold to a retail investor in India is long only, so a first-timer learns about risk the hard way, in a month when the market falls. The product’s answer was hedged ideas with the instruction spelled out, down to the capital required and the worst case. That made it an engineering problem with a deadline, because an idea is only worth something while its price holds. The same instruction has to reach the web app, an iPhone and an Android phone within seconds and look identical on all three.

## Approach

One Node API owns the ideas, the positions and who may see what. A socket gateway pushes new ideas, price moves and alerts to whoever is connected, so nothing depends on a client remembering to ask. The clients are deliberately thin. They render the payload, and the numbers on the card come from the server instead of being calculated twice in two languages. The app advises and stops there, so nobody’s money moves inside it.

## By the numbers

- **3 clients**: web, iPhone and Android served by one Node API and one socket gateway
- **5 months**: from first commit to a launch on all three, with four engineers
- **0 orders**: placed inside the app by design, because the broker moves the money
- **100k+**: Play Store installs today, the client’s own work after the build I shipped
- **4.5★**: on Play from 344 ratings, and 4.8★ on the App Store
- **Still shipping**: live and updated under the client’s team, now with macOS and Apple Vision builds alongside the phones

## Architecture

- **Clients:** Next.js on the web, one React Native codebase for iOS and Android
- **API:** Node.js REST, one contract for all three clients
- **Realtime:** Socket.io gateway for published ideas, price moves and alerts
- **Data:** MySQL through Sequelize
- **Access:** Three tiers, free through to one with a minimum capital requirement, deciding which ideas an account can see
- **Infra:** Docker images on AWS, same image in every environment

## Decisions

### Keeping access rules in one backend

Publishing an idea is one write and one push, and everything deciding who sees it lives in that one place. Otherwise each client decides for itself, and a paid idea showing on a free account becomes a problem for the advice business.

### Pushing updates over sockets

During market hours a polling client is either late or expensive. Prices, alerts and new ideas go out over sockets as they happen, and the phones hold the connection while the app is open instead of waking every few seconds to ask what changed.

### The app stops at advice

We drew the line at the instruction. The card tells you the trade, the capital it needs, the most you can make and the most you can lose. Then you place it with your broker. That kept a regulated product clear about what it does, and kept order execution, where things go badly wrong, out of a five-month build by four people.

### Choosing a relational database

Positions, entitlements and published ideas went into MySQL with constraints rather than something flexible. A recommendation is a record you may have to show someone later, so the schema should refuse a half-written one.

### Containerised from day one

The same Docker image runs in dev, staging and production. Four people cannot afford to spend a market morning finding out the server has a different Node version than the laptop that passed the tests.

## Screens

- hedged.in today, still leading with the problem the product was built around: almost everything sold to a retail investor is long only
- A published idea in the app today: the structure, the capital it needs, the most it can make and the most it can lose, with placing the order left to your own broker

## Outcome

We launched on web, iOS and Android inside five months from one API and one socket gateway, with four engineers and no separate mobile team. The client’s own team has carried it since: past 100,000 installs on Play at 4.5 stars, 4.8 on iOS, and it now ships for macOS and Apple Vision too. I shipped the launch, and the growth since then is their work.

## Next

- [Mahindra Lifespaces](https://play.google.com/store/apps/details?id=com.mlife.app)
