Centralized Crypto Exchange
A real-time trading interface backed by an order-matching engine.
Overview
The exchange connects order matching, live order books, and market charts in a single trading application. A TypeScript and Bun backend works with Redis queues, WebSockets carry live updates to the interface, and TimescaleDB stores the time-series data used for OHLCV charts.
Architecture
Scroll to explore the connections, or use Fit to see the full diagram.
Separate order commands, market broadcasts, and historical candles
- REST order requests enter a Redis list with a correlation ID. The in-memory engine consumes commands and publishes replies.
- WebSocket subscriptions forward engine market events to the trading screen. This is separate from the request/reply order path.
- A Redis-backed database worker persists trade events to TimescaleDB. The API reads historical candle data from PostgreSQL.
Component responsibilities
Order command path
Express API requests enter a Redis list with a client correlation ID. The Bun/TypeScript in-memory engine consumes commands and publishes replies.
Market updates
A WebSocket service subscribes to Redis market channels and forwards depth, trade, and ticker updates to the Next.js client.
Historical data
A separate database worker consumes queued trade events and persists them to PostgreSQL/TimescaleDB. Kline API queries read historical candle data.
Why I built this
I wanted to understand how a trading application connects order processing, real-time updates, and historical market data. Building the exchange let me work on the backend flow and the interface together.
Use case
A user can inspect a market's order book and price history, submit an order, and see the interface react to live updates within the exchange application.
What I learned
- Separating order processing, live event delivery, and historical market-data storage.
- Connecting WebSocket updates to a trading interface without treating every update as a full page request.
- Working with time-series data and OHLCV aggregation for market charts.
Key features
Order matching
A matching engine processes buy and sell orders, with Redis supporting the order-queue workflow.
Live market updates
WebSocket updates keep the order book and trading interface connected to changing market data.
Historical price charts
OHLCV candlestick charts present market history using time-series data stored in TimescaleDB.


