{"id":24033520,"url":"https://github.com/vikash1596kumarkharwar/cryptotradex","last_synced_at":"2026-05-07T02:35:00.065Z","repository":{"id":270557472,"uuid":"910748102","full_name":"VIKASH1596KUMARKHARWAR/CryptoTradeX","owner":"VIKASH1596KUMARKHARWAR","description":"CryptoTradeX is a cutting-edge cryptocurrency exchange system built for scalability, high performance, and real-time trading. It leverages modern technologies like Redis, TimescaleDB, and WebSockets to deliver lightning-fast order processing and seamless user experiences.","archived":false,"fork":false,"pushed_at":"2025-01-01T09:51:25.000Z","size":1793,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T17:49:28.937Z","etag":null,"topics":["nextjs","nodejs","redis","timescaledb","typescript","websocket"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VIKASH1596KUMARKHARWAR.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-01T09:42:12.000Z","updated_at":"2025-01-01T09:54:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"9beb4b3e-a25e-441d-93ad-510a3d36857f","html_url":"https://github.com/VIKASH1596KUMARKHARWAR/CryptoTradeX","commit_stats":null,"previous_names":["vikash1596kumarkharwar/cryptotradex"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/VIKASH1596KUMARKHARWAR/CryptoTradeX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VIKASH1596KUMARKHARWAR%2FCryptoTradeX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VIKASH1596KUMARKHARWAR%2FCryptoTradeX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VIKASH1596KUMARKHARWAR%2FCryptoTradeX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VIKASH1596KUMARKHARWAR%2FCryptoTradeX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VIKASH1596KUMARKHARWAR","download_url":"https://codeload.github.com/VIKASH1596KUMARKHARWAR/CryptoTradeX/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VIKASH1596KUMARKHARWAR%2FCryptoTradeX/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32720352,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-07T02:14:30.463Z","status":"ssl_error","status_checked_at":"2026-05-07T02:14:29.405Z","response_time":62,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextjs","nodejs","redis","timescaledb","typescript","websocket"],"created_at":"2025-01-08T18:19:40.662Z","updated_at":"2026-05-07T02:35:00.049Z","avatar_url":"https://github.com/VIKASH1596KUMARKHARWAR.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Cryptocurrency Exchange System\n\n## Overview\nThis project implements a **high-performance cryptocurrency exchange system** focusing on **scalability**, **concurrency**, and **real-time data updates**. The architecture leverages modern technologies like **Redis**, **TimescaleDB**, and **WebSockets** to deliver efficient trading capabilities.\n\n--- \n\nWe welcome contributions from all developers and would love to connect with like-minded individuals who are passionate about cryptocurrency, high-performance systems, and real-time data.\n\n---\n## what i build :\n\n![result ](images/result/img1.png)\n\n---\n## 🏗️ System Architecture\n\n\n## 🖼️ System Architecture Diagram\n![System Architecture Diagram](system-architecture.png)\n_The diagram illustrating the high-level architecture of the system._\n\n\nThe system is divided into the following services:\n\n- **API**: Handles HTTP requests from users.\n- **Engine**: Maintains market orderbooks and user balances (stored in memory for high-speed access).\n- **WebSocket**: Streams real-time events to clients.\n- **DB Processor**: Processes messages from the Engine and persists them into the database.\n- **Frontend**: A Next.js application that provides the user interface.\n- **Market Maker (MM)**: Generates random orders to maintain market liquidity.\n- **Redis**: Used for queueing and Pub/Sub operations.\n- **TimescaleDB**: Manages time-series data and creates Kline data buckets for analytics.\n\n### Primary Database\n- **PostgreSQL** is suggested as the primary database to store critical data such as user information, orders, trades, etc.\n\n---\n\n## 📡 WebSocket Streaming\nThe system supports the following WebSocket streams:\n\n- **Trades**: `trades@MARKET`\n- **Orderbook Depth**: `depth@MARKET`\n- **Ticker Updates**: `ticker@MARKET`\n\n---\n\n## ⚙️ Working Flow\n\n### Sequential Processing\nThe workflow ensures that all operations are sequential rather than concurrent, guaranteeing data consistency and preventing race conditions.\n\n### Single Engine\nA single engine is responsible for maintaining the **orderbook** and **user balances**, ensuring **data integrity** throughout the system.\n\n### Database Operations\n- **Time series data** stores trade and order events, which are later transformed into **Kline (Candlestick)** data for analytics.\n- A **locking mechanism** ensures secure operations, such as **fund creation** and **updates**, preventing inconsistent states in concurrent environments.\n\n### Critical Functionality\n\n#### `createAndLockFunds()`\nThis function ensures that funds are locked securely during critical operations. It uses precise **technical and mathematical reasoning** to prevent **race conditions** and **inconsistent states**.\n\n---\n\n## 🛠️ Local Setup\n\nFollow the instructions below to set up the project locally.\n\n### Set up TimescaleDB and Redis:\n1. Navigate to the `docker` directory:\n    ```bash\n    cd docker\n    ```\n\n2. Start the services:\n    ```bash\n    docker-compose up\n    ```\n\n3. If PostgreSQL is running, disable and stop it:\n    ```bash\n    sudo systemctl disable postgresql\n    sudo systemctl stop postgresql\n    ```\n\n---\n\n### Start Services:\n1. **API Server:**\n    ```bash\n    cd api\n    npm install\n    npm run dev\n    ```\n\n2. **Engine:**\n    ```bash\n    cd engine\n    npm install\n    npm run dev\n    ```\n\n3. **WebSocket Server:**\n    ```bash\n    cd ws\n    npm install\n    npm run dev\n    ```\n\n4. **Frontend:**\n    ```bash\n    cd frontend\n    npm install\n    npm run dev\n    ```\n5. **market makers:**\n    ```bash\n    cd mm\n    npm install\n    npm run dev\n    ```\n\n---\n\n## 📝 Important Considerations\n\n- **Orderbook and User Balances**: These are stored in memory for fast access and processing.\n- **Locking Balances**: Ensures secure fund management during operations like placing orders or withdrawals.\n\n---\n\n## 🤔 Counterintuitive Points\n\n- **In-Memory Operations**: Critical data (like balances and orderbooks) is stored in memory for high performance. The DB Processor ensures eventual consistency by persisting this data into TimescaleDB and PostgreSQL.\n  \n- **Sequential Workflow**: Despite the system's concurrency at the service level, individual operations follow a sequential workflow to ensure reliability and avoid data inconsistency.\n\n---\n## 🤝 Contributing\n\nWe encourage you to contribute to this project! If you find any issues, have suggestions for improvement, or want to add new features, feel free to open a pull request. Your contributions are always welcome.\n\nWe'd love to connect with developers who are passionate about building scalable, real-time systems. Let's grow this project together!\n\n---\n\n## 🔧 Troubleshooting\n\n- If you encounter issues with database connections or WebSocket streaming, ensure that all services are running and Docker is correctly configured.\n- For issues with the API server or engine, check the logs for detailed error messages.\n\n---\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikash1596kumarkharwar%2Fcryptotradex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvikash1596kumarkharwar%2Fcryptotradex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikash1596kumarkharwar%2Fcryptotradex/lists"}