# flysail/mall architecture

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

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

## Overview

##### Main Components Overview

Frontend Layer:
- mall-admin-web (Vue.js based admin interface)
- mall-app-web (Customer-facing web interface)

Backend Services Layer:
- mall-admin (Admin management APIs)
- mall-portal (Customer-facing APIs)
- mall-search (Elasticsearch-based product search)
- mall-security (Security and authentication)
- mall-common (Shared utilities)
- mall-mbg (MyBatis code generation)

Infrastructure Layer:
- MySQL (Primary database)
- Redis (Caching)
- Elasticsearch (Search engine)
- RabbitMQ (Message queue)
- MongoDB (NoSQL storage)
- MinIO/OSS (Object storage)

##### Component Relationships

a) Frontend-Backend Integration:
- mall-admin-web → mall-admin (REST APIs)
- mall-app-web → mall-portal (REST APIs)

b) Service Dependencies:
- mall-admin → mall-security (Authentication)
- mall-portal → mall-security (Authentication)
- mall-admin → mall-common (Shared utilities)
- mall-portal → mall-common (Shared utilities)
- All services → mall-mbg (Database access)

c) Infrastructure Integration:
- Services → MySQL (Data persistence)
- Services → Redis (Caching)
- mall-search → Elasticsearch (Product search)
- mall-portal → RabbitMQ (Order processing queue)

##### Key Architectural Patterns
Patterns with distinct sections:

a) Security Layer:
- JWT Authentication
- Dynamic Security
- Role-based Access Control

b) Data Access Layer:
- MyBatis ORM
- Generated Mappers
- DAO Pattern

c) Service Layer:
- Business Logic
- Service Implementations
- DTOs

##### Cross-Cutting Concerns
As vertical layers:

- Logging (ELK Stack)
- Monitoring
- Caching
- Security
- Docker Containerization

##### Additional Elements

Symbols for:
- Load balancers
- API gateways
- Cache layers
- Message queues
- Database clusters

Annotations for:
- Technology versions
- Communication protocols
- Security boundaries
- Scalability points

##### Deployment View
A separate section showing:

- Docker containers
- Nginx reverse proxy
- Service discovery
- Load balancing

Remember to show both synchronous (REST) and asynchronous (Message Queue) communication patterns, and indicate where caching and security boundaries exist.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef infrastructure fill:#f1c40f,stroke:#f39c12,color:black
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef utility fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Frontend Layer
    subgraph Frontend
        AdminWeb["Mall Admin Web\n(Vue.js)"]:::frontend
        AppWeb["Mall App Web\n(Customer UI)"]:::frontend
    end

    %% Backend Services Layer
    subgraph Services
        Admin["Admin Service"]:::backend
        Portal["Portal Service"]:::backend
        Search["Search Service"]:::backend
        Security["Security Framework"]:::backend
        Common["Common Utilities"]:::utility
        MBG["MyBatis Generator"]:::utility
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        MySQL[(MySQL)]:::infrastructure
        Redis[(Redis)]:::infrastructure
        ES[(Elasticsearch)]:::infrastructure
        RMQ[("RabbitMQ")]:::infrastructure
        MongoDB[(MongoDB)]:::infrastructure
        MinIO["MinIO/OSS"]:::infrastructure
    end

    %% Cross-cutting Concerns
    subgraph CrossCutting
        JWT["JWT Auth"]:::security
        DynamicSec["Dynamic Security"]:::security
        Logging["ELK Logging"]:::utility
        Docker["Docker"]:::utility
    end

    %% Relationships
    AdminWeb --> Admin
    AppWeb --> Portal
    Admin --> Security
    Portal --> Security
    Admin & Portal --> Common
    Admin & Portal & Search --> MBG
    Search --> ES
    Portal --> RMQ
    Admin & Portal --> MySQL
    Admin & Portal --> Redis
    Security --> JWT
    Security --> DynamicSec

    %% Click events for component mapping
    click Admin "https://github.com/flysail/mall/tree/master/mall-admin"
    click Portal "https://github.com/flysail/mall/tree/master/mall-portal"
    click Search "https://github.com/flysail/mall/tree/master/mall-search"
    click Security "https://github.com/flysail/mall/tree/master/mall-security"
    click Common "https://github.com/flysail/mall/tree/master/mall-common"
    click MBG "https://github.com/flysail/mall/tree/master/mall-mbg"
    click Docker "https://github.com/flysail/mall/tree/master/document/docker"
    click Logging "https://github.com/flysail/mall/tree/master/document/elk"
    click JWT "https://github.com/flysail/mall/blob/master/mall-security/src/main/java/com/macro/mall/security/util/JwtTokenUtil.java"
    click DynamicSec "https://github.com/flysail/mall/blob/master/mall-security/src/main/java/com/macro/mall/security/component/DynamicSecurityService.java"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend"]:::frontend
        Backend_L["Backend"]:::backend
        Infra_L["Infrastructure"]:::infrastructure
        Security_L["Security"]:::security
        Utility_L["Utility"]:::utility
    end
```
