# gz-yami/mall4j architecture

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

- Interactive diagram: https://gitdiagram.com/gz-yami/mall4j
- Repository: https://github.com/gz-yami/mall4j

## Overview

##### Main System Components

The system is a B2C e-commerce platform with these key components:

a) Backend Services (Java):
- Admin Service (yami-shop-admin)
- API Service (yami-shop-api)
- Core Services (yami-shop-service)
- Security Module (yami-shop-security)
- System Management (yami-shop-sys)

b) Frontend Applications:
- Admin Dashboard (mall4v - Vue)
- Mobile Mini Program (mall4m - WeChat Mini Program)
- Universal App (mall4uni - Uni-app)

c) Infrastructure:
- Database (MySQL)
- Cache (Redis)
- File Storage
- Security Layer

**┌─ Client Layer ─────────────────────────┐**
- Mall4v (Admin) │ Mall4m │ Mall4uni     │
- ┴────────┴──────────────┘
- ↓            ↓           ↓
**┌─ Gateway/Security Layer ───────────────┐**
- SA-Token Authentication & Authorization │
- ┘
- ↓                    ↓
**┌─ Application Layer ──────────────────────────────┐**
- ┌─────────────┐ ┌──────────┐ ┌────────────────┐ │
- Admin Service│ │API Service│ │Security Service│ │
- ┘ └──────────┘ └────────────────┘ │
- ┘
- ↓                    ↓
**┌─ Service Layer ────────────────────────────────┐**
- Order│Product│User│System│Payment│Delivery     │
- ┘
- ↓                    ↓
**┌─ Infrastructure Layer ────────────────────────┐**
- MySQL │ Redis │ File Storage │ Message Queue  │
- ┘

##### Key Interactions to Highlight

- Authentication flow using SA-Token
- Order processing pipeline
- Product management workflow
- User session management
- Cache interaction patterns
- File upload/download paths

##### Additional Elements

Components:
- Distributed lock mechanism (Redisson)
- XSS protection layer
- Validation framework
- Swagger/Knife4j API documentation
- MyBatis Plus data access
- Logging system (Logback)

##### Technical Details

- Spring Boot 3.0.4 framework
- SA-Token 1.34.0 security
- MyBatis Plus 3.5.3.1
- Redis/Redisson integration
- Validation framework
- Distributed architecture support

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style definitions
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef infrastructure fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white

    %% Client Layer
    subgraph ClientLayer
        Mall4v["Admin Dashboard"]:::frontend
        Mall4m["Mobile Mini Program"]:::frontend
        Mall4uni["Universal App"]:::frontend
    end

    %% Security Layer
    subgraph SecurityLayer
        SAToken["SA-Token Authentication"]:::security
        XSSProtection["XSS Protection"]:::security
    end

    %% Application Layer
    subgraph ApplicationLayer
        AdminService["Admin Service"]:::api
        APIService["API Service"]:::api
        SecurityService["Security Service"]:::security
    end

    %% Service Layer
    subgraph ServiceLayer
        OrderService["Order Service"]:::service
        ProductService["Product Service"]:::service
        UserService["User Service"]:::service
        SystemService["System Service"]:::service
        PaymentService["Payment Service"]:::service
        DeliveryService["Delivery Service"]:::service
    end

    %% Infrastructure Layer
    subgraph InfrastructureLayer
        MySQL[(MySQL)]:::infrastructure
        Redis[(Redis)]:::infrastructure
        FileStorage["File Storage"]:::infrastructure
        MessageQueue["Message Queue"]:::infrastructure
    end

    %% Connections
    Mall4v & Mall4m & Mall4uni --> SAToken
    SAToken --> AdminService & APIService
    XSSProtection --> AdminService & APIService
    AdminService & APIService --> SecurityService
    SecurityService --> OrderService & ProductService & UserService & SystemService & PaymentService & DeliveryService
    OrderService & ProductService & UserService & SystemService & PaymentService & DeliveryService --> MySQL
    OrderService & ProductService & UserService --> Redis
    ProductService --> FileStorage
    OrderService --> MessageQueue

    %% Click events
    click Mall4v "https://github.com/gz-yami/mall4j/tree/master//front-end/mall4v"
    click Mall4m "https://github.com/gz-yami/mall4j/tree/master//front-end/mall4m"
    click Mall4uni "https://github.com/gz-yami/mall4j/tree/master//front-end/mall4uni"
    click AdminService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-admin"
    click APIService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-api"
    click SecurityService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-security"
    click SystemService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-sys"
    click MySQL "https://github.com/gz-yami/mall4j/blob/master//db/yami_shop.sql"
    click OrderService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-service/src/main/java/com/yami/shop/service"
    click ProductService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-service/src/main/java/com/yami/shop/service"
    click UserService "https://github.com/gz-yami/mall4j/tree/master//yami-shop-service/src/main/java/com/yami/shop/service"

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        Security["Security"]:::security
        Service["Service"]:::service
        Infra["Infrastructure"]:::infrastructure
        API["API"]:::api
    end
```
