Skip to content
← Work index

07Case study

Trend Fiver

Real-time financial prediction engine

Year
2024
Role
Backend architecture, data layer
Status
Live

Users call the direction of a market inside a fixed time slot. That sounds like a simple CRUD app until you notice that scoring requires a price read at a precise instant, thousands of times, while a leaderboard recomputes underneath it.

3
Asset classes - crypto, equities, forex
Redis
Hot path for price reads
Slot
Deterministic settlement window

The constraint

What made it hard

Hitting a market data provider once per prediction settlement is both slow and expensive, and two users settling in the same slot must see the same price or the game is not fair. Fairness here is a caching problem wearing a product costume.

Approach

  1. 01

    Slots as the unit of truth

    Predictions are bucketed into fixed windows. Settlement reads one canonical price per asset per slot, so every participant in a window is scored against an identical number by construction.

  2. 02

    Redis in front of the feed

    High-frequency price reads are served from Redis rather than the upstream provider, collapsing thousands of settlement reads into a single fetch per slot.

  3. 03

    Typed schema with Drizzle

    Drizzle keeps the PostgreSQL schema and the TypeScript types in one place, which matters when the scoring logic and the API contract must never disagree about a number.

  4. 04

    Precomputed leaderboards

    Rankings are computed on settlement and cached, not derived per request - the read path stays flat as participation grows.

Architecture

Trend Fiver slot-based settlementslot 1slot 2slot 3slot 4fixed settlement windows - the unit of fairnessMarket feedscrypto · equity · fxRediscanonical slot priceSettlementdeterministicPostgresdrizzleevery prediction in thewindow scored againstone identical priceLeaderboardprecomputedreads stay flatas participation grows
One upstream fetch per asset per slot fans out to every settlement in that window.

Specification

Feeds
Live crypto, equity and forex price data
Cache
Redis - canonical slot prices, leaderboards
ORM
Drizzle, schema-first TypeScript types
Settlement
Deterministic per-slot, single price read
Client
React + TypeScript, live position updates

Stack

  • Node.js
  • React
  • TypeScript
  • PostgreSQL
  • Redis
  • Drizzle ORM

Where it landed

  • 01

    Settlement fairness guaranteed structurally rather than by convention.

  • 02

    Upstream data provider calls reduced to one per asset per slot.

  • 03

    Leaderboard reads decoupled from participant count.

Next case study

08

WiScribble

Digital signing and online notarisation

Read →

Something that has towork in production?

I take on contract engineering and full-time roles. Most useful first message: what you are building, what is currently in the way, and when you need it live.