# lipengjun92/platform-wxshop architecture

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

- Interactive diagram: https://gitdiagram.com/lipengjun92/platform-wxshop
- Repository: https://github.com/lipengjun92/platform-wxshop

## Overview

##### Main Components
- Backend Modules:
– platform-admin: The administrative/backend management module (Spring MVC-based, using MyBatisPlus, with integrated aspects (AOP) for caching, logging, and data filtering). It handles business logic and system configuration.
– platform-api: The RESTful API layer targeted at the WeChat mini-program. It handles public interfaces, authentication, and transactions related to shopping, orders, and goods.
– platform-schedule: The module for scheduling and executing periodic tasks in the system.
– platform-common: The common library which serves cross-cutting concerns (utility functions, caching, authentication, shiro security, logging, and file upload/OSS support).
– platform-gen: A separate code generation module which helps automate the creation of code (DAO, Service, Controller, templates).
- Frontend Modules:
– uni-mall: A uniapp-based front-end center for the mall optimized for cross-platform use.
– wx-mall: A native WeChat mini-program implementation.
- Database and Infrastructure:
– _sql scripts: Database initialization scripts (for the core platform and region data).
– Cache/Redis integration (configured using j2cache.properties).
- Other elements:
– Payment integrations: WeChat payment configuration and related certificates.
– External service integrations such as SMS, Weixin Java SDK, and possibly third-party authentication.

##### Relationships and Interactions
- The Customer places orders via the client front-ends (uni-mall and wx-mall) which connect through the platform-api.
- The platform-admin serves as the backend management console where administrators can manage goods, orders, users, etc.
- The platform-common module acts as a shared library providing utilities and common service implementations to both the admin and API modules.
- The platform-gen module interacts mostly during the development phase to generate code/templates that are then used by the other modules.
- The platform-schedule module runs scheduled tasks (e.g., maintenance or periodic business logic) and interacts with the common database and caching infrastructure.
- All backend modules interact with the MySQL database as their persistence store and utilize Redis for caching and session management.
- External integrations (payment, SMS, certificate-based communications) are configured in the properties under platform-admin and platform-api, ensuring that data flows securely between third parties and the platform.

##### Architectural and Design Patterns
- Layered Architecture: Clearly separate the presentation (web and API), business logic (service layer), data access (DAO/Mapper layer), and infrastructure (common utilities and external APIs).
- Modularization: Each submodule (admin, API, common, schedule, gen) functions as a distinct layer/component.
- Cross-Cutting Concerns: Use of AOP aspects for logging, caching, and data filtering.
- RESTful Communication: The API layer communicates with front-end clients through well-defined REST endpoints.
- Code Generation: The platform-gen module implements a template-based approach for generating CRUD interfaces, ensuring consistent architecture.
- Authentication & Security: Integration with shiro (as seen in the common module) and token-based API authentication.

##### Relevant Technologies and Frameworks
- Java (and specifically Java 11 is recommended)
- Spring MVC for the web framework, integrated with MyBatisPlus for ORM.
- Redis (with J2Cache) for caching.
- Payment integration using Weixin (WeChat) Java SDK.
- Frontend using uniapp (uni-mall) and native WeChat components (wx-mall) for mobile e-commerce.
- Maven for project build and dependency management.
- Code generation using template engines (based on velocity templates as seen in platform-gen).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Backend Services"
        pAdmin["platform-admin – Management Console"]
        pAPI["platform-api – REST API for Mini-Programs"]
        pSchedule["platform-schedule – Scheduled Tasks"]
        pCommon["platform-common – Common Utilities & Cross Cutting Concerns"]
        pGen["platform-gen – Code Generation Module"]
        tokenServ["TokenService (Payment Integration)"]
        wxPayServ["WeixinPayService (Payment Integration)"]
    end

    subgraph "Frontend Clients"
        uniMall["uni-mall – Uniapp Front-end Client"]
        wxMall["wx-mall – Native WeChat Mini-Program Client"]
    end

    subgraph "Infrastructure"
        mysql["MySQL Database"]
        redis["Redis Cache"]
        dbScript["Database Initialization Scripts"]
    end

    subgraph "External Integrations"
        externalServices["External Services (Weixin Pay, SMS, etc)"]
        j2cache["J2Cache Config"]
    end

    %% Frontend to API Interaction
    uniMall -->|"HTTPRequest"| pAPI
    wxMall  -->|"HTTPRequest"| pAPI

    %% Backend Modules Interacting with Common Services
    pAPI -->|"uses"| pCommon
    pAdmin -->|"uses"| pCommon

    %% Backend Modules Database and Cache Interactions
    pAPI -->|"DBQueries"| mysql
    pAdmin -->|"DBQueries"| mysql
    pSchedule -->|"DBTasks"| mysql

    pAPI -->|"CacheLookup"| redis
    pSchedule -->|"CacheInvalidation"| redis

    %% External Integrations from API and Common
    pAPI -->|"ExternalCalls"| externalServices
    pCommon -->|"PaymentAPI"| externalServices

    %% Code Generation Module Interactions
    pGen -->|"GeneratesCode"| pAdmin
    pGen -->|"GeneratesCode"| pAPI

    %% Payment Integration Components within Modules
    pAPI -->|"PaymentConfig"| tokenServ
    pCommon -->|"PaymentConfig"| wxPayServ
    tokenServ -->|"Integrates"| externalServices
    wxPayServ -->|"Integrates"| externalServices

    %% Database Initialization Script
    dbScript -->|"initializes"| mysql

    %% Cache configuration link from platform-admin to J2Cache Config
    pAdmin -->|"ConfigFile"| j2cache

    %% Click Events
    click pAdmin "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//platform-admin"
    click pAPI "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//platform-api"
    click pSchedule "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//platform-schedule"
    click pCommon "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//platform-common"
    click pGen "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//platform-gen"
    click uniMall "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//uni-mall"
    click wxMall "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//wx-mall"
    click dbScript "https://github.com/lipengjun92/platform-wxshop/tree/v1.0.0//_sql"
    click j2cache "https://github.com/lipengjun92/platform-wxshop/blob/v1.0.0//platform-admin/src/main/resources/j2cache.properties"
    click tokenServ "https://github.com/lipengjun92/platform-wxshop/blob/v1.0.0//platform-api/src/main/java/com/platform/service/TokenService.java"
    click wxPayServ "https://github.com/lipengjun92/platform-wxshop/blob/v1.0.0//platform-common/src/main/java/com/platform/service/WeixinPayService.java"

    %% Styles
    classDef backend fill:#ffe6e6,stroke:#333,stroke-width:2px;
    classDef frontend fill:#e6f7ff,stroke:#333,stroke-width:2px;
    classDef infra fill:#e6ffe6,stroke:#333,stroke-width:2px;
    classDef integration fill:#fff2cc,stroke:#333,stroke-width:2px;

    class pAdmin,pAPI,pSchedule,pCommon,pGen backend;
    class uniMall,wxMall frontend;
    class mysql,redis,dbScript infra;
    class tokenServ,wxPayServ,j2cache,externalServices integration;
```
