# LLM Guard Server > 基于 Spring Cloud 微服务架构的 LLM 安全防护系统 ## 项目简介 LLM Guard Server 是一个面向大语言模型应用的安全防护系统,采用 Spring Cloud 微服务架构构建。系统提供完善的用户管理、权限控制、安全防护、日志审计等功能,旨在为企业级 LLM 应用提供全方位的安全保障。 ## 技术栈 | 技术 | 版本 | 说明 | |------|------|------| | Java | 21 | 编程语言 | | Spring Boot | 3.5.8 | 应用框架 | | Spring Cloud | 2025.0.0 | 微服务框架 | | Spring Cloud Alibaba | 2025.0.0.0 | 阿里微服务组件 | | Nacos | 2.x | 服务注册与配置中心 | | Sentinel | 1.x | 熔断限流 | | MyBatis-Plus | 3.5.7 | ORM 框架 | | Redis | - | 缓存 | | DM 达梦数据库 | 8.1.3.62 | 关系型数据库 | | Maven | - | 项目构建 | ## 系统架构 ``` ┌─────────────────────────────────────────────────────────────────┐ │ 客户端请求 │ └─────────────────────────────┬───────────────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ llm-guard-gateway (6201) │ │ 网关服务:路由、认证、限流、过滤 │ └─────────────────────────────┬───────────────────────────────────┘ │ ┌───────────────┴───────────────┐ ▼ ▼ ┌─────────────────────────┐ ┌─────────────────────────┐ │ llm-guard-auth │ │ llm-guard-modules │ │ 认证服务 │ │ 业务模块 │ ├─────────────────────────┤ ├─────────────────────────┤ │ • 用户登录 │ │ • llm-guard-system │ │ • Token 签发 │ │ • llm-guard-biz │ │ • 权限认证 │ │ - 用户管理 │ └─────────────────────────┘ │ - 角色管理 │ │ - 菜单管理 │ │ - 部门管理 │ │ - 定时任务 │ │ - 日志审计 │ └─────────────────────────┘ │ ▼ ┌─────────────────────────────────────────────────────────────────┐ │ 基础设施层 │ ├──────────────┬──────────────┬──────────────┬───────────────────┤ │ Nacos │ Sentinel │ Redis │ DM Database │ │ 服务注册 │ 熔断限流 │ 缓存 │ 数据存储 │ │ 配置中心 │ │ │ │ └──────────────┴──────────────┴──────────────┴───────────────────┘ ``` ## 模块结构 ``` llm-guard-server/ ├── llm-guard-auth/ # 认证服务模块 │ └── 处理用户认证、授权和登录 ├── llm-guard-gateway/ # 网关服务模块 │ └── 路由、过滤、限流 ├── llm-guard-api/ # API 接口模块 │ └── llm-guard-api-system/ # 系统接口定义 ├── llm-guard-common/ # 公共模块 │ ├── llm-guard-common-core/ # 核心公共组件 │ ├── llm-guard-common-security/ # 安全组件 │ ├── llm-guard-common-redis/ # Redis 缓存 │ ├── llm-guard-common-log/ # 日志组件 │ ├── llm-guard-common-datasource/ # 数据源配置 │ ├── llm-guard-common-datascope/ # 数据权限 │ ├── llm-guard-common-sensitive/ # 数据脱敏 │ ├── llm-guard-common-mybatisplus/ # MyBatis-Plus 配置 │ └── llm-guard-common-swagger/ # API 文档 ├── llm-guard-modules/ # 业务模块 │ ├── llm-guard-system/ # 系统管理模块 │ └── llm-guard-biz/ # 业务模块 ├── doc/ # 项目文档 ├── pom.xml # Maven 主配置 └── README.md # 项目说明 ``` ## 核心特性 - **微服务架构**: 基于 Spring Cloud 的分布式架构 - **统一认证**: JWT Token 无状态认证 - **权限控制**: 基于 RBAC 的权限管理 - **数据脱敏**: 敏感信息自动脱敏 - **操作审计**: 完整的操作日志记录 - **熔断限流**: Sentinel 服务保护 - **配置中心**: Nacos 统一配置管理 - **服务注册**: Nacos 服务发现 - **缓存支持**: Redis 高性能缓存 - **接口文档**: Swagger 自动生成 ## 开发指南 ### 环境要求 - JDK 21+ - Maven 3.6+ - Nacos 2.x - Redis 5.x+ - DM Database 8.x ### 构建项目 ```bash mvn clean install ``` ### 启动服务 1. 启动 Nacos 服务 2. 启动 Redis 服务 3. 启动 Gateway 网关服务 4. 启动 Auth 认证服务 5. 启动 System 业务服务 ## 许可证 Copyright © 2024 LLM Guard Server