This project is a cryptocurrency trading platform clone inspired by Exness. It allows users to simulate trading SOL, BTC, and ETH with real-time price updates, order management features, and candlestick charts. This platform is designed for educational purposes, strategy testing, and portfolio building.
- Key Features
- Installation Guide
- Usage
- Environment Variables
- Project Structure
- Technologies Used
- License
- Real-time Price Updates: Uses WebSockets to receive live trade data for SOL, BTC, and ETH.
- Order Management: Allows users to create, manage, and close buy/sell orders with configurable margin, leverage, stop loss, and take profit.
- Candlestick Charts: Displays historical price data using candlestick charts with selectable time intervals (1m, 5m, 15m).
- User Authentication: Implements JWT-based authentication for user signup and signin.
- Asynchronous Order Processing: Uses Bull queue to process order-related events asynchronously.
- Email Notifications: Sends email notifications for order events (open, close, liquidate).
- Redis Integration: Uses Redis for real-time data distribution and caching.
- Data Persistence: Trade data is stored in a PostgreSQL database.
- Server-Sent Events: Order updates pushed to the client with Server-Sent Events (SSE).
- Zustand State Management: Uses Zustand for a simple frontend state management.
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Install backend dependencies:
cd backend npm install cd ../httpServer npm install cd ../Price-Websocket npm install
-
Install frontend dependencies:
cd frontend npm install -
Configure environment variables:
Create
.envfiles in thebackend,httpServer,Price-Websocketandfrontenddirectories based on the.env.exampleor similar files (if present). Set the following environment variables:- Backend/httpServer:
DATABASE_URL: PostgreSQL database connection URI.REDIS_URL: Redis connection URI.JWT_SECRET: Secret key for JWT authentication.SENDGRID_API_KEY: API key for SendGrid email service.FRONTEND_URL: The URL for the frontend, in order to allow CORS.
- Price-Websocket:
- No specific env vars.
- Frontend:
VITE_BACKEND_URL: The URL for the backend api.VITE_WEBSOCKET_URL: The URL for the price-websocket server.
- Backend/httpServer:
-
Run the PostgreSQL database:
Ensure you have PostgreSQL installed and running. Create a database and configure the
DATABASE_URLenvironment variable accordingly. -
Run Redis server:
Ensure you have Redis installed and running. Configure the
REDIS_URLenvironment variable. -
Run the backend servers:
cd backend npm run dev # or npm start cd ../httpServer npm run dev # or npm start cd ../Price-Websocket npm run dev # or npm start
-
Run the frontend:
cd frontend npm run dev
-
Access the platform: Open your browser and navigate to the address where the frontend is running (typically
http://localhost:5173). -
Sign up/Sign in: Create a new user account or sign in with existing credentials.
-
View real-time prices: The main trading interface displays real-time prices for SOL, BTC, and ETH.
-
Place orders: Use the buy/sell order form to create new orders, specifying margin, leverage, stop loss, and take profit values.
-
Manage orders: View and close open orders in the order management section.
-
View candlestick charts: Analyze historical price data using the candlestick charts with selectable time intervals.
DATABASE_URL: PostgreSQL database connection URI.REDIS_URL: Redis connection URI.JWT_SECRET: Secret key for JWT authentication.SENDGRID_API_KEY: API key for SendGrid email service.FRONTEND_URL: The URL for the frontend, in order to allow CORS.VITE_BACKEND_URL: The URL for the backend API.VITE_WEBSOCKET_URL: The URL for the price-websocket server.
/
├── Readme.md # This file
├── backend/ # Backend server (Node.js/TypeScript)
│ ├── src/ # Backend source code
│ │ ├── index.ts # Backend entry point
│ ├── package.json # Backend dependencies and scripts
│ ├── tsconfig.json # TypeScript configuration
│ └── nodemon.json # Nodemon configuration
├── httpServer/ # HTTP server for API endpoints (Node.js/TypeScript)
│ ├── src/ # HttpServer source code
│ │ ├── server.ts # HttpServer entry point
│ │ ├── jwt.ts # JWT related code
│ │ ├── models/ # Data models
│ │ ├── utils/ # Utility functions
│ │ ├── services/ # Business Logic services
│ ├── package.json # HttpServer dependencies and scripts
│ ├── tsconfig.json # TypeScript configuration
├── Price-Websocket/ # Price WebSocket Server
│ ├── src/ # Price WebSocket source code
│ │ ├── server.ts # Price WebSocket entry point
│ ├── package.json # Price WebSocket dependencies and scripts
│ ├── tsconfig.json # TypeScript configuration
├── frontend/ # Frontend application (React)
│ ├── src/ # Frontend source code
│ │ ├── components/ # React components
│ │ ├── assets/ # Static assets (images, etc.)
│ │ ├── App.jsx # Main App Component
│ │ ├── main.jsx # React entry point
│ │ ├── index.css # Global CSS styles
│ │ ├── stores/ # Zustand stores
│ ├── package.json # Frontend dependencies and scripts
│ ├── vite.config.js # Vite configuration
│ ├── index.html # HTML entry point