|
1 | 1 | # CLAUDE.md |
2 | 2 |
|
3 | | -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 3 | +本文件为 Claude Code (claude.ai/code) 在本项目中工作时提供指导。 |
4 | 4 |
|
5 | | -## Project Overview |
| 5 | +## 项目概述 |
6 | 6 |
|
7 | | -Flow Engine is an enterprise-grade workflow engine built with Java 17 and Spring Boot 3.5.9. It provides visual process design, dynamic form configuration, multi-node type transitions, and script extensions. The project uses a front-end/back-end separated architecture, supporting both PC and mobile clients. |
| 7 | +Flow Engine 是一个企业级工作流引擎,基于 Java 17 和 Spring Boot 3.5.9 构建。提供可视化流程设计、动态表单配置、多节点类型流转以及脚本扩展功能。项目采用前后端分离架构,支持 PC 端和移动端客户端。 |
8 | 8 |
|
9 | | -## Common Commands |
| 9 | +## 常用命令 |
10 | 10 |
|
11 | | -### Backend (Java/Maven) |
| 11 | +### 后端 (Java/Maven) |
12 | 12 |
|
13 | 13 | ```bash |
14 | | -# Build the entire project |
| 14 | +# 构建整个项目 |
15 | 15 | ./mvnw clean install |
16 | 16 |
|
17 | | -# Run all tests |
| 17 | +# 运行所有测试 |
18 | 18 | ./mvnw test |
19 | 19 |
|
20 | | -# Run tests for a specific module |
| 20 | +# 运行特定模块的测试 |
21 | 21 | ./mvnw test -pl flow-engine-framework |
22 | 22 |
|
23 | | -# Run a specific test class |
| 23 | +# 运行特定的测试类 |
24 | 24 | ./mvnw test -Dtest=ScriptRuntimeContextTest |
25 | 25 |
|
26 | | -# Run the example application |
| 26 | +# 运行示例应用 |
27 | 27 | cd flow-engine-example && mvn spring-boot:run |
28 | 28 | ``` |
29 | 29 |
|
30 | | -### Frontend (React/pnpm) |
| 30 | +### 前端 (React/pnpm) |
31 | 31 |
|
32 | 32 | ```bash |
33 | | -# Install dependencies (use pnpm, not npm) |
| 33 | +# 安装依赖(使用 pnpm,而非 npm) |
34 | 34 | cd frontend && pnpm install |
35 | 35 |
|
36 | | -# Build all packages |
| 36 | +# 构建所有包 |
37 | 37 | pnpm run build |
38 | 38 |
|
39 | | -# Build specific app |
| 39 | +# 构建特定应用 |
40 | 40 | pnpm run build:app-pc |
41 | 41 |
|
42 | | -# Development mode |
43 | | -pnpm run dev:app-pc # PC application |
44 | | -pnpm run dev:app-mobile # Mobile application |
| 42 | +# 构建特定包 |
| 43 | +pnpm run build:flow-core # 构建核心 API 库 |
| 44 | +pnpm run build:flow-types # 构建类型定义库 |
| 45 | +pnpm run build:flow-pc # 构建 PC 端组件库 |
| 46 | + |
| 47 | +# 开发模式 |
| 48 | +pnpm run dev:app-pc # PC 端应用 |
| 49 | +pnpm run dev:app-mobile # 移动端应用 |
45 | 50 | ``` |
46 | 51 |
|
47 | | -## Architecture |
| 52 | +## 架构 |
48 | 53 |
|
49 | | -### Backend Layers (8-layer architecture) |
| 54 | +### 后端分层架构(8 层架构) |
50 | 55 |
|
51 | | -1. **Workflow Layer** - Process definition |
52 | | -2. **Node Layer** - 15 node types (StartNode, EndNode, ApprovalNode, HandleNode, NotifyNode, RouterNode, SubProcessNode, DelayNode, TriggerNode, ConditionNode, ParallelNode, InclusiveNode, and their branch variants) |
53 | | -3. **Action Layer** - 8 action types (Pass, Reject, Save, AddAudit, Delegate, Return, Transfer, Custom) |
54 | | -4. **Record Layer** - Process instance records |
55 | | -5. **Session Layer** - Session management |
56 | | -6. **Manager Layer** - Business managers (NodeStrategyManager, OperatorManager, ActionManager, etc.) |
57 | | -7. **Strategy Layer** - Policy-driven configuration |
58 | | -8. **Script Layer** - Groovy script runtime |
| 56 | +1. **工作流层** - 流程定义 |
| 57 | +2. **节点层** - 15 种节点类型(StartNode、EndNode、ApprovalNode、HandleNode、NotifyNode、RouterNode、SubProcessNode、DelayNode、TriggerNode、ConditionNode、ParallelNode、InclusiveNode 及其分支变体) |
| 58 | +3. **动作层** - 8 种动作类型(Pass、Reject、Save、AddAudit、Delegate、Return、Transfer、Custom) |
| 59 | +4. **记录层** - 流程实例记录 |
| 60 | +5. **会话层** - 会话管理 |
| 61 | +6. **管理器层** - 业务管理器(NodeStrategyManager、OperatorManager、ActionManager 等) |
| 62 | +7. **策略层** - 策略驱动的配置 |
| 63 | +8. **脚本层** - Groovy 脚本运行时 |
59 | 64 |
|
60 | | -### Design Patterns Used |
| 65 | +### 设计模式 |
61 | 66 |
|
62 | | -- **Builder Pattern** - WorkflowBuilder, NodeBuilder, FormMetaBuilder |
63 | | -- **Factory Pattern** - FlowActionFactory |
64 | | -- **Strategy Pattern** - NodeStrategy, WorkflowStrategy |
65 | | -- **Template Method Pattern** - BaseAction, BaseNodeBuilder |
66 | | -- **Chain of Responsibility Pattern** - Action execution chain |
67 | | -- **Composite Pattern** - Node hierarchy with blocks |
| 67 | +- **建造者模式** - WorkflowBuilder、NodeBuilder、FormMetaBuilder |
| 68 | +- **工厂模式** - FlowActionFactory |
| 69 | +- **策略模式** - NodeStrategy、WorkflowStrategy |
| 70 | +- **模板方法模式** - BaseAction、BaseNodeBuilder |
| 71 | +- **责任链模式** - 动作执行链 |
| 72 | +- **组合模式** - 带 blocks 的节点层级结构 |
68 | 73 |
|
69 | | -### Module Structure |
| 74 | +### 模块结构 |
70 | 75 |
|
71 | | -| Module | Description | |
| 76 | +| 模块 | 描述 | |
72 | 77 | |--------|-------------| |
73 | | -| `flow-engine-framework` | Core workflow engine framework | |
74 | | -| `flow-engine-starter` | Spring Boot starter | |
75 | | -| `flow-engine-starter-api` | API layer | |
76 | | -| `flow-engine-starter-infra` | Infrastructure layer | |
77 | | -| `flow-engine-starter-query` | Query layer | |
78 | | -| `flow-engine-example` | Example application | |
79 | | -| `frontend/apps/app-pc` | PC workflow designer and admin | |
80 | | -| `frontend/apps/app-mobile` | Mobile todo/done pages | |
81 | | - |
82 | | -### Technology Stack |
83 | | - |
84 | | -- **Backend**: Java 17, Spring Boot 3.5.9, Groovy |
85 | | -- **Frontend**: React 18, TypeScript, pnpm, Rsbuild, Rslib, Antd |
86 | | - |
87 | | -## Key Packages |
88 | | - |
89 | | -- `com.codingapi.flow.node` - Node implementations (15 types) |
90 | | -- `com.codingapi.flow.action` - Action implementations (8 types) |
91 | | -- `com.codingapi.flow.strategy` - Strategy interfaces and implementations |
92 | | -- `com.codingapi.flow.repository` - Data access layer |
93 | | -- `com.codingapi.flow.service` - Business service layer |
94 | | -- `com.codingapi.flow.script` - Groovy script runtime |
95 | | - |
96 | | -## Development Notes |
97 | | - |
98 | | -- Use pnpm for frontend package management (per user configuration) |
99 | | -- All node configurations use policy-driven approach, supporting dynamic extensions |
100 | | -- Scripts use fine-grained synchronization locks for thread safety |
101 | | -- Process definitions use hierarchical node structure via `blocks` property (not separate edge relationships) |
| 78 | +| `flow-engine-framework` | 核心工作流引擎框架 | |
| 79 | +| `flow-engine-starter` | Spring Boot 启动器 | |
| 80 | +| `flow-engine-starter-api` | API 层 | |
| 81 | +| `flow-engine-starter-infra` | 基础设施层 | |
| 82 | +| `flow-engine-starter-query` | 查询层 | |
| 83 | +| `flow-engine-example` | 示例应用 | |
| 84 | +| `frontend/apps/app-pc` | PC 端流程设计器和管理后台 | |
| 85 | +| `frontend/apps/app-mobile` | 移动端待办/已办页面 | |
| 86 | +| `frontend/packages/flow-core` | 核心 API 库 | |
| 87 | +| `frontend/packages/flow-types` | TypeScript 类型定义库 | |
| 88 | +| `frontend/packages/flow-pc` | PC 端组件库 | |
| 89 | + |
| 90 | +### 技术栈 |
| 91 | + |
| 92 | +- **后端**:Java 17、Spring Boot 3.5.9、Groovy |
| 93 | +- **前端**:React 18、TypeScript、pnpm、Rsbuild、Rslib、Antd |
| 94 | + |
| 95 | +## 关键包 |
| 96 | + |
| 97 | +- `com.codingapi.flow.node` - 节点实现(15 种类型) |
| 98 | +- `com.codingapi.flow.action` - 动作实现(8 种类型) |
| 99 | +- `com.codingapi.flow.strategy` - 策略接口和实现 |
| 100 | +- `com.codingapi.flow.repository` - 数据访问层 |
| 101 | +- `com.codingapi.flow.service` - 业务服务层 |
| 102 | +- `com.codingapi.flow.script` - Groovy 脚本运行时 |
| 103 | + |
| 104 | +## 开发规范 |
| 105 | + |
| 106 | +- **与用户沟通及编写文档时,所有内容必须使用中文表述** |
| 107 | +- 前端包管理使用 pnpm(根据用户配置) |
| 108 | +- 设计涉及流程或 UML 图形的解决方案时,使用 Mermaid Markdown 语法 |
| 109 | +- 在编写计划的时候要遵循 TDD 的开发规范,务必要在方案中进行对实现代码逻辑的单元测试设计。 |
| 110 | +- 在设计计划方案或执行方案过程中,对于代码的设计规划与调整修改要遵循本项目的代码风格和架构设计规则 |
| 111 | +- 设计的计划要保存到本地的 `docs/` 目录下,每一个计划以时间+标题的方式命名创建文件夹,例如 `2026-02-26-xxxx`,文件夹下内容分为 `plan.md` 以及其他设计文件(如设计文件 xxx.pen 或其他设计内容信息) |
| 112 | + |
0 commit comments