Prerequisites
Before you begin, ensure you have the following installed:Node.js
Version 18 or higher required
npm
Version 10.9.0 or higher
Docker
For running PostgreSQL and Redis
Git
For version control
Quick Start
Start infrastructure services
Start PostgreSQL (TimescaleDB) and Redis using Docker Compose:This starts:
- TimescaleDB on port
5432(PostgreSQL) - Redis on port
6379
Configure environment variables
Set up environment variables for each workspace. See the Environment Configuration page for details.
Quick environment setup
Quick environment setup
Your development environment is now ready!
Monorepo Structure
Opiinix Trade uses a Turborepo monorepo architecture:Workspaces
apps/client - Next.js Frontend
apps/client - Next.js Frontend
The client application built with Next.js 14, featuring:
- Server-side rendering
- NextAuth.js for authentication
- Radix UI components
- TanStack Query for data fetching
- Real-time WebSocket connections
npm run dev- Start development server on port 3000npm run build- Build for productionnpm run start- Start production servernpm run lint- Lint code
apps/server - Express API
apps/server - Express API
The backend API server built with Express, handling:
- Order placement and management
- User authentication (JWT)
- Event management
- Portfolio tracking
npm run dev- Build and start servernpm run build- Build with esbuildnpm run start- Start production server
packages/db - Database Layer
packages/db - Database Layer
Prisma-based database package providing:
- PostgreSQL schema definitions
- Type-safe database client
- Migration management
npm run build- Generate Prisma client
packages/order-queue - Order Queue
packages/order-queue - Order Queue
Redis-based queue for asynchronous order processing:
- Order enqueueing
- Worker management
- Queue monitoring
npm run dev- Start with nodemonnpm run start- Start worker
services/engine - Matching Engine
services/engine - Matching Engine
The core order matching engine:
- Order book management
- Price-time priority matching
- Real-time order execution
npm run dev- Build and startnpm run build- Build with esbuild
services/wss - WebSocket Server
services/wss - WebSocket Server
Real-time WebSocket server for:
- Order book updates
- Live price streaming
- Event notifications
npm run dev- Build and startnpm run build- Build with esbuild
Available Scripts
Run these commands from the root directory:Turborepo Configuration
The project uses Turborepo for efficient monorepo management. Key configuration fromturbo.json:
Turborepo automatically handles task dependencies and caching for optimal build performance.
Port Configuration
Default ports used in development:| Service | Port | Description |
|---|---|---|
| Client (Next.js) | 3000 | Frontend application |
| Server (Express) | 3001 | Backend API |
| PostgreSQL | 5432 | Database |
| Redis | 6379 | Cache & Queue |
| WebSocket | 8080 | Real-time updates |