Delta is a high-performance, microservices-based option trading platform designed for speed, scalability, and reliability. It features a real-time matching engine, live market data streaming, and a responsive React frontend.
Delta uses an event-driven microservices architecture to handle high-frequency trading operations efficiently.
-
Client Request
- The user places an order via the FrontendClient.
- The request hits the HTTP Server (behind Nginx/Docker Proxy).
-
Order Queuing
- The HTTP Server validates the request and pushes it to a Redis Stream (
trade). - Instead of blocking, the HTTP server subscribes to a specific response channel and waits.
- The HTTP Server validates the request and pushes it to a Redis Stream (
-
Order Processing (The Engine)
- The Engine (in-memory) polls the
tradestream. - It matches orders, updates balances, and manages positions in microseconds.
- Market Data: The Poller service continuously feeds live prices from Backpack Exchange into the Engine via Redis.
- Liquidation: If prices move against a user, the Engine auto-liquidates positions within 3-5 seconds.
- The Engine (in-memory) polls the
-
Response & Feedback
- Once processed, the Engine publishes the result back to Redis Pub/Sub.
- The HTTP Server picks up the result and sends the final response to the user.
- Simultaneously, the Engine broadcasts updates to the Frontend via WebSockets (through the Poller/HTTP layer).
-
Persistence (DB Worker)
- To keep the Engine fast, it never writes to the database directly.
- It pushes completed trades to the
engine-responsestream. - The DB Worker asynchronously reads this stream and saves data to PostgreSQL.
- Independent Scaling: We can scale the HTTP Server to handle millions of connections without touching the Engine.
- Performance: The Engine remains single-threaded and lock-free (in-memory), unburdened by slow database writes.
- Reliability: If the DB Worker crashes, the Engine keeps running. Data piles up in Redis and is processed once the worker restarts.
| Service | Technology | Role | Documentation |
|---|---|---|---|
| Frontend | React, Vite, Zustand | User Interface, Charts & Trading Panel | Read More |
| HTTP API | Express, Bun | REST API, Auth, Request Gateway | Read More |
| Engine | Node/Bun | Order Matching, Risk Management | Read More |
| Poller | Node/Bun, WS | Market Data Aggregator | Read More |
| DB Worker | Prisma, Bun | Async Database Writer | Read More |
- Docker & Docker Compose
- Bun (for local development)
-
Clone the repository:
git clone https://github.com/SamadeshPoudel/Option-Trading-Platform.git cd Option-Trading-Platform -
Setup Environment Variables: Copy
.env.exampleto.envin the root and each service directory.cp .env.example .env # Repeat for frontend/, http/, engine/, etc. -
Start Infrastructure (Redis & Postgres):
docker compose up -d redis db
-
Run Services: You can run services individually using
bun run index.tsin their respective directories, or use Docker Compose to spin up the whole stack:docker compose up --build
-
Access the Platform:
- Frontend:
http://localhost:5173 - Backend API:
http://localhost:5000
- Frontend:
- Frontend: React 19, TypeScript, TailwindCSS v4, Lightweight Charts
- Backend API: Node.js/Bun, Express, Better-Auth
- Core Engine: In-Memory Typescript Engine
- Database: PostgreSQL (Prisma ORM)
- Message Broker: Redis Streams & Pub/Sub
- DevOps: Docker, Docker Compose, Nginx
Live link: delta.samadesh.com
