it is a real-time crypto trading engine built using Redis, WebSockets, and a microservices-based API style, its is well monitored logged and oberved using Loki, Promethues, Grafana
real-time crypto trading engine built using Redis, WebSockets, and a microservices-based API system
Demo Link: https://drive.google.com/file/d/1GHW_pp2NaNt9nJgo-UVYER41yEj39kXJ/view?usp=sharing
-
Browser → API (
/api/v1/order):-
A client sends a buy/sell order.
-
Example:
{ "kind": "buy", "type": "limit", "price": 12000, "quantity": 20, "market": "sol/usdc" }
-
-
API → Redis Queue:
- The API pushes the order into a Redis Queue using a key like
MESSAGES.
- The API pushes the order into a Redis Queue using a key like
-
Engine (Matching Engine):
-
Subscribes to Redis Queue.
-
Pops the order using the
MESSAGESkey. -
Processes the order and publishes the result (fills, executed quantity) using Redis Pub/Sub to the respective
clientId.
-
-
API → Redis Pub/Sub:
-
API subscribes to Redis Pub/Sub using
clientId. -
Receives real-time updates for order execution (
ORDER_PLACED,fills, etc.) and returns this data to the browser.
-
-
WebSocket:
-
The browser maintains a WebSocket connection for real-time updates.
-
The WebSocket service streams back order status, ticker, trade fills, etc.
-
-
Market Streams on Init:
-
On startup, the engine listens to Redis streams like:
-
Trades@SOL/USD -
DEPTH@SOL/USD -
Ticker@SOL/USD
-
-
-
Redis Pub/Sub:
- Used to distribute updates across API and WebSocket components.
-
Redis Queue:
- Handles order queuing for the engine to consume and process.
-
Engine → DB Processor:
- Pushes raw trade data (
Price,Volume,Timestamp) into Redis Lists.
- Pushes raw trade data (
-
DB Processor → Timeseries DB:
-
Aggregates raw trades into candlestick data (OHLC - Open, High, Low, Close).
-
Stores structured historical data for charting and analytics.
-
-
Subscribed clients are notified through Redis channels using their
clientId. -
All Redis messages are structured and pushed through:
-
Redis Queue→ for backend processing. -
Redis Pub/Sub→ for client notifications.
-

