docs: 重构API文档和系统架构文档,统一技术栈规范docs(architecture): 更新系统架构设计文档
- 重新组织文档结构,优化标题层级 - 添加系统架构图,直观展示系统组成- 补充前端架构、后端架构、数据架构等详细内容 - 更新安全架构、部署架构、性能优化策略等章节 - 增加扩展性设计和高可用设计章节 - 总结系统架构设计特点和优势
This commit is contained in:
@@ -1,132 +1,100 @@
|
||||
# 后端Java微服务架构
|
||||
# xlxumu Java后端项目
|
||||
|
||||
## 项目结构
|
||||
|
||||
```
|
||||
backend-java/
|
||||
├── pom.xml # 根项目POM文件
|
||||
├── api/ # API网关
|
||||
├── gateway/ # 网关服务
|
||||
├── registry/ # 服务注册与发现
|
||||
├── config-server/ # 配置中心
|
||||
├── services/ # 业务服务模块
|
||||
│ ├── farming-service/ # 养殖管理服务
|
||||
│ ├── finance-service/ # 金融服务
|
||||
│ ├── government-service/ # 政府监管服务
|
||||
│ ├── trade-service/ # 交易管理服务
|
||||
│ ├── mall-service/ # 商城管理服务
|
||||
│ ├── data-platform-service/ # 数据中台服务
|
||||
│ ├── ai-service/ # AI能力服务
|
||||
│ └── user-center-service/ # 用户中心服务
|
||||
├── common/ # 公共模块
|
||||
├── docs/ # 文档
|
||||
└── scripts/ # 脚本
|
||||
├── api/ # API定义
|
||||
├── common/ # 公共模块
|
||||
├── config-server/ # 配置服务器
|
||||
├── docs/ # 文档
|
||||
├── gateway/ # 网关服务
|
||||
├── registry/ # 服务注册中心
|
||||
├── scripts/ # 脚本
|
||||
└── services/ # 微服务
|
||||
├── ai-service/ # AI服务
|
||||
├── data-platform-service/ # 数据平台服务
|
||||
├── farming-service/ # 农业管理服务 (端口: 8081)
|
||||
├── finance-service/ # 金融服务
|
||||
├── government-service/ # 政府监管服务
|
||||
├── mall-service/ # 商城服务
|
||||
├── trade-service/ # 交易服务
|
||||
└── user-center-service/ # 用户中心服务 (端口: 8082)
|
||||
```
|
||||
|
||||
## 技术栈
|
||||
|
||||
- **核心框架**: Spring Boot 2.7.5 + Spring Cloud 2021.0.5
|
||||
- **编程语言**: Java 11
|
||||
- **构建工具**: Maven 3.8+
|
||||
- **数据库**: MySQL 8.0
|
||||
- **缓存**: Redis
|
||||
- **消息队列**: RabbitMQ
|
||||
- **API文档**: Swagger/OpenAPI 3.0
|
||||
- **监控**: Spring Boot Admin + Micrometer
|
||||
- **安全**: Spring Security + OAuth2 + JWT
|
||||
- **配置中心**: Spring Cloud Config
|
||||
- **服务发现**: Spring Cloud Eureka
|
||||
- **负载均衡**: Spring Cloud LoadBalancer
|
||||
- **熔断器**: Resilience4j
|
||||
- **链路追踪**: Spring Cloud Sleuth + Zipkin
|
||||
- **容器化**: Docker
|
||||
- **编排**: Kubernetes
|
||||
- Java 8+
|
||||
- Spring Boot 2.7.x
|
||||
- Spring Cloud 2021.x
|
||||
- Maven 3.8.x
|
||||
- MySQL 8.0
|
||||
|
||||
## 服务说明
|
||||
## 环境要求
|
||||
|
||||
### 1. farming-service (养殖管理服务)
|
||||
负责养殖相关的业务逻辑,包括:
|
||||
- 牛只信息管理
|
||||
- 饲养记录管理
|
||||
- 疫苗接种记录
|
||||
- 健康状况监控
|
||||
1. JDK 8或更高版本
|
||||
2. Maven 3.8或更高版本
|
||||
3. MySQL 8.0
|
||||
|
||||
### 2. finance-service (金融服务)
|
||||
负责金融相关的业务逻辑,包括:
|
||||
- 贷款申请与审批
|
||||
- 保险购买与理赔
|
||||
- 支付处理
|
||||
- 财务报表生成
|
||||
## 快速开始
|
||||
|
||||
### 3. government-service (政府监管服务)
|
||||
负责政府监管相关的业务逻辑,包括:
|
||||
- 政策发布与推送
|
||||
- 监管数据上报
|
||||
- 合规性检查
|
||||
- 数据统计分析
|
||||
|
||||
### 4. trade-service (交易管理服务)
|
||||
负责交易相关的业务逻辑,包括:
|
||||
- 活牛交易撮合
|
||||
- 价格信息发布
|
||||
- 交易合同管理
|
||||
- 物流跟踪
|
||||
|
||||
### 5. mall-service (商城管理服务)
|
||||
负责商城相关的业务逻辑,包括:
|
||||
- 商品管理
|
||||
- 订单处理
|
||||
- 库存管理
|
||||
- 用户评价
|
||||
|
||||
### 6. data-platform-service (数据中台服务)
|
||||
负责数据平台相关的业务逻辑,包括:
|
||||
- 数据采集与清洗
|
||||
- 数据仓库构建
|
||||
- 数据分析与挖掘
|
||||
- 报表生成
|
||||
|
||||
### 7. ai-service (AI能力服务)
|
||||
负责AI相关的业务逻辑,包括:
|
||||
- 图像识别(牛只识别、健康状况识别)
|
||||
- 预测分析(市场价格预测、疫病预测)
|
||||
- 智能推荐
|
||||
- 自然语言处理
|
||||
|
||||
### 8. user-center-service (用户中心服务)
|
||||
负责用户管理相关的业务逻辑,包括:
|
||||
- 用户注册与登录
|
||||
- 权限管理
|
||||
- 个人信息管理
|
||||
- 消息通知
|
||||
|
||||
## 开发规范
|
||||
|
||||
1. **代码规范**: 遵循阿里巴巴Java开发手册
|
||||
2. **API设计**: 遵循RESTful API设计规范
|
||||
3. **数据库设计**: 遵循数据库设计三范式
|
||||
4. **日志规范**: 使用SLF4J + Logback记录日志
|
||||
5. **异常处理**: 统一异常处理机制
|
||||
6. **测试覆盖**: 单元测试覆盖率不低于80%
|
||||
7. **文档规范**: 使用Swagger生成API文档
|
||||
|
||||
## 部署说明
|
||||
|
||||
1. **本地开发**: 使用Docker Compose启动依赖服务
|
||||
2. **测试环境**: 使用Kubernetes部署
|
||||
3. **生产环境**: 使用Kubernetes部署,配合Prometheus监控
|
||||
|
||||
## 构建与运行
|
||||
### 1. 安装依赖
|
||||
|
||||
```bash
|
||||
# 构建所有服务
|
||||
# 在backend-java根目录下执行
|
||||
mvn clean install
|
||||
```
|
||||
|
||||
# 运行单个服务
|
||||
### 2. 配置数据库
|
||||
|
||||
确保MySQL服务正在运行,并创建相应的数据库:
|
||||
|
||||
```sql
|
||||
CREATE DATABASE IF NOT EXISTS xlxumu_farming;
|
||||
CREATE DATABASE IF NOT EXISTS xlxumu_user;
|
||||
```
|
||||
|
||||
### 3. 运行服务
|
||||
|
||||
#### 运行farming-service
|
||||
|
||||
```bash
|
||||
cd services/farming-service
|
||||
mvn spring-boot:run
|
||||
```
|
||||
|
||||
## 配置说明
|
||||
服务将在 http://localhost:8081 启动
|
||||
|
||||
所有服务的配置文件位于config-server模块中,通过Spring Cloud Config进行统一管理。
|
||||
#### 运行user-center-service
|
||||
|
||||
```bash
|
||||
cd services/user-center-service
|
||||
mvn spring-boot:run
|
||||
```
|
||||
|
||||
服务将在 http://localhost:8082 启动
|
||||
|
||||
## 服务端口分配
|
||||
|
||||
| 服务名称 | 端口 |
|
||||
|---------|------|
|
||||
| farming-service | 8081 |
|
||||
| user-center-service | 8082 |
|
||||
|
||||
## 开发指南
|
||||
|
||||
1. 所有微服务都继承自根pom.xml
|
||||
2. 每个服务都有独立的数据库
|
||||
3. 使用Spring Boot Actuator进行健康检查
|
||||
4. 使用Spring Cloud Gateway作为API网关
|
||||
|
||||
## 构建和部署
|
||||
|
||||
```bash
|
||||
# 构建所有服务
|
||||
mvn clean package
|
||||
|
||||
# 构建单个服务
|
||||
cd services/farming-service
|
||||
mvn clean package
|
||||
```
|
||||
@@ -9,6 +9,7 @@
|
||||
<groupId>com.xlxumu</groupId>
|
||||
<artifactId>backend-java</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>farming-service</artifactId>
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xlxumu.farm;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class FarmingServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FarmingServiceApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
server.port=8081
|
||||
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/xlxumu_farming?useSSL=false&serverTimezone=UTC
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
@@ -0,0 +1,10 @@
|
||||
server.port=8081
|
||||
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/xlxumu_farming?useSSL=false&serverTimezone=UTC
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
||||
artifactId=farming-service
|
||||
groupId=com.xlxumu
|
||||
version=1.0.0
|
||||
@@ -0,0 +1 @@
|
||||
com/xlxumu/farm/FarmingServiceApplication.class
|
||||
@@ -0,0 +1 @@
|
||||
/Users/ainongkeji/code/vue/xlxumu/backend-java/services/farming-service/src/main/java/com/xlxumu/farm/FarmingServiceApplication.java
|
||||
44
backend-java/services/user-center-service/pom.xml
Normal file
44
backend-java/services/user-center-service/pom.xml
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.xlxumu</groupId>
|
||||
<artifactId>backend-java</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>user-center-service</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.xlxumu.user;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class UserCenterApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(UserCenterApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
server.port=8082
|
||||
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/xlxumu_user?useSSL=false&serverTimezone=UTC
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
@@ -0,0 +1,10 @@
|
||||
server.port=8082
|
||||
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/xlxumu_user?useSSL=false&serverTimezone=UTC
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=update
|
||||
spring.jpa.show-sql=true
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
com/xlxumu/user/UserCenterApplication.class
|
||||
@@ -0,0 +1 @@
|
||||
/Users/ainongkeji/code/vue/xlxumu/backend-java/services/user-center-service/src/main/java/com/xlxumu/user/UserCenterApplication.java
|
||||
Reference in New Issue
Block a user