# diweikang2019/smart-admin architecture

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

- Interactive diagram: https://gitdiagram.com/diweikang2019/smart-admin
- Repository: https://github.com/diweikang2019/smart-admin

## Overview

##### Main Components
- Back End: The back-end code is located in the “smart-admin-api-java8-springboot2” directory. It is split into at least two Maven modules:
– sa-admin: Contains business modules for system functionalities (e.g., business modules for category, goods, OA (office automation), system modules like login, employee, menu, and role management).
– sa-base: This holds the common utilities, shared configuration, common exception handling, and core aspects (such as JSON conversion, swagger support, security configurations, code generator support, etc.).
- Database: Represent the persistence layer where Mybatis-Plus is used to map domain objects, and mappers are located in “src/main/resources/mapper”. The database is central to storing business data and system parameters.
- External/Supporting Services: Illustrate integration with additional services like Sa-Token (for security/session management), encryption (API encrypt/decrypt), and logging or monitoring (operate log, login log, heartbeat) systems. Also, show configuration profiles (dev, pre, test, prod) that are managed through different YAML and XML configuration files.

##### Internal Layered Architecture in the Back End
- Controller Layer: In each module (in sa-admin, for example) the REST controllers (such as CategoryController, GoodsController, and numerous system management controllers) receive HTTP requests.
- Service Layer: This layer houses business logic; it is responsible for handling operations of both business modules and support modules (data scope, file management, etc.).
- Manager Layer: Note that the project practices a “four-layer architecture” – Manager classes (such as EmployeeManager, RoleEmployeeManager) sit between the service and DAO layers to manage complex business logic and transactions.
- Data Access Layer (DAO): The DAOs interact directly with database mapper XMLs and Mybatis configuration files.

##### Cross-Cutting and Configuration Components
- Configuration and Environment Support: Emphasize the multiple configuration profiles (development, pre, prod, and test) and common shared configurations in the sa-base module.
- Code Generation and Support Utilities: The project also supports an online code generator that auto-generates controllers, DAOs, and configuration templates (look at the code-generator packages and corresponding templates under resources).

##### Data Flow and Dependencies
- Within the back end, indicate that controllers call services, which in turn delegate to managers and then to DAOs for persistence.
- That DAO operations rely on mapper XMLs and Mybatis (pointing to the “mapper” folders in resources).

##### Notate Key Technologies
- That the back end is built in Java8 or Java17, using SpringBoot2/3, with Sa-Token for security and Mybatis-Plus for ORM.
- The front end is built with Vue3 and Vite5 plus integrations with Ant Design Vue and Pinia.

## Diagram (Mermaid)

```mermaid
graph TD
    FE["Front End - Vue3/Vite5, Pinia, Ant Design Vue"]:::frontend

    %% Front End calls Back End Controllers via REST API
    FE -->|"REST_API"| Controller

    subgraph "Back End - Admin Module (sa-admin)"
        Controller["Controller Layer (REST Controllers)"]:::backendLayer
        Service["Service Layer"]:::backendLayer
        Manager["Manager Layer"]:::backendLayer
        DAO["DAO Layer"]:::backendLayer
        Controller -->|"calls"| Service
        Service -->|"delegates"| Manager
        Manager -->|"invokes"| DAO
        DAO -->|"queries"| DB["Database (Mybatis-Plus & Mappers)"]:::database
        Controller -->|"reads"| Config["Multi-Environment Configuration"]:::config
    end

    subgraph "Back End - Base Module (sa-base)"
        TokenConfig["Security (TokenConfig)"]:::backendUtil
        APIEncrypt["API Encryption Support"]:::backendUtil
        CodeGen["Code Generation Support"]:::backendUtil
    end

    %% Controller utilizes security features from Base Module
    Controller -->|"security"| TokenConfig
    Controller -->|"encryption"| APIEncrypt

    %% Click Events
    click FE "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-web-javascript"
    click Controller "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-api-java8-springboot2/sa/admin/src/main/java/net/lab1024/sa/admin/module/business"
    click DB "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-api-java8-springboot2/sa-admin/src/main/resources/mapper"
    click Config "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-api-java8-springboot2/sa-admin/src/main/resources/dev, pre, prod, test"
    click TokenConfig "https://github.com/diweikang2019/smart-admin/blob/master/smart-admin-api-java8-springboot2/sa-base/src/main/java/net/lab1024/sa/base/config/TokenConfig.java"
    click APIEncrypt "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-api-java8-springboot2/sa/base/src/main/java/net/lab1024/sa/base/module/support/apiencrypt"
    click CodeGen "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-api-java8-springboot2/sa-base/src/main/resources/code-generator-template"
    click Controller "https://github.com/diweikang2019/smart-admin/tree/master/smart-admin-api-java8-springboot2/sa-admin"

    %% Styling Classes
    classDef frontend fill:#CDE,stroke:#333,stroke-width:2px;
    classDef backendLayer fill:#E1FFC8,stroke:#333,stroke-width:2px;
    classDef backendUtil fill:#FFDAB9,stroke:#333,stroke-width:2px;
    classDef database fill:#F4CCCC,stroke:#333,stroke-width:2px;
    classDef config fill:#D9EAD3,stroke:#333,stroke-width:2px;
```
