CryptEx is a centralized crypto exchange backend: a custom spot and perpetual-futures matching engine, plus the REST API and supporting services around it — persistence, WebSocket fan-out, an external mark-price feed and a reverse proxy — built as a Bun/Turborepo TypeScript monorepo. Nothing talks to the trading engine over HTTP: every order, balance change and admin action is a message on a Redis Stream, and every effect the engine produces is a message on a response stream that downstream services each consume independently.
core-backend (REST API) and ws-index-poller (Binance mark-price feed) publish onto the engine.request Redis Stream; core-trading-engine consumes it, performs matching/balances/positions/funding, and publishes results onto engine.response, which database-engine (Postgres persistence) and ws-server (WebSocket broadcast) each consume as their own independent consumer group.
core-backendREST API — auth, admin, orders, balances, market data (port 8080)core-trading-engineMatching engine — order book, balances, positions, funding, liquidation (port 8081)database-enginePersists every engine update to Postgres (port 8082)ws-serverWebSocket fan-out of engine updates to browser clients (port 8083)ws-index-pollerBinance mark-price feed + hourly funding-rate scheduler (port 8084)proxy-serverReverse proxy to Backpack Exchange's public REST API (port 8085)core-frontendPublic-facing web app (Next.js, port 3000)git clone https://github.com/SajalDBansal/centralized-exchange.git cd centralized-exchange bun install
docker compose -f infra/docker-compose.dev.yml up -d
cd packages/database bunx prisma migrate deploy
bun run dev