# bitisanop/cryptoexchange_tradingplatform_coinexchange architecture

> Architecture diagram of the GitHub repository bitisanop/cryptoexchange_tradingplatform_coinexchange, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bitisanop/cryptoexchange_tradingplatform_coinexchange
- Repository: https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange

## Overview

##### Project type and purpose
- This is a full-stack, Java-based, microservice architecture for a digital asset exchange and perpetual contract trading system (“BITISAN”).
- It uses Spring Cloud (Feign clients, gateway), Spring Boot, MyBatis, Redis, RocketMQ, Netty, MySQL/MongoDB, with separate front-end (Vue/H5/Admin) modules.

##### File structure
- Top-level modules (Maven multi-module):
- bitisan-api: interface definitions (Java packages with Feign clients, DTOs, entities)
- bitisan-gateway: API Gateway (Spring Cloud Gateway/Zuul)
- bitisan-service: many sub-services (admin, user, exchange, market, match, coinswap, earn, option, swap, second, p2p, udun, permission, robot-market, robot-normal, open)
- bitisan-netty: custom Netty server for real-time/Push logic (WebSockets, Shiro, handlers)
- bitisan-generate: code generator for MyBatisPlus
- bitisan-web: front-end resources (Vue, H5, Admin UI)
- bitisan-util: common/shared libraries and dependency management
- config/bootstrap.yml: common Spring Cloud Config (centralized configuration)
- Notice each service has its own controller, service, mapper, entity, MQ listeners, xxl-job tasks, and resources.

##### README insights
- Core function: multi-asset trading (spot, contract, options, swap, second market, P2P).
- Uses Redis for caching & locks, RocketMQ for event-driven order processing, MySQL for core data, MongoDB for market data.
- Front-ends: SPA (Vue), H5 (uniApp), Native mobile (Swift, Java Android), Admin console.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        Web["Web/UI (Vue)"]:::client
        Mobile["H5/Mobile App"]:::client
        AdminUI["Admin Console"]:::client
    end

    %% Edge Layer
    Web -->|HTTP| NGINX["NGINX Load Balancer"]:::edge
    Mobile -->|HTTP| NGINX
    AdminUI -->|HTTP| NGINX

    %% Gateway Layer
    NGINX -->|Forward| Gateway["API Gateway"]:::gateway
    click Gateway "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-gateway/bitisan-api-gateway/"

    %% Config & Registry
    Gateway -->|Config Pull| ConfigServer["Config Server"]:::infra
    click ConfigServer "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/blob/main/config/bootstrap.yml"
    Gateway -->|Discovery| Registry["Service Registry"]:::infra

    %% Microservices Layer
    subgraph "Microservices" 
        direction TB

        subgraph "User Domain"
            UserService["User Service"]:::service
            PermissionService["Permission Service"]:::service
        end
        click UserService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-user-service/"
        click PermissionService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-permission-service/"

        subgraph "Trading Core"
            ExchangeService["Exchange Service"]:::service
            MatchService["Match Service"]:::service
            MarketService["Market Service"]:::service
        end
        click ExchangeService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-exchange-service/"
        click MatchService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-match-service/"
        click MarketService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-market-service/"

        subgraph "Management"
            AdminService["Admin Service"]:::service
            AgentService["Agent Portal Service"]:::service
        end
        click AdminService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-admin-service/"
        click AgentService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-agent-service/"

        subgraph "Financial Products"
            CoinswapService["Coinswap Service"]:::service
            EarnService["Earn Service"]:::service
            OptionService["Option Service"]:::service
            SwapService["Swap Service"]:::service
            SecondService["Second Market Service"]:::service
            P2PService["P2P Service"]:::service
        end
        click CoinswapService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-coinswap-service/"
        click EarnService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-earn-service/"
        click OptionService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-option-service/"
        click SwapService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-swap-service/"
        click SecondService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-second-service/"
        click P2PService "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-p2p-service/"

        subgraph "Robots & Jobs"
            RobotMarket["Robot Market Trading Service"]:::service
            RobotNormal["Robot Normal Trading Service"]:::service
            JobTasks["Scheduled Job Utilities (XXL)"]:::service
        end
        click RobotMarket "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-robot-market-service/"
        click RobotNormal "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-robot-normal-service/"
        click JobTasks "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-job/"

        subgraph "Open & API"
            OpenAPI["Open API Service"]:::service
            APIInterfaces["API Interfaces (Feign, DTOs)"]:::service
        end
        click OpenAPI "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-service/bitisan-open-service/"
        click APIInterfaces "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-api/"

    end

    %% Communication
    Gateway -->|HTTP/Feign| UserService
    Gateway -->|HTTP/Feign| PermissionService
    Gateway -->|HTTP/Feign| ExchangeService
    Gateway -->|HTTP/Feign| MatchService
    Gateway -->|HTTP/Feign| MarketService
    Gateway -->|HTTP/Feign| AdminService
    Gateway -->|HTTP/Feign| AgentService
    Gateway -->|HTTP/Feign| OpenAPI

    %% Order Flow (Async)
    ExchangeService -->|"RocketMQ topic: orderEvents"| MatchService:::async
    MatchService -->|"RocketMQ topic: tradeEvents"| ExchangeService:::async
    ExchangeService -->|"HTTP/Feign walletUpdate"| UserService

    %% Market Data Flow
    MarketService -->|Store| MongoDB["MongoDB"]:::data
    MarketService -->|Cache| Redis["Redis"]:::data
    MarketService -->|Push via WebSocket| NettyServer["Netty Server"]:::infra
    click NettyServer "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-netty/src/main/java/com/bitisan/netty/"

    NettyServer -->|WebSocket| Web
    NettyServer -->|WebSocket| Mobile

    %% Data Stores
    UserService -->|CRUD| MySQL["MySQL"]:::data
    ExchangeService -->|CRUD| MySQL
    MatchService -->|CRUD| MySQL
    PermissionService -->|CRUD| MySQL
    AdminService -->|CRUD| MySQL
    AgentService -->|CRUD| MySQL
    OpenAPI -->|CRUD| MySQL
    CoinswapService -->|CRUD| MySQL
    EarnService -->|CRUD| MySQL
    OptionService -->|CRUD| MySQL
    SwapService -->|CRUD| MySQL
    SecondService -->|CRUD| MySQL
    P2PService -->|CRUD| MySQL
    RobotMarket -->|CRUD| MySQL
    RobotNormal -->|CRUD| MySQL

    %% Utilities & External
    APIInterfaces -->|Shared| Util["Shared Utilities"]:::infra
    click Util "https://github.com/bitisanop/cryptoexchange_tradingplatform_coinexchange/tree/main/bitisan-util/"

    ExternalOSS["Alibaba OSS"]:::external
    Geetest["Geetest Captcha"]:::external
    SMS["Aliyun/Tencent SMS"]:::external

    UserService -->|Upload| ExternalOSS
    UserService -->|Captcha| Geetest
    UserService -->|SMS| SMS

    %% Legend
    subgraph Legend
        direction TB
        C1["Client"]:::client
        G1["Edge/Gateway"]:::gateway
        S1["Service"]:::service
        D1["Database/Cache"]:::data
        I1["Infrastructure"]:::infra
        E1["External"]:::external
    end

    %% Styles
    classDef client fill:#FFD580,stroke:#333,stroke-width:1px
    classDef edge fill:#FFB6C1,stroke:#333,stroke-width:1px
    classDef gateway fill:#FF7F50,stroke:#333,stroke-width:1px
    classDef service fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef data fill:#98FB98,stroke:#333,stroke-width:1px
    classDef infra fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#F5DEB3,stroke:#333,stroke-width:1px
    classDef async stroke-dasharray: 5 5;color:#555
    class Registry,ConfigServer,MySQL,MongoDB,Redis,NettyServer infra
    class async async
```
