Pulse Terminal is a full-stack, real-time cryptocurrency trading interface and market data platform. The system streams L2 order book data from Binance WebSockets, processes and aggregates order book parameters, synchronizes state via Redis, and renders a high-performance terminal UI.
+-------------------+
| Binance WebSocket |
+---------+---------+
| (wss://stream.binance.us)
v
+---------+---------+
| binance_ws.py |
+----+---------+----+
| | (Every 60s)
(Redis Pub) | v
| +------+------+
| | PostgreSQL |
v +------+------+
+----+----+ |
| Redis | | (GET /api/ohlcv)
| Pub/Sub | |
+----+----+ |
| |
(Redis Sub) | |
v v
+----+---------+----+
| FastAPI WS | (main.py)
+---------+---------+
| (WebSocket)
v
+---------+---------+
| React Client | (Pulse UI)
+-------------------+
- Real-Time Order Book Engine: Connects to the Binance L2 depth stream and pushes real-time bid and ask arrays to the client with sub-100ms latency.
- Microstructure Metrics: Computes key market-microstructure metrics on every packet:
- Mid Price: Average of best bid and best ask.
- Spread: Difference between best ask and best bid.
- CVD (Cumulative Volume Delta): Volume differences (bid volume minus ask volume) across the top 20 price levels to track net buying and selling pressure.
- Redis Integration: Uses a Redis pub/sub broker to fan out updates to multiple clients.
- Memory Optimization: Employs capped local order book state tracking, pruning zero-quantity levels and restricting stored records to the top 20 entries.
- Pulse UI: A dark-themed trading desk dashboard with proportional depth bars and instant visual updates.
| Component | Technology |
|---|---|
| Backend | Python 3.11, FastAPI, Uvicorn |
| Streaming | Binance WebSocket, websockets library |
| Pub/Sub Broker | Redis 7 |
| Database | PostgreSQL 15, asyncpg |
| Frontend | React, Bootstrap |
| Infrastructure | Docker, Docker Compose |
To run the backend services (FastAPI, Redis, PostgreSQL) locally:
docker compose up --buildStart the React client separately from the project root:
npm install --legacy-peer-deps
npm startTo keep resource utilization under 512 MB:
- Database: Use a managed serverless PostgreSQL database (e.g., Supabase). Use the Supavisor connection pooler URI as the
DATABASE_URL. - Redis: Use a managed Redis instance (e.g., Render Key Value). Set the internal URL as
REDIS_URL. - Backend: Host on Render as a Web Service. Set environment variables:
DATABASE_URLREDIS_URL
- Frontend: Host on Vercel as a static site. Set environment variables:
REACT_APP_API_BASE(Backend URL)REACT_APP_WS_URL(Backend WebSocket URL)