Skip to content

Latest commit

 

History

History
64 lines (49 loc) · 1.6 KB

File metadata and controls

64 lines (49 loc) · 1.6 KB

CEX

A minimal centralized exchange backend in Rust.

Architecture

┌─────────┐     ┌───────────┐     ┌────────┐
│   API   │────▶│   Redis   │◀────│ Engine │
└─────────┘     └───────────┘     └────────┘
                     │
        ┌────────────┼────────────┐
        ▼            ▼            ▼
   ┌─────────┐  ┌─────────┐  ┌──────────┐
   │   WS    │  │DB Filler│  │ Postgres │
   └─────────┘  └─────────┘  └──────────┘
Service Description
api HTTP gateway (orders, markets, health)
engine In-memory orderbook matching engine
ws WebSocket real-time event streaming
db_filler Persists events to Postgres

Quick Start

# Start infrastructure
docker compose up -d redis postgres

# Run services (in separate terminals)
cargo run -p api
cargo run -p engine
cargo run -p ws
cargo run -p db_filler

Or with Docker:

docker compose up -d

API

Endpoint Method Description
/order/new POST Create order
/order/cancel POST Cancel order
/markets GET List markets
/health GET Health check

Tests

cargo test --all

Requirements

  • Rust 1.77+
  • Redis
  • PostgreSQL