RcoinX — Real-time Spot Trading
A pre-launch cryptocurrency exchange needed a frontend platform that could render live market data for thousands of concurrent users without dropping frames — starting from an empty repository.
01 — Problem
An exchange frontend, from an empty repo
RcoinX was pre-launch: no design system, no repository structure, no data layer — but a hard requirement that Spot Trading feel instant. An order book updates many times per second; a naive render pipeline melts at that rate, and a naive architecture melts the team once three engineers work in the same codebase.
The real problem was two problems: make real-time market data cheap to render, and make the codebase safe to grow. I owned both.
02 — Constraints
What made it hard
Everything had to be built while the backend was still moving — API contracts changed weekly. The UI had to support RTL and LTR from day one for a bilingual market. And with a 3-engineer team, any architecture that required constant coordination would have been slower than no architecture at all.
- Market data arrives on 3 concurrent WebSocket streams, at up to tens of messages per second per symbol.
- React re-renders are the enemy: an order book that re-renders on every tick is unusable.
- Multiple screens need the same live data — subscriptions must be shared, not duplicated.
- Backend contracts unstable → the frontend needed its own typed boundary and mock layer to keep shipping.
03 — Architecture
A ref-counted WebSocket layer
The core decision: no component talks to a socket. A centralized WebSocket layer owns connections and exposes subscribe(topic) — the first subscriber to a topic opens the upstream subscription, the ref-count tracks consumers, and the last unsubscribe tears it down. Components mount and unmount freely; the socket layer decides what actually flows over the wire.
Incoming ticks never touch React state directly. They patch a normalized cache, throttled to a 200–300ms cadence — fast enough to feel live, slow enough that the order book renders at a fixed, predictable rate. Auto-reconnect with resubscription replays the ref-count table after a drop, so a network blip never leaves a stale screen.
04 — Platform
A monorepo the team couldn't break
I structured the codebase as a Turborepo monorepo with 8 shared packages (ui, providers, http, i18n, types, cross-feature APIs) and strict Feature-Sliced Design import boundaries enforced by ESLint. A feature can't reach into another feature's internals; a page can't import a raw API client. The linter, not code review, holds the architecture.
Account & Security shipped on the same foundation: TOTP, WebAuthn, MFA-gated flows — with RTL/LTR Storybook components and Vitest + MSW contract tests running in Docker CI, so backend churn broke tests, not production.
05 — Outcome
What shipped
Spot Trading shipped end-to-end (~9.5K LOC): order book, candlestick charts, order management, 9 REST integrations, 3 WebSocket streams. Three engineers shipped in parallel without stepping on each other, and the WebSocket layer hasn't needed structural changes since it landed.
Stack
Next case
Chatomatic — AI Assistant SaaS→