Skip to content

Real-time trading exchange platform built with a modular architecture.

Notifications You must be signed in to change notification settings

VarunThisSide/BoltEx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ BoltEx: High-Performance Order Matching Engine

BoltEx is a full-stack, real-time trading exchange platform built with a modular architecture. It features a high-throughput matching engine, a real-time WebSocket server for market updates, and a persistent database processor to ensure data integrity across the system.


🏗️ Architecture Overview

The project is designed as a distributed system, separated into four core microservices:

  • Engine: The core logic written in TypeScript that manages the order book, processes limit/market orders, and executes matches.
  • API Server: An Express-based gateway that handles user authentication, RESTful interactions, and order placement.
  • WS Server: A high-concurrency WebSocket server that manages real-time subscriptions and broadcasts market data (tickers, depth, and trades).
  • DB Processor: A dedicated background worker that pulls execution data from Redis queues and persists it to a PostgreSQL database via Prisma.

🛠️ Tech Stack

  • Languages: TypeScript (Primary), JavaScript
  • Backend: Node.js, Express.js
  • Real-time: WebSockets (ws), Redis (Pub/Sub & Queues)
  • Database: PostgreSQL, Redis
  • DevOps: Docker, Docker Compose

🚀 Local Setup & Deployment

Prerequisites


1. Clone the Repository

git clone https://github.com/VarunThisSide/boltex.git
cd boltex

2. Configure Environment Variables

Create a .env file in the root directory:

# Database (e.g., Neon, Supabase, or Local)
DATABASE_URL="postgresql://user:password@localhost:5432/boltex"

# Redis Configuration
REDIS_HOST="localhost"
REDIS_PORT=6379
REDIS_PASSWORD=""

# Ports
API_PORT=3000
WS_PORT=3001

3. Run with Docker Compose

The most efficient way to run the entire stack (including the database and Redis) is via Docker Compose:

docker-compose up --build

This command builds the images for the Engine, API, WS Server, and DB Processor, while pulling the official images for PostgreSQL and Redis.


Manual Component Execution

If you prefer to run services individually for debugging purposes:

1. Start Infrastructure

docker run -p 6379:6379 -d redis
docker run --name boltex-db -e POSTGRES_PASSWORD=password -p 5432:5432 -d postgres

2. Run the Engine

cd engine
npm install
npm run dev

3. Run the API / WS Server

cd api  # or cd ws
npm install
npm run dev

📡 API & WebSocket Usage

REST API

  • POST /api/v1/order — Place a Limit or Market order
  • GET /api/v1/depth — Retrieve the current order book depth for a specific pair

WebSockets

Connect to receive live market updates:

ws://localhost:3001

About

Real-time trading exchange platform built with a modular architecture.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages