Architectural Overview
Relevant source files
The following files were used as context for generating this wiki page:The zheng project is a comprehensive, multi-module, distributed enterprise application built using Java and the Maven build system. Its architecture is based on a collection of distinct, interconnected subsystems, each responsible for a specific business domain such as Content Management (CMS), User Permissions (UPMS), Object Storage (OSS), and Payments. This modular design promotes separation of concerns and allows for independent development, deployment, and scaling of each component.
The system heavily utilizes a service-oriented architecture, with modules communicating via Remote Procedure Calls (RPC), likely using Dubbo. The front-end is composed of server-side rendered web applications, while administration interfaces provide management capabilities for each subsystem. The overall structure is designed for building complex, large-scale web platforms.
Project Module Structure
The project is organized as a parent Maven project (zheng) that aggregates numerous sub-modules. Each sub-module represents a major functional area of the system.
The following diagram illustrates the high-level module organization defined in the root pom.xml.
This diagram shows the top-level modules within the zheng project.
Sources: pom.xml:20-33
Key Modules
| Module | Description |
|---|---|
zheng-admin | A common administration module, likely providing a base template or functionality for other admin modules. |
zheng-common | Contains shared code, utility classes, and common dependencies for the entire project. |
zheng-upms | User Permission Management System. Manages users, roles, and permissions across the platform. |
zheng-cms | Content Management System. Manages articles, topics, blogs, and other content. |
zheng-oss | Object Storage Service. Provides functionality for file uploads and storage. |
zheng-pay | Payment System. Handles payment-related logic. |
zheng-ucenter | User Center. Manages user profiles and related data. |
zheng-api | A module likely exposing a consolidated API for external clients. |
zheng-ui | Contains the front-end HTML, CSS, and JavaScript files, rendered by the web modules. |
Sources: pom.xml:20-33, zheng-ui/zheng-cms-web/index.html
Core Technology Stack
The zheng-common module defines the core set of technologies and libraries used throughout the project. This ensures consistency and manages versions centrally.
| Technology | Library/Component | Version | Purpose |
|---|---|---|---|
| Spring Framework | spring-context, spring-webmvc, spring-jdbc | 4.3.20.RELEASE | Core application framework, MVC, data access. |
| Security | shiro-core, shiro-web, shiro-spring | 1.3.2 | Authentication and Authorization. |
| Database | mybatis, mybatis-spring, pagehelper | 3.4.2, 1.3.1, 5.0.1 | Persistence framework and pagination. |
| RPC | dubbo | 2.5.6 | Remote procedure call framework for service communication. |
| Caching | ehcache, redis.clients.jedis | 2.10.0, 2.9.0 | In-memory and distributed caching. |
| Session | spring-session-data-redis | 1.3.0.RELEASE | Manages user sessions in Redis for distributed environments. |
| Messaging | activemq-core, rocketmq-client | 5.7.0, 3.6.2.Final | Asynchronous communication and message queuing. |
| Templating | thymeleaf-spring4 | 3.0.3.RELEASE | Server-side template engine for rendering UI. |
Sources: zheng-common/pom.xml:23-228, zheng-cms/zheng-cms-web/pom.xml:36-40
Subsystem Architecture: zheng-cms Example
The zheng-cms module is a representative example of the architectural pattern used across the project. It is itself a multi-module project with a clear separation of layers.
This diagram shows the internal module structure of the zheng-cms subsystem.
Sources: zheng-cms/pom.xml:22-31, zheng-cms/zheng-cms-admin/pom.xml:21-25, zheng-cms/zheng-cms-web/pom.xml:18-22
zheng-cms Components
zheng-cms-rpc-api: A JAR file containing the service interfaces (APIs). This module is shared with any client module that needs to interact with the CMS services.
Sources: zheng-cms/zheng-cms-web/pom.xml:18-22zheng-cms-rpc-service: The implementation of the RPC APIs. This is where the business logic resides. It depends on thezheng-cms-daomodule to interact with the database.
Sources: zheng-cms/pom.xml:24zheng-cms-dao: The Data Access Object layer, responsible for database operations using MyBatis. It depends onzheng-cms-common.
Sources: zheng-cms/zheng-cms-dao/pom.xml:21-23zheng-cms-common: Contains common classes and constants specific to the CMS module.
Sources: zheng-cms/pom.xml:29zheng-cms-admin: A WAR file representing the administration web application. It allows staff to manage content. It depends onzheng-cms-rpc-apito call backend services andzheng-upms-clientfor authentication/authorization.
Sources: zheng-cms/zheng-cms-admin/pom.xml:21-33zheng-cms-web: A WAR file for the public-facing website. It consumes services fromzheng-cms-rpc-apito display content to users. It also includes dependencies fortbschedule(for scheduled tasks) androcketmq(for message queuing).
Sources: zheng-cms/zheng-cms-web/pom.xml:18-40zheng-cms-job: A WAR file for running scheduled jobs related to the CMS.
Sources: zheng-cms/pom.xml:26, zheng-cms/zheng-cms-job/pom.xmlzheng-cms-search: A WAR file likely dedicated to handling search functionality, possibly integrating with a search engine like Elasticsearch or Solr.
Sources: zheng-cms/pom.xml:27, zheng-cms/zheng-cms-search/pom.xml
This layered and modular approach is replicated in other major subsystems like zheng-upms, zheng-oss, and zheng-pay.
Deployment and Execution
Each web application module (packaged as a .war) is configured to run on an embedded Jetty server, each on a distinct port. This facilitates local development and microservice-style deployment.
The following table lists the default ports for some of the key web modules.
| Module | Default Port |
|---|---|
zheng-upms-server | 1111 |
zheng-cms-search | 2221 |
zheng-cms-admin | 2222 |
zheng-cms-job | 2223 |
zheng-cms-web | 2224 |
zheng-pay-admin | 3331 |
zheng-wechat-mp-admin | 5551 |
zheng-oss-admin | 7772 |
Sources: zheng-upms/zheng-upms-server/pom.xml:83-85, zheng-cms/zheng-cms-admin/pom.xml:73-75, zheng-cms/zheng-cms-web/pom.xml:76-78, zheng-oss/zheng-oss-admin/pom.xml:80-82, zheng-pay/zheng-pay-admin/pom.xml:78-80, zheng-cms/zheng-cms-job/pom.xml:73-75, zheng-cms/zheng-cms-search/pom.xml:75-77, zheng-wechat/zheng-wechat-mp/zheng-wechat-mp-admin/pom.xml:78-80
UI Layer
The user interface is handled by the zheng-ui module, which contains static assets and Thymeleaf templates. These templates are rendered by the various web application modules (e.g., zheng-cms-web). The HTML files show dynamic content rendering using Thymeleaf's th:* attributes, which pull data from the model provided by the Spring MVC controllers.
For example, the main page of the CMS web application displays a list of systems and categories.
<dl>
<dt>所有系统</dt>
<dd th:each="system : ${systems}" th:text="${system.name}">系统名称</dd>
</dl>
<dl>
<dt>所有类目</dt>
<dd th:each="category : ${categories}"><a href="news/category/index.html" th:href="@{'/category/' + ${category.alias}}" th:text="${category.name}">类目</a></dd>
</dl>
This snippet shows how Thymeleaf is used to dynamically generate lists from backend data.
Sources: zheng-ui/zheng-cms-web/index.html:81-88
This architecture separates the presentation logic (HTML/CSS/JS) in zheng-ui from the backend web controllers in modules like zheng-cms-web, even though they are ultimately packaged together.