# phunguyen-byte/lilishop architecture

> Architecture diagram of the GitHub repository phunguyen-byte/lilishop, 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/phunguyen-byte/lilishop
- Repository: https://github.com/phunguyen-byte/lilishop

## Overview

The Lilishop project is a full‐featured e-commerce “mall” system offering multiple frontends (buyer/PC, seller/store, platform manager/admin, mobile app, and even an IM service) and a rich backend with a modular architecture. In other words, it is not a single monolithic application but a distributed collection of RESTful API services and consumers—with a shared framework library—that cover most aspects of an e-commerce platform, from goods and orders to promotions, payments, messaging, and scheduling.

##### Major layers and components
- Frontend Clients:
– Buyer/PC Web Interface (mall storefront)
– Seller Dashboard (store management)
– Platform Manager/Admin (back-office)
– Mobile App/uniapp client (also supporting mini programs)
– IM/Chat clients (websocket based)
- API Services:
– Separate modules like “buyer-api”, “manager-api”, “seller-api”, “im-api” and “admin” show that each business role or domain (buyer, seller, admin/manager, IM) has its own dedicated service.
- Shared Modules and Framework:
– The “common-api” and the extensive “framework” directory contain business domain modules (goods, orders, promotions, store management, payment, logistics, analytics, etc.). These represent core business logic and shared libraries.
- Asynchronous/Background Components:
– “consumer” module: Dedicated event consumers to process asynchronous operations (e.g. order events, notifications, status changes).
– “xxl-job” directory, which provides the scheduled task engine for timed and delayed jobs.
- Infrastructure & External Systems:
– The “DB” directory with SQL scripts indicates a central relational database (MySQL) for persisting application data.
– Caches (Redis + MongoDB) and a search engine (Elasticsearch) are used, as mentioned in the README.
– Message broker (RocketMQ) is evident from both the file names and the messaging modules under “rocketmq” and “trigger” directories.
– Additional support components include Docker for containerization, Nginx for load balancing, and OSS for static resource storage.
– Security (JWT, Spring Security), logging (Log4j/Logback), and database connection pooling (Druid) form part of the cross-cutting concerns.

##### Relationships and interactions
– Buyer API (buyer-api)
– Seller API (seller-api)
– Manager API (manager-api)
– Admin Service (admin)
– IM API (im-api)
- That the “common-api” and “framework” modules are used by many of these services to provide common business logic.
- A dedicated “Consumer” component (and optionally a “Message Queue” component) – illustrating that asynchronous events (like order updates, promotions, notifications) flow from API services into RocketMQ and are processed by the consumer module.
- “xxl-job” scheduler as a separate component that triggers periodic jobs such as statistics updates or batch processes.
- Central “Database” (MySQL) that all services interact with for CRUD operations.
- Additional external systems such as “Cache” layers (Redis/MongoDB), “Search Engine” (Elasticsearch), and “OSS” for static resources.
- Finally, indicate integration with third-party services (SMS, payment gateways, and logistics providers).

##### Architectural patterns and design principles
- The design is based on a microservices—or at least a modular—architecture, with clear border separation between the API services that serve different client roles.
- Both synchronous RESTful calls (client to service) and asynchronous messaging (services to consumer via RocketMQ).
- That a “shared framework” layer supports cross-cutting features like security, token generation, caching strategies and distributed tasks.
- The frontends are completely decoupled from the backend services to facilitate a full “前后端分离” (front-end/back-end separation) architecture and distributed deployment.

##### Relevant technologies
- Backend: Spring Boot, Spring MVC, MyBatis-Plus, Spring Security, Druid, RocketMQ, and xxl-job for scheduling.
- Frontend: Vue.js with Vue Router/Vuex (for Manager and Seller dashboards) and uni-app for mobile.
- Infrastructure: MySQL, Redis, MongoDB, Elasticsearch, Docker, Nginx, OSS.
- Communication: RESTful APIs, JWT-based authentication, and asynchronous messaging.
- Additional modules: A robust business framework layer (“framework” directory) and consumer modules for handling business events.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Clients Layer
    subgraph "Clients"
        buyerClient["Buyer Web Interface"]:::client
        sellerClient["Seller Dashboard"]:::client
        platformClient["Platform Manager/Admin"]:::client
        mobileClient["Mobile App/uniapp"]:::client
        imClient["IM/Chat Clients"]:::client
    end

    %% API Services Layer
    subgraph "API Services"
        buyerApi["Buyer API"]:::api
        sellerApi["Seller API"]:::api
        managerApi["Manager API"]:::api
        adminService["Admin Service"]:::api
        imApi["IM API"]:::api
        commonApi["Common API"]:::shared
        frameworkMod["Framework"]:::shared
        messageConsumer["Consumer Module"]:::consumer
        scheduler["XXL-Job Scheduler"]:::scheduler
    end

    %% Infrastructure Layer
    subgraph "Infrastructure & External Systems"
        database["Database (MySQL)"]:::infrastructure
        cache["Cache (Redis/MongoDB)"]:::infrastructure
        search["Search Engine (Elasticsearch)"]:::infrastructure
        mq["Message Broker (RocketMQ)"]:::infrastructure
        oss["OSS (Static Resources)"]:::infrastructure
        thirdParty["Third-party Services (SMS,Payment,Logistics)"]:::infrastructure
    end

    %% Client to API connections
    buyerClient -->|"calls"| buyerApi
    mobileClient -->|"calls"| buyerApi
    sellerClient -->|"calls"| sellerApi
    platformClient -->|"calls"| managerApi
    platformClient -->|"calls"| adminService
    imClient -->|"calls"| imApi

    %% API Services using Shared Modules
    buyerApi -->|"uses"| commonApi
    buyerApi -->|"uses"| frameworkMod
    sellerApi -->|"uses"| commonApi
    sellerApi -->|"uses"| frameworkMod
    managerApi -->|"uses"| commonApi
    managerApi -->|"uses"| frameworkMod
    adminService -->|"uses"| commonApi
    adminService -->|"uses"| frameworkMod
    imApi -->|"uses"| commonApi
    imApi -->|"uses"| frameworkMod

    %% API Services interacting with Database
    buyerApi -->|"CRUD"| database
    sellerApi -->|"CRUD"| database
    managerApi -->|"CRUD"| database
    adminService -->|"CRUD"| database
    imApi -->|"CRUD"| database

    %% API Services sending events to Message Broker
    buyerApi -->|"sends"| mq
    sellerApi -->|"sends"| mq
    managerApi -->|"sends"| mq
    adminService -->|"sends"| mq
    imApi -->|"sends"| mq

    %% Message Broker to Consumer processing
    mq -->|"delivers"| messageConsumer
    messageConsumer -->|"updates"| database

    %% Scheduler tasks interaction with Database
    scheduler -->|"triggers"| database

    %% Infrastructure external interactions (general associations)
    oss ---|"serves"| buyerApi
    oss ---|"serves"| sellerApi
    oss ---|"serves"| managerApi
    oss ---|"serves"| adminService
    oss ---|"serves"| imApi
    cache ---|"caches"| database
    search ---|"indexes"| database
    thirdParty ---|"integrates"| buyerApi
    thirdParty ---|"integrates"| sellerApi
    thirdParty ---|"integrates"| managerApi
    thirdParty ---|"integrates"| adminService
    thirdParty ---|"integrates"| imApi

    %% Click Events for Component Mapping
    click buyerApi "https://github.com/phunguyen-byte/lilishop/tree/master/buyer-api"
    click sellerApi "https://github.com/phunguyen-byte/lilishop/tree/master/seller-api"
    click managerApi "https://github.com/phunguyen-byte/lilishop/tree/master/manager-api"
    click adminService "https://github.com/phunguyen-byte/lilishop/tree/master/admin"
    click imApi "https://github.com/phunguyen-byte/lilishop/tree/master/im-api"
    click commonApi "https://github.com/phunguyen-byte/lilishop/tree/master/common-api"
    click frameworkMod "https://github.com/phunguyen-byte/lilishop/tree/master/framework"
    click messageConsumer "https://github.com/phunguyen-byte/lilishop/tree/master/consumer"
    click scheduler "https://github.com/phunguyen-byte/lilishop/tree/master/xxl-job"
    click database "https://github.com/phunguyen-byte/lilishop/tree/master/DB"

    %% Styles
    classDef client fill:#F39C12,stroke:#000,stroke-width:2px;
    classDef api fill:#3498DB,stroke:#000,stroke-width:2px;
    classDef shared fill:#9B59B6,stroke:#000,stroke-width:2px;
    classDef consumer fill:#E67E22,stroke:#000,stroke-width:2px;
    classDef scheduler fill:#16A085,stroke:#000,stroke-width:2px;
    classDef infrastructure fill:#2ECC71,stroke:#000,stroke-width:2px;
```
