# 2227324689/gpmall architecture

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

- Interactive diagram: https://gitdiagram.com/2227324689/gpmall
- Repository: https://github.com/2227324689/gpmall

## Overview

##### Project Type and Purpose
- This is a full-stack, microservices-based e-commerce platform (“Gpmall”) with a Vue.js front end and multiple Spring Boot/Dubbo back-end services.
- The front end (gpmall-front) serves UI pages and proxies REST calls to BFF (Backend For Frontend) modules. Those BFF modules in turn consume Dubbo services for shopping, user, order, payment, search, comment, coupon, market, etc.

##### High-Level Components
a. Front End (Vue.js)
- gpmall-front (ports via webpack dev server)
b. BFF / API Gateways (Spring Boot web modules)
- gpmall-shopping (8081)
- gpmall-user     (8082)
- gpmall-cashier  (8083)
c. Core Microservices (Dubbo providers + API interface modules)
- shopping-service   (20881)
- user-service       (20880)
- order-services     (20882)
- pay-service        (20883)
- market-service     (20884)
- comment-service    (20885)
- coupon-service     (uses Dubbo)
- search-service     (builds/queries Elasticsearch)
d. Shared Libraries
- gpmall-commons (core utilities, locking, MQ, email, etc.)
- parent POM for version management
e. Infrastructure / Middleware
- Zookeeper (Dubbo registry)
- MySQL (each service persistence)
- Redis (caching/session)
- Kafka (async messaging, e.g. order cancellation, registration)
- Elasticsearch (product search)
- Druid (DB connection pool & monitoring)
- Docker-Compose orchestrates services

##### Relationships and Data Flows
- User’s browser → HTTP(S) to gpmall-front (port 8080)
- Front end proxies REST calls → BFF modules (8081–8083)
- BFF modules act as Dubbo consumers → invoke remote service APIs (RPC)
- Each Dubbo provider registers with Zookeeper → receives RPC calls
- Providers perform business logic → interact with MySQL (via MyBatis + generated mappers)
- Providers leverage Redis for caching and Kafka for events
- The search service synchronizes data to Elasticsearch for product search

##### Architectural Patterns & Design Principles
- Microservices: Each bounded context is a separate deployable unit
- API-Gateway/BFF: Web modules tailor service calls for UI use cases
- Service Registry & Discovery: Dubbo + Zookeeper
- Event-Driven: Kafka for decoupled asynchronous flows (e.g. email callbacks)
- Domain-Driven layering: API interfaces, dto conversions, persistence, service implementations
- Pipeline/Saga: Order service composes business steps via handler pipeline

##### Essential Elements to Capture
- All BFF modules and their REST endpoints
- Each Dubbo service (API + Provider) with registry to Zookeeper
- Persistence layer per service (MyBatis mappers → MySQL)
- Caching (Redis) and search index (Elasticsearch)
- Asynchronous flows via Kafka (order cancellation, registration mail)
- Shared utility layers (commons-core, commons-mq, commons-lock, commons-tool)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        FE["gpmall-front (8080)"]:::frontend
        click FE "https://github.com/2227324689/gpmall/tree/master/gpmall-front/"
    end

    subgraph "BFF / API Gateway"
        BG1["gpmall-shopping (8081)"]:::bff
        BG2["gpmall-user (8082)"]:::bff
        BG3["gpmall-cashier (8083)"]:::bff
        click BG1 "https://github.com/2227324689/gpmall/tree/master/gpmall-shopping/"
        click BG2 "https://github.com/2227324689/gpmall/tree/master/gpmall-user/"
        click BG3 "https://github.com/2227324689/gpmall/tree/master/gpmall-cashier/"
    end

    subgraph "Core Microservices"
        MS1["shopping-service (20881)"]:::core
        MS2["user-service (20880)"]:::core
        MS3["order-services (20882)"]:::core
        MS4["pay-service (20883)"]:::core
        MS5["market-service (20884)"]:::core
        MS6["comment-service (20885)"]:::core
        MS7["coupon-service"]:::core
        MS8["search-service"]:::core
        click MS1 "https://github.com/2227324689/gpmall/tree/master/shopping-service/"
        click MS2 "https://github.com/2227324689/gpmall/tree/master/user-service/"
        click MS3 "https://github.com/2227324689/gpmall/tree/master/order-services/"
        click MS4 "https://github.com/2227324689/gpmall/tree/master/pay-service/"
        click MS5 "https://github.com/2227324689/gpmall/tree/master/market-service/"
        click MS6 "https://github.com/2227324689/gpmall/tree/master/comment-service/"
        click MS7 "https://github.com/2227324689/gpmall/tree/master/coupon-service/"
        click MS8 "https://github.com/2227324689/gpmall/tree/master/search-service/"
    end

    subgraph "Shared Libraries"
        SL["gpmall-commons"]:::shared
        PP["parent POM"]:::shared
        click SL "https://github.com/2227324689/gpmall/tree/master/gpmall-commons/"
        click PP "https://github.com/2227324689/gpmall/blob/master/gpmall-parent/pom.xml"
    end

    subgraph "Infrastructure & Orchestration"
        ZK["Zookeeper (registry)"]:::infra
        MQ["Kafka (messaging)"]:::infra
        RD["Redis (cache/session)"]:::infra
        DB["MySQL (persistence)"]:::infra
        ES["Elasticsearch"]:::infra
        DC["Docker-Compose"]:::infra
        click DC "https://github.com/2227324689/gpmall/blob/master/docker-compose.yml"
    end

    Browser["User Browser"]:::frontend

    %% Synchronous flows
    Browser -->|"HTTP"| FE
    FE -->|"REST HTTP"| BG1
    FE -->|"REST HTTP"| BG2
    FE -->|"REST HTTP"| BG3

    BG1 -->|"REST HTTP"| MS1
    BG1 -->|"REST HTTP"| MS2
    BG2 -->|"REST HTTP"| MS2
    BG3 -->|"REST HTTP"| MS3
    BG3 -->|"REST HTTP"| MS4

    %% Service Registry
    MS1 <-->|"Dubbo RPC"| ZK
    MS2 <-->|"Dubbo RPC"| ZK
    MS3 <-->|"Dubbo RPC"| ZK
    MS4 <-->|"Dubbo RPC"| ZK
    MS5 <-->|"Dubbo RPC"| ZK
    MS6 <-->|"Dubbo RPC"| ZK
    MS7 <-->|"Dubbo RPC"| ZK
    MS8 <-->|"Dubbo RPC"| ZK

    %% Persistence and caching
    MS1 -->|"MyBatis → MySQL"| DB
    MS2 -->|"MyBatis → MySQL"| DB
    MS3 -->|"MyBatis → MySQL"| DB
    MS4 -->|"MyBatis → MySQL"| DB
    MS5 -->|"MyBatis → MySQL"| DB
    MS6 -->|"MyBatis → MySQL"| DB
    MS7 -->|"MyBatis → MySQL"| DB
    MS8 -->|"MyBatis → MySQL"| DB

    MS1 -->|"Cache"| RD
    MS2 -->|"Cache"| RD
    MS3 -->|"Cache"| RD
    MS4 -->|"Cache"| RD
    MS5 -->|"Cache"| RD
    MS6 -->|"Cache"| RD
    MS7 -->|"Cache"| RD
    MS8 -->|"Cache"| RD

    %% Asynchronous messaging
    MS3 -.->|"order.cancel"| MQ
    MS2 -.->|"user.register"| MQ

    %% Search index synchronization
    MS1 -.->|"sync products"| ES
    MS8 -->|"queries"| ES

    %% Shared libraries dependency
    SL --> MS1
    SL --> MS2
    SL --> MS3
    SL --> MS4
    SL --> MS5
    SL --> MS6
    SL --> MS7
    SL --> MS8

    PP --> SL

    %% Orchestration boundary
    DC --- ZK
    DC --- MQ
    DC --- RD
    DC --- DB
    DC --- ES
    DC --- MS1
    DC --- MS2
    DC --- MS3
    DC --- MS4
    DC --- MS5
    DC --- MS6
    DC --- MS7
    DC --- MS8

    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef bff fill:#90EE90,stroke:#333,stroke-width:1px
    classDef core fill:#FFA500,stroke:#333,stroke-width:1px
    classDef shared fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef infra fill:#DDA0DD,stroke:#333,stroke-width:1px
```
