PROJECT / 03Oct 2025 — Present

Centralized Crypto Exchange

A real-time trading interface backed by an order-matching engine.

View source
Trading dashboard with an order book and candlestick chart
Trading dashboard with an order book and candlestick chart

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

System architecture
100%

Scroll to explore the connections, or use Fit to see the full diagram.

Separate order commands, market broadcasts, and historical candlesRedis lists carry commands and database work; pub/sub carries correlated replies and market updates. Matching runs in the TypeScript engine's memory.Next.js trading UIOrders + live depthHistorical candlesExpress REST APIBun / TypeScriptClient-ID repliesRedisCommand listsReply + market pub/subWebSocket serverChannel subscriptionsDepth / trades / tickerMatching engineIn-memory order booksOrders + trade eventsDatabase workerdb_processor listPersist trade eventsPostgres / TimescaleTrades + candle viewsHistorical kline queriesREST ordersLPUSH / replyRPOP commandPublish eventsMarket pub/subLive updatesQueue DB workSQL writesGET klines

Separate order commands, market broadcasts, and historical candles

  1. REST order requests enter a Redis list with a correlation ID. The in-memory engine consumes commands and publishes replies.
  2. WebSocket subscriptions forward engine market events to the trading screen. This is separate from the request/reply order path.
  3. A Redis-backed database worker persists trade events to TimescaleDB. The API reads historical candle data from PostgreSQL.

Centralized Crypto Exchange · System architecture

Component responsibilities
  1. 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.

  2. Market updates

    A WebSocket service subscribes to Redis market channels and forwards depth, trade, and ticker updates to the Next.js client.

  3. 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

  1. Order matching

    A matching engine processes buy and sell orders, with Redis supporting the order-queue workflow.

  2. Live market updates

    WebSocket updates keep the order book and trading interface connected to changing market data.

  3. Historical price charts

    OHLCV candlestick charts present market history using time-series data stored in TimescaleDB.

More projects

View all
GitHub
LinkedIn
X