- 新增 hzhub-portal-employee 员工门户前端项目(基于 Vue3 + Element Plus) - 后端登录接口增加返回 nickName 字段 - 移除 KnowledgeInfoController 的 @SaCheckPermission 注解 - 删除 hzhub-portal-company 旧门户项目 - 更新项目文档和架构说明 - 添加后台运行管理脚本(start-all.sh / status-all.sh / stop-all.sh) - 更新 docker-compose 配置 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
10 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
HZHub (汇智中台) is an enterprise-level business platform built on HZHub-AI, integrating AI capabilities with ERP data adaptation. It consists of multiple frontend portals, a backend AI service, an ERP service, and a gateway, orchestrated via Docker Compose.
Commands
Docker Deployment (Production-like)
# Start all services (recommended for integration testing)
cd hzhub-deploy
docker-compose up -d
# View service status
docker-compose ps
# View logs
docker-compose logs -f hzhub-ai
docker-compose logs -f hzhub-admin
# Restart services
docker-compose restart hzhub-ai
# Stop all services
docker-compose down
Backend Development (Spring Boot)
# Run AI service locally (foreground)
cd hzhub-ai
mvn spring-boot:run -Dspring-boot.run.profiles=dev
# Run AI service locally (background)
cd hzhub-ai
./start.sh # Start service in background
./status.sh # Check service status
./logs.sh # View logs
./stop.sh # Stop service
./restart.sh # Restart service
# Build all modules
cd hzhub-ai
mvn clean package
# Build specific module
cd hzhub-ai/hzhub-modules/hzhub-chat
mvn clean package
# Run tests
mvn test
💡 Tip: For background service management, see SERVICE_MANAGEMENT.md
Frontend Development (Vue 3 + Vben Admin)
# Admin portal development
cd hzhub-admin
pnpm install # Install dependencies
pnpm dev # Start dev server (foreground)
./start.sh # Start dev server (background)
./status.sh # Check service status
./logs.sh # View logs
pnpm build # Build all packages
pnpm --filter=@vben/web-antd build:prod # Build admin frontend
# Employee portal development
cd hzhub-portal-employee
pnpm install
pnpm dev # Start dev server (foreground)
./start.sh # Start dev server (background)
./status.sh # Check service status
./logs.sh # View logs
# Dealer portal development
cd hzhub-portal-dealer
pnpm install
pnpm dev
💡 Tip: For background service management (start/stop/restart/status/logs), see SERVICE_MANAGEMENT.md
Architecture
Multi-Service Structure
┌─────────────────────────────────────────┐
│ Frontend Layer │
│ hzhub-admin | hzhub-portal-employee │
│ | hzhub-portal-dealer │
└────────────┬────────────────────────────┘
│
┌────────┴────────┐
│ hzhub-gateway │ (API Gateway - planned)
│ Spring Cloud │ Auth, routing, rate limiting
└────────┬────────┘
│
┌────────┴────────┬────────────┐
│ hzhub-ai │ hzhub-erp │
│ (AI Service) │ (Planned) │
│ Spring Boot │ JDBC to │
│ 3.5.8 │ SQL Server│
└─────────────────┴────────────┘
Backend Module Organization
hzhub-ai is organized as a multi-module Maven project:
- hzhub-admin: Main application entry point (
HZHubAIApplication.java), configuration files - hzhub-common: Shared utilities (core, redis, mybatis, security, satoken, oss, chat, etc.)
- hzhub-modules: Business modules
- hzhub-chat: Chat/AI conversation functionality
- hzhub-system: System management, users, roles, permissions
- hzhub-workflow: Workflow engine (Flowable-based)
- hzhub-aiflow: AI workflow orchestration
- hzhub-generator: Code generator
- hzhub-extend: Extensions (monitoring, job scheduling)
Frontend Architecture
hzhub-admin uses a monorepo structure with pnpm + turbo:
hzhub-admin/
├── apps/
│ └── web-antd/ # Main admin application (Ant Design Vue)
│ ├── src/
│ │ ├── api/ # API calls
│ │ ├── views/ # Page components
│ │ ├── router/ # Vue Router config
│ │ └── store/ # Pinia stores
│ └── package.json
├── packages/ # Shared packages
└── package.json # Root monorepo config
Portal applications (hzhub-portal-employee, hzhub-portal-dealer) are Vue 3 apps with:
- Composition API (
<script setup>) - Pinia state management with persistence
- Element Plus UI components
- hook-fetch for HTTP requests with SSE support
Key Technologies
Backend (hzhub-ai):
- Spring Boot 3.5.8, Spring AI 2.0
- LangChain4j for AI/LLM integration
- Sa-Token for authentication (JWT-based)
- MyBatis-Plus for database access
- Dynamic datasource for multi-database support
- Weaviate for vector database (knowledge retrieval)
Frontend:
- Vue 3 with Composition API
- Vben Admin framework (admin portal)
- Element Plus + element-plus-x (portal UI)
- Pinia for state management
- UnoCSS for atomic CSS
Infrastructure:
- MySQL 8.0 (business data)
- Redis 7 (cache, session)
- Weaviate 1.25.0 (vector database)
- n8n (workflow automation)
- MinIO (object storage)
Important Patterns
Backend API Structure
Controllers in hzhub-modules/*/controller/ follow REST conventions:
@RestController
@RequestMapping("/chat")
public class ChatController {
@PostMapping("/message")
public R<ChatResponse> sendMessage(@RequestBody ChatRequest request) {
// Response wrapper: R<T>
}
}
Response wrapper R<T> from hzhub-common-core provides standardized API responses.
Multi-tenancy & Authentication
- Sa-Token handles JWT authentication
- Client ID header required:
ClientID(passed in frontend requests) - Token auto-injected via
Authorization: Bearer <token> - User permissions checked via Sa-Token's permission system
Dynamic Datasource
hzhub-common-mybatis uses dynamic-datasource-spring-boot-starter:
spring:
datasource:
dynamic:
primary: master
datasource:
master: # MySQL for business data
erp: # SQL Server (planned)
Switch datasource in code: @Ds("erp") annotation on service methods.
SSE Streaming
AI chat uses Server-Sent Events for streaming responses:
@GetMapping(value = "/stream", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<String> streamChat(@RequestParam String message) {
// Returns SSE stream
}
Frontend uses hook-fetch with sseTextDecoderPlugin to handle SSE.
Configuration Profiles
Backend uses Spring profiles:
application.yml- Base configurationapplication-dev.yml- Developmentapplication-prod.yml- Production
Profile set via SPRING_PROFILES_ACTIVE env var or spring.profiles.active property.
Development Workflow
Service Dependencies
When running locally, backend services need infrastructure:
- MySQL (localhost:3306)
- Redis (localhost:6379)
- Weaviate (localhost:28080)
Start infrastructure via Docker Compose first:
cd hzhub-deploy
docker-compose up -d mysql redis weaviate
Environment Variables
Backend:
SPRING_DATASOURCE_DYNAMIC_DATASOURCE_MASTER_URL: MySQL connection URLSPING_DATASOURCE_DYNAMIC_DATASOURCE_MASTER_USERNAME: DB usernameSPRING_DATASOURCE_DYNAMIC_DATASOURCE_MASTER_PASSWORD: DB passwordSPRING_DATA_REDIS_HOST: Redis hostSPRING_DATA_REDIS_PORT: Redis port
Frontend (in .env.development):
VITE_API_URL: Backend API base URL (default: http://localhost:6039)VITE_CLIENT_ID: Client identifier for authVITE_WEB_TITLE: Page title
Testing
Backend tests use Spring Boot test framework:
@SpringBootTest
class ChatServiceTest {
@Test
void testSendMessage() { ... }
}
Frontend uses Vitest for unit tests:
cd hzhub-admin
pnpm test:unit
Deployment
Docker Image Building
Backend Dockerfile in hzhub-ai/Dockerfile:
- Builds from Maven source
- Runs on port 6039
Frontend Dockerfiles in each portal directory:
- Builds with pnpm
- Served via Nginx
Service Ports
| Service | Port | Access |
|---|---|---|
| hzhub-admin (frontend) | 5666 | http://localhost:5666 |
| hzhub-portal-employee | 5137 | http://localhost:5137 |
| hzhub-portal-dealer | 5138 | http://localhost:5138 |
| hzhub-ai (backend API) | 6039 | http://localhost:6039 |
| MySQL | 3306 | localhost:3306 |
| Redis | 6379 | localhost:6379 |
| Weaviate | 28080 | http://localhost:28080 |
| n8n | 5678 | http://localhost:5678 |
Common Tasks
Adding a New Backend Module
- Create module in
hzhub-ai/hzhub-modules/ - Add to parent
pom.xmlmodules list - Include in
hzhub-admindependencies - Create controller, service, mapper following existing patterns
Adding a New API Endpoint
- Create controller in module's
controller/package - Use
@RestControllerand@RequestMapping - Return
R<T>wrapper for responses - Add permission check if needed:
@SaCheckPermission("system:user:list")
Adding Frontend Features
For admin portal:
- Add API call in
apps/web-antd/src/api/ - Create view in
apps/web-antd/src/views/ - Add route in
apps/web-antd/src/router/ - Add menu configuration
For portals (employee/dealer):
- Add API module in
src/api/withindex.tsandtypes.ts - Create page in
src/pages/ - Define route in
src/routers/modules/ - Add store if needed in
src/stores/
Working with Weaviate
Weaviate is used for knowledge retrieval (RAG). Collection creation and querying handled by LangChain4j integration in hzhub-common-chat.
Notes
- Package naming:
org.hzhub.*(renamed fromorg.ruoyi.*) - Java version: JDK 17+
- Node version: Node 22+ with pnpm 10+
- Code style: ESLint
@antfu/eslint-configfor frontend; backend follows Spring conventions - Git hooks: Lefthook configured (see
lefthook.yml)