How jammy928/coinexchange_cryptoexchange_java works
Project type and purpose
• This is a full-stack, Spring-Cloud-based microservice cryptocurrency exchange platform.
• It consists of multiple backend services (matching engine, market data, user center, OTC, chat, wallet, admin API), two Vue.js front-ends (trading UI & admin console), native mobile apps (Android/iOS, not open-source), and wallet RPC modules for various blockchains.
File structure
• 00_framework (core microservices):
• cloud – Eureka service registry
• admin – admin back-end API
• exchange – in-memory matching engine
• exchange-api & exchange-core – REST API and domain logic for orders
• market – market data service (K-line, depth, push)
• ucenter-api – user management API
• otc-api & otc-core – OTC trading API & logic
• chat – real-time chat (Netty + WebSocket)
• wallet – internal wallet microservice (finance, Kafka consumers)
• core – shared DTOs, entities, DAO, common config
• sql – SQL scripts and triggers
• 01_wallet_rpc – dozens of coin-specific RPC microservices (bitcoin, eth, erc-20, etc.) each exposing a REST/gRPC endpoint, invoking blockchain nodes or third-party explorers.
• 04_Web_Admin – Vue.js admin console (connects to admin API).
• 05_Web_Front – Vue.js trading UI (connects to exchange-api, ucenter‐api, otc-api, wallet).
• 02_App_Android & 03_APP_IOS – native mobile clients.
README insights
• Microservice architecture (Spring Cloud).
• Service discovery (Eureka).
• Message bus (Kafka) for decoupled events: order matching → market persistence → market push.
• Datastores: MySQL for relational data, MongoDB for order details & market persistence, Redis for cache & sessions.
• External dependencies: Alibaba OSS, Tencent Captcha.
• Wallet RPC services for on-chain transactions.
• Clients: Web Front-End, Web Admin, Mobile Apps
• API Gateway / Load Balancer (optional if in use)
• Service Discovery (Eureka)
• Microservices: Admin, Exchange-API, Exchange Core, Exchange (matching engine), Market, UCenter, OTC API, Chat, Wallet
• Wallet RPC Cluster (multiple coin services)
• Messaging Layer (Kafka cluster)
• Databases/Caches: MySQL, MongoDB, Redis
• External Services: Blockchain nodes / explorers, OSS, Captcha, Email/SMS gateways
b. Relationships & data flows:
• Clients → API Gateway → relevant microservice (e.g., trading UI → Exchange-API; admin UI → Admin service)
• Microservices register with Eureka (cloud).
• Exchange-API forwards orders to Exchange (matching engine).
• Exchange publishes match events to Kafka → Market service consumes to persist trades and generate K-lines → push via WebSocket or HTTP to clients.
• Chat service uses WebSocket & Netty, persists history in MongoDB.
• UCenter handles user/account actions, writes to MySQL, caches sessions in Redis.
• OTC API uses Kafka for asynchronous tasks (order checking, settlement).
• Wallet microservice and wallet-rpc services listen to Kafka/deposit events, call blockchain RPCs and persist deposit/withdraw records in MongoDB/MySQL, then publish events back onto Kafka.
c. Architectural patterns & design principles:
• Microservices with single responsibility, discoverable via Eureka
• Event-driven asynchronous communication (Kafka topics for orders, trades, deposits)
• Shared core library for common entities/DAOs (promotes code reuse)
• Domain-driven: separate modules for Exchange domain, Market domain, OTC, UCenter, Wallet
• CQRS-style separation: Exchange engine (write), Market service (read & BI)
d. Key technologies:
• Java 8, Spring Boot, Spring Cloud (Eureka, Config, Zuul? if used)
• Spring Data JPA (MySQL), Spring Data MongoDB, Redis (Spring Cache/Shiro session store)
• Kafka (Spring Kafka)
• Netty & WebSocket for chat & market push
• Vue.js + iView + Less for front-ends
• REST controllers for APIs