# macrozheng/mall-learning architecture

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

- Interactive diagram: https://gitdiagram.com/macrozheng/mall-learning
- Repository: https://github.com/macrozheng/mall-learning

## Overview

This project is a comprehensive, multi-module learning resource for an e-commerce (“mall”) system. The repository isn’t just a single application; it’s a collection of modules, sample implementations, and detailed supporting documentation covering the full technology stack used in a modern full‐stack, cloud‐native e-commerce system. The purpose is to teach architecture, design principles, and integration of components such as Spring Boot, MyBatis, Elasticsearch, RabbitMQ, Redis, MongoDB, Docker, and many more via a series of tutorials.

##### And Map Out the Main Architectural Components
- Frontend Layer: Although the main code in this repository is focused on backend modules (“mall-tiny-xx”, “mall-tiny-alipay”, etc.), the README also links to separate frontend projects (mall-admin-web, mall-app-web). Indicate these as distinct UI components that interact with the backend through APIs.
- Cloud, Container, and Deployment Layers: Since there are dedicated “docs/cloud” and “docs/deploy” folders, represent the containerization (Docker, Docker Compose, Jenkins deployment pipelines) and cloud integration aspects (API gateways, OAuth2 configurations, configuration centers like Consul/Nacos, and service discovery with Eureka/Zuul/knife4j_cloud).
- Cross-cutting Concerns: Identify supporting components such as security (SpringSecurity, JWT, and associated filters/configs), common API response wrappers and exception handling (common/api packages), logging & monitoring components, and the use of Lombok, Hutool, and Swagger for development and documentation.

##### Relationships and Data Flow
- Data flow between the backend modules and their corresponding data stores (MySQL for core business data, Redis for caching and possibly session management, MongoDB for NoSQL document data).
- For deployment, indicate how container orchestration and CI/CD (via Docker, Docker Compose, and optionally Jenkins) wrap around these components.

##### Architectural Patterns and Principles
- Modularization: Emphasize how each “mall-tiny” module in the repository is an example of a separate logical service (or microservice-style implementation) allowing you to focus on one technical domain (e.g., security, caching, messaging).
- Containerization and CI/CD: Include a deployment/CD pipeline segment that shows how Docker images are built via Maven plugins and deployed using Jenkins scripts.
- Cross-cutting concerns such as security (authentication, authorization), logging via AOP, and error handling are implemented in common libraries across modules.

##### Incorporate Relevant Technology and Tools
- Where applicable, call out frameworks or libraries (e.g., JWT for authentication, Swagger for documentation, Lombok for code generation).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Frontend Layer
    user["End Users"]:::userclass
    subgraph "Frontend Layer"
        adminUI["Mall Admin Web (Frontend)"]:::frontend
        appUI["Mall App Web (Frontend)"]:::frontend
    end

    %% API Gateway / Security Layer
    subgraph "API Gateway / Security Layer"
        gateway["API Gateway"]:::gateway
        authService["Auth Service (JWT)"]:::gateway
    end

    %% Backend Services
    subgraph "Backend Services"
        tiny01["mall-tiny-01 (Spring Boot)"]:::backend
        tiny02["mall-tiny-02 (Security, JWT)"]:::backend
        tinyAlipay["mall-tiny-alipay (Alipay Payment)"]:::backend
        tinyBoot["mall-tiny-boot"]:::backend
        tinyMybatis["mall-tiny-mybatis"]:::backend
        tinyPlus["mall-tiny-plus"]:::backend
        tinyRabbit["mall-tiny-rabbit (Messaging)"]:::backend
        tinyRedis["mall-tiny-redis (Caching)"]:::backend
        tinyStream["mall-tiny-stream (Event Streaming)"]:::backend
        tinySwagger["mall-tiny-swagger (API Docs)"]:::backend
        tinyMain["mall-tiny (Base Module)"]:::backend
    end

    %% Integration & Middleware
    subgraph "Integration & Middleware"
        redisConfig["Redis Config"]:::integration
        redisService["Redis Service"]:::integration
        rabbitMqConfig["RabbitMQ Config"]:::integration
        rabbitMqComp["RabbitMQ Components"]:::integration
        esRepo["Elasticsearch Repository"]:::integration
        mongoRepo["MongoDB Repository"]:::integration
    end

    %% Data Storage
    subgraph "Data Storage"
        mysqlDB["MySQL Database"]:::database
        navicat["Navicat DB Model"]:::database
    end

    %% Cross-cutting Concerns
    subgraph "Cross-cutting Concerns"
        commonApi["Common API"]:::crosscut
        jwtUtils["JWT Utilities"]:::crosscut
    end

    %% Deployment & Cloud
    subgraph "Deployment & Cloud"
        cloudDocs["Cloud Docs"]:::deployment
        deployDocs["Deployment Docs"]:::deployment
        dockerNode["Docker & Compose"]:::deployment
        jenkinsNode["Jenkins CI/CD"]:::deployment
    end

    %% Connections from Users to Frontend
    user -->|"accesses"| adminUI
    user -->|"accesses"| appUI

    %% Frontend to API Gateway
    adminUI -->|"calls"| gateway
    appUI -->|"calls"| gateway

    %% API Gateway to Auth Service
    gateway -->|"authenticates"| authService

    %% Auth Service routing to Backend Services
    authService -->|"routes"| tiny01
    authService -->|"routes"| tiny02
    authService -->|"routes"| tinyAlipay
    authService -->|"routes"| tinyBoot
    authService -->|"routes"| tinyMybatis
    authService -->|"routes"| tinyPlus
    authService -->|"routes"| tinyRabbit
    authService -->|"routes"| tinyRedis
    authService -->|"routes"| tinyStream
    authService -->|"routes"| tinySwagger
    authService -->|"routes"| tinyMain

    %% Backend Services usage of Integration & Middleware components
    tinyRedis -->|"uses"| redisConfig
    tinyRedis -->|"uses"| redisService
    tinyRabbit -->|"uses"| rabbitMqConfig
    tinyRabbit -->|"uses"| rabbitMqComp
    tinyPlus -->|"uses"| esRepo
    tinyMain -->|"uses"| mongoRepo

    %% Backend Services connection to Data Storage
    tiny01 -->|"stores"| mysqlDB
    tiny02 -->|"stores"| mysqlDB
    tinyMain -->|"stores"| mysqlDB

    %% Backend Services utilizing Cross-cutting components
    tiny02 -->|"uses"| commonApi
    tiny02 -->|"uses"| jwtUtils

    %% Data Storage internal connection
    mysqlDB ---|"modeledIn"| navicat

    %% Deployment & Cloud connections (deployment flows)
    gateway ---|"deployedVia"| dockerNode
    adminUI ---|"deployedVia"| deployDocs
    appUI ---|"deployedVia"| cloudDocs
    tiny01 ---|"CI/CD"| jenkinsNode

    %% Click Events for Backend Modules
    click tiny01 "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-01/"
    click tiny02 "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-02/"
    click tinyAlipay "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-alipay/"
    click tinyBoot "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-boot/"
    click tinyMybatis "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-mybatis/"
    click tinyPlus "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-plus/"
    click tinyRabbit "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-rabbit/"
    click tinyRedis "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-redis/"
    click tinyStream "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-stream/"
    click tinySwagger "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-swagger/"
    click tinyMain "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny/"

    %% Click Events for Integration & Middleware
    click redisConfig "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-03/src/main/java/com/macro/mall/tiny/config/RedisConfig.java"
    click redisService "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-03/src/main/java/com/macro/mall/tiny/service/RedisService.java"
    click rabbitMqConfig "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-07/src/main/java/com/macro/mall/tiny/config/RabbitMqConfig.java"
    click rabbitMqComp "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-rabbit/"
    click esRepo "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-05/src/main/java/com/macro/mall/tiny/nosql/elasticsearch/repository/EsProductRepository.java"
    click mongoRepo "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-06/src/main/java/com/macro/mall/tiny/nosql/mongodb/repository/MemberReadHistoryRepository.java"

    %% Click Events for Data Storage
    click mysqlDB "https://github.com/macrozheng/mall-learning/blob/master/document/sql/mall_tiny.sql"
    click navicat "https://github.com/macrozheng/mall-learning/blob/master/document/navicat/mall数据库模型.ndm2"

    %% Click Events for Deployment & Cloud
    click cloudDocs "https://github.com/macrozheng/mall-learning/tree/master/docs/cloud/"
    click deployDocs "https://github.com/macrozheng/mall-learning/tree/master/docs/deploy/"
    click dockerNode "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-docker/"
    click jenkinsNode "https://github.com/macrozheng/mall-learning/tree/master/mall-tiny-jenkins/"

    %% Click Events for Cross-cutting Concerns
    click commonApi "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-01/src/main/java/com/macro/mall/tiny/common/api/CommonResult.java"
    click jwtUtils "https://github.com/macrozheng/mall-learning/blob/master/mall-tiny-04/src/main/java/com/macro/mall/tiny/common/utils/JwtTokenUtil.java"

%% Styles
classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
classDef gateway fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
classDef backend fill:#D5F5E3,stroke:#1D8348,stroke-width:2px;
classDef integration fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
classDef database fill:#D6EAF8,stroke:#2471A3,stroke-width:2px;
classDef crosscut fill:#FDEDEC,stroke:#922B21,stroke-width:2px;
classDef deployment fill:#E8DAEF,stroke:#6C3483,stroke-width:2px;
classDef userclass fill:#F7DC6F,stroke:#B7950B,stroke-width:2px;
```
