sdd-workflow 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +226 -0
- package/bin/sdd-init.js +59 -0
- package/package.json +30 -0
- package/src/installer.js +558 -0
- package/templates/skills/sdd-constitution/SKILL.md +128 -0
- package/templates/skills/sdd-implement/SKILL.md +153 -0
- package/templates/skills/sdd-init/SKILL.md +302 -0
- package/templates/skills/sdd-plan/SKILL.md +226 -0
- package/templates/skills/sdd-review/SKILL.md +498 -0
- package/templates/skills/sdd-run/SKILL.md +439 -0
- package/templates/skills/sdd-specify/SKILL.md +280 -0
- package/templates/skills/sdd-split/SKILL.md +432 -0
- package/templates/skills/sdd-tasks/SKILL.md +199 -0
- package/templates/skills/sdd-testcases/SKILL.md +235 -0
- package/templates/specify/README.md +179 -0
- package/templates/specify/scripts/create-feature.sh +144 -0
- package/templates/specify/templates/constitution-template.md +74 -0
- package/templates/specify/templates/plan-modular-template/README.md +98 -0
- package/templates/specify/templates/plan-modular-template/architecture.md +127 -0
- package/templates/specify/templates/plan-modular-template/backend-api.md +191 -0
- package/templates/specify/templates/plan-modular-template/backend-impl.md +134 -0
- package/templates/specify/templates/plan-modular-template/changelog.md +34 -0
- package/templates/specify/templates/plan-modular-template/data-model.md +130 -0
- package/templates/specify/templates/plan-modular-template/frontend-api.md +126 -0
- package/templates/specify/templates/plan-modular-template/frontend-impl.md +108 -0
- package/templates/specify/templates/plan-modular-template/performance.md +112 -0
- package/templates/specify/templates/plan-modular-template/security.md +85 -0
- package/templates/specify/templates/plan-template.md +190 -0
- package/templates/specify/templates/requirements/metadata-template.json +12 -0
- package/templates/specify/templates/requirements/original-template.md +26 -0
- package/templates/specify/templates/spec-modular-template/README.md +69 -0
- package/templates/specify/templates/spec-modular-template/acceptance-criteria.md +49 -0
- package/templates/specify/templates/spec-modular-template/changelog.md +27 -0
- package/templates/specify/templates/spec-modular-template/constraints.md +125 -0
- package/templates/specify/templates/spec-modular-template/overview.md +60 -0
- package/templates/specify/templates/spec-modular-template/user-stories.md +59 -0
- package/templates/specify/templates/spec-template.md +214 -0
- package/templates/specify/templates/tasks-modular-template/README.md +79 -0
- package/templates/specify/templates/tasks-template.md +232 -0
- package/templates/specify/templates/testcases-template.md +434 -0
- package/templates/teams/sdd-development-team.md +318 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# SDD Feature Creator
|
|
3
|
+
# Creates a new feature specification directory
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Color definitions
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
NC='\033[0m' # No Color
|
|
12
|
+
|
|
13
|
+
# Get .specify directory
|
|
14
|
+
SPECIFY_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
|
15
|
+
SPECS_DIR="$SPECIFY_DIR/specs"
|
|
16
|
+
TEMPLATES_DIR="$SPECIFY_DIR/templates"
|
|
17
|
+
|
|
18
|
+
# Check directory exists
|
|
19
|
+
if [ ! -d "$SPECIFY_DIR" ]; then
|
|
20
|
+
echo -e "${RED}Error: .specify directory does not exist${NC}"
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
# Get next feature ID
|
|
25
|
+
get_next_feature_id() {
|
|
26
|
+
local max_id=0
|
|
27
|
+
for dir in "$SPECS_DIR"/*/; do
|
|
28
|
+
if [ -d "$dir" ]; then
|
|
29
|
+
dirname=$(basename "$dir")
|
|
30
|
+
id=$(echo "$dirname" | grep -o '^[0-9]*' || echo "0")
|
|
31
|
+
if [ "$id" -gt "$max_id" ] 2>/dev/null; then
|
|
32
|
+
max_id=$id
|
|
33
|
+
fi
|
|
34
|
+
fi
|
|
35
|
+
done
|
|
36
|
+
printf "%03d" $((max_id + 1))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# Create feature directory
|
|
40
|
+
create_feature() {
|
|
41
|
+
local feature_name=$1
|
|
42
|
+
local feature_id=$(get_next_feature_id)
|
|
43
|
+
local feature_dir="$SPECS_DIR/${feature_id}-${feature_name}"
|
|
44
|
+
|
|
45
|
+
# Check if directory already exists
|
|
46
|
+
if [ -d "$feature_dir" ]; then
|
|
47
|
+
echo -e "${RED}Error: Feature directory already exists: $feature_dir${NC}"
|
|
48
|
+
exit 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
# Create directory
|
|
52
|
+
mkdir -p "$feature_dir/contracts"
|
|
53
|
+
|
|
54
|
+
# Get current date
|
|
55
|
+
local date=$(date +%Y-%m-%d)
|
|
56
|
+
|
|
57
|
+
# Create spec.md
|
|
58
|
+
if [ -f "$TEMPLATES_DIR/spec-template.md" ]; then
|
|
59
|
+
sed -e "s/{feature_id}/$feature_id/g" \
|
|
60
|
+
-e "s/{date}/$date/g" \
|
|
61
|
+
-e "s/{feature_name}/$feature_name/g" \
|
|
62
|
+
"$TEMPLATES_DIR/spec-template.md" > "$feature_dir/spec.md"
|
|
63
|
+
else
|
|
64
|
+
touch "$feature_dir/spec.md"
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Create plan.md
|
|
68
|
+
if [ -f "$TEMPLATES_DIR/plan-template.md" ]; then
|
|
69
|
+
sed -e "s/{feature_id}/$feature_id/g" \
|
|
70
|
+
-e "s/{date}/$date/g" \
|
|
71
|
+
"$TEMPLATES_DIR/plan-template.md" > "$feature_dir/plan.md"
|
|
72
|
+
else
|
|
73
|
+
touch "$feature_dir/plan.md"
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
# Create tasks.md
|
|
77
|
+
if [ -f "$TEMPLATES_DIR/tasks-template.md" ]; then
|
|
78
|
+
sed -e "s/{feature_id}/$feature_id/g" \
|
|
79
|
+
-e "s/{date}/$date/g" \
|
|
80
|
+
"$TEMPLATES_DIR/tasks-template.md" > "$feature_dir/tasks.md"
|
|
81
|
+
else
|
|
82
|
+
touch "$feature_dir/tasks.md"
|
|
83
|
+
fi
|
|
84
|
+
|
|
85
|
+
echo -e "${GREEN}Feature directory created: $feature_dir${NC}"
|
|
86
|
+
echo ""
|
|
87
|
+
echo "File structure:"
|
|
88
|
+
echo " ${feature_id}-${feature_name}/"
|
|
89
|
+
echo " ├── spec.md # Feature specification"
|
|
90
|
+
echo " ├── plan.md # Technical plan"
|
|
91
|
+
echo " ├── tasks.md # Task breakdown"
|
|
92
|
+
echo " └── contracts/ # API contracts"
|
|
93
|
+
echo ""
|
|
94
|
+
echo "Next steps:"
|
|
95
|
+
echo " 1. Use /sdd-specify to complete the feature specification"
|
|
96
|
+
echo " 2. Use /sdd-plan to create the technical plan"
|
|
97
|
+
echo " 3. Use /sdd-tasks to break down tasks"
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# List existing features
|
|
101
|
+
list_features() {
|
|
102
|
+
echo -e "${YELLOW}Existing features:${NC}"
|
|
103
|
+
echo ""
|
|
104
|
+
for dir in "$SPECS_DIR"/*/; do
|
|
105
|
+
if [ -d "$dir" ]; then
|
|
106
|
+
dirname=$(basename "$dir")
|
|
107
|
+
echo " - $dirname"
|
|
108
|
+
fi
|
|
109
|
+
done
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# Help information
|
|
113
|
+
show_help() {
|
|
114
|
+
echo "SDD Feature Creator"
|
|
115
|
+
echo ""
|
|
116
|
+
echo "Usage:"
|
|
117
|
+
echo " $0 <feature-name> Create new feature directory"
|
|
118
|
+
echo " $0 list List existing features"
|
|
119
|
+
echo " $0 help Show help"
|
|
120
|
+
echo ""
|
|
121
|
+
echo "Examples:"
|
|
122
|
+
echo " $0 user-authentication"
|
|
123
|
+
echo " $0 data-export"
|
|
124
|
+
echo " $0 notification-system"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
# Main logic
|
|
128
|
+
case "$1" in
|
|
129
|
+
""|help|--help|-h)
|
|
130
|
+
show_help
|
|
131
|
+
;;
|
|
132
|
+
list|--list|-l)
|
|
133
|
+
list_features
|
|
134
|
+
;;
|
|
135
|
+
*)
|
|
136
|
+
# Validate feature name format
|
|
137
|
+
if [[ ! "$1" =~ ^[a-z][a-z0-9-]*$ ]]; then
|
|
138
|
+
echo -e "${RED}Error: Feature name must be lowercase letters, numbers and hyphens, starting with a letter${NC}"
|
|
139
|
+
echo "Examples: user-authentication, data-export, notification-system"
|
|
140
|
+
exit 1
|
|
141
|
+
fi
|
|
142
|
+
create_feature "$1"
|
|
143
|
+
;;
|
|
144
|
+
esac
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# 项目宪法 (Constitution)
|
|
2
|
+
|
|
3
|
+
> 项目基本信息、技术栈、环境配置见项目根目录 CLAUDE.md,本文档仅记录**开发约束和原则**。
|
|
4
|
+
> 创建日期: {date}
|
|
5
|
+
> 最后更新: {date}
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 一、绝对铁律
|
|
10
|
+
|
|
11
|
+
1. {iron_rule_1}
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 二、开发原则
|
|
16
|
+
|
|
17
|
+
### 2.1 简单性原则
|
|
18
|
+
|
|
19
|
+
> **优先复用现有方法,避免重复造轮子**
|
|
20
|
+
|
|
21
|
+
新增代码前必须检查:是否已有类似方法?是否可扩展现有方法?是否有更底层的公共方法?
|
|
22
|
+
|
|
23
|
+
### 2.2 N+1 查询禁令
|
|
24
|
+
|
|
25
|
+
禁止在循环内执行数据库查询,使用批量查询 + Map 缓存替代。
|
|
26
|
+
|
|
27
|
+
### 2.3 代码质量
|
|
28
|
+
|
|
29
|
+
{code_quality_principles}
|
|
30
|
+
|
|
31
|
+
### 2.4 测试标准
|
|
32
|
+
|
|
33
|
+
{testing_standards}
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 三、架构约束
|
|
38
|
+
|
|
39
|
+
<!-- SDD 自动检测技术栈,填入 constitution.md 中的实际值。
|
|
40
|
+
支持任意架构模式,以下为常见模式示例,请根据项目实际情况选择或替换。 -->
|
|
41
|
+
|
|
42
|
+
### 3.1 架构模式
|
|
43
|
+
|
|
44
|
+
> 检测到的架构模式: `{architecture_pattern}`
|
|
45
|
+
> 前端技术栈: `{frontend_stack}`
|
|
46
|
+
> 后端技术栈: `{backend_stack}`
|
|
47
|
+
> 数据库: `{database}`
|
|
48
|
+
|
|
49
|
+
{architecture_principles}
|
|
50
|
+
|
|
51
|
+
### 3.2 API 响应格式
|
|
52
|
+
|
|
53
|
+
{api_response_format}
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## 四、SDD 文档职责边界
|
|
58
|
+
|
|
59
|
+
| 文档 | 职责 | 内容边界 |
|
|
60
|
+
|------|------|----------|
|
|
61
|
+
| spec.md | What | 业务需求、用户故事、验收标准。禁止 SQL/代码/文件路径 |
|
|
62
|
+
| testcases.md | 行为验证 | 测试场景 Given-When-Then |
|
|
63
|
+
| plan.md | How | 技术方案、架构设计、代码设计 |
|
|
64
|
+
| tasks.md | When | 任务分解、执行顺序、进度跟踪 |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## 五、经验教训
|
|
69
|
+
|
|
70
|
+
{lessons_learned}
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
*本文档由 SDD 规范维护,如需更新请运行 `/sdd-constitution`*
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# {feature_name} - Implementation Plan Index
|
|
2
|
+
|
|
3
|
+
> Version: {version}
|
|
4
|
+
> Created: {create_date}
|
|
5
|
+
> Updated: {update_date}
|
|
6
|
+
> Related Spec: [spec.md](../spec.md)
|
|
7
|
+
> Related Test Cases: [testcases.md](../testcases.md)
|
|
8
|
+
|
|
9
|
+
## Document Structure
|
|
10
|
+
|
|
11
|
+
The implementation plan has been split into the following modules for easier management and on-demand loading:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
plan/
|
|
15
|
+
├── README.md # This file - plan index and overview
|
|
16
|
+
├── architecture.md # Architecture design
|
|
17
|
+
├── data-model.md # Data model (DDL, DTO)
|
|
18
|
+
├── backend-api.md # Backend API design
|
|
19
|
+
├── backend-impl.md # Backend implementation details
|
|
20
|
+
├── frontend-api.md # Frontend API integration
|
|
21
|
+
├── frontend-impl.md # Frontend implementation details
|
|
22
|
+
├── security.md # Security design
|
|
23
|
+
├── performance.md # Performance optimization
|
|
24
|
+
└── changelog.md # Change log
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Document Overview
|
|
28
|
+
|
|
29
|
+
| Module | Content | Document |
|
|
30
|
+
|--------|---------|----------|
|
|
31
|
+
| Architecture Design | Overall architecture, tech stack, module breakdown | [architecture.md](./architecture.md) |
|
|
32
|
+
| Data Model | DDL, DTO, entity relationships | [data-model.md](./data-model.md) |
|
|
33
|
+
| Backend API | Controller, interface definitions | [backend-api.md](./backend-api.md) |
|
|
34
|
+
| Backend Implementation | Service, Repository implementation | [backend-impl.md](./backend-impl.md) |
|
|
35
|
+
| Frontend API | API integration, request wrapper | [frontend-api.md](./frontend-api.md) |
|
|
36
|
+
| Frontend Implementation | Components, Store, routing | [frontend-impl.md](./frontend-impl.md) |
|
|
37
|
+
| Security | Authentication, authorization, data security | [security.md](./security.md) |
|
|
38
|
+
| Performance Optimization | Caching, indexing, optimization strategies | [performance.md](./performance.md) |
|
|
39
|
+
| Change Log | Version change history | [changelog.md](./changelog.md) |
|
|
40
|
+
|
|
41
|
+
## Quick Navigation
|
|
42
|
+
|
|
43
|
+
### Core Documents
|
|
44
|
+
- [Architecture Design](./architecture.md) - Understand overall architecture and technology choices
|
|
45
|
+
- [Data Model](./data-model.md) - View database design and DTO definitions
|
|
46
|
+
- [Backend API](./backend-api.md) - View API interface definitions
|
|
47
|
+
|
|
48
|
+
### Implementation Documents
|
|
49
|
+
- [Backend Implementation](./backend-impl.md) - Backend Service and Repository implementation
|
|
50
|
+
- [Frontend API](./frontend-api.md) - Frontend API integration approach
|
|
51
|
+
- [Frontend Implementation](./frontend-impl.md) - Frontend component and Store implementation
|
|
52
|
+
|
|
53
|
+
### Auxiliary Documents
|
|
54
|
+
- [Security Design](./security.md) - Security-related design
|
|
55
|
+
- [Performance Optimization](./performance.md) - Performance optimization strategies
|
|
56
|
+
- [Change Log](./changelog.md) - Version change history
|
|
57
|
+
|
|
58
|
+
## Core Information Summary
|
|
59
|
+
|
|
60
|
+
### Technology Stack
|
|
61
|
+
|
|
62
|
+
> Read from constitution.md or project configuration.
|
|
63
|
+
|
|
64
|
+
| Layer | Technology | Version |
|
|
65
|
+
|-------|-----------|---------|
|
|
66
|
+
| Frontend Framework | {frontend_framework} | {frontend_version} |
|
|
67
|
+
| UI Library | {ui_library} | {ui_version} |
|
|
68
|
+
| State Management | {state_management} | {state_version} |
|
|
69
|
+
| Backend Framework | {backend_framework} | {backend_version} |
|
|
70
|
+
| Database | {database} | {database_version} |
|
|
71
|
+
|
|
72
|
+
### Architecture Overview
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Frontend ({frontend_framework} + {state_management})
|
|
76
|
+
| HTTP API
|
|
77
|
+
Backend ({backend_framework})
|
|
78
|
+
| {database_driver}
|
|
79
|
+
Database ({database})
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Key Design Decisions
|
|
83
|
+
|
|
84
|
+
1. **Decision 1**: {brief_description}
|
|
85
|
+
2. **Decision 2**: {brief_description}
|
|
86
|
+
3. **Decision 3**: {brief_description}
|
|
87
|
+
|
|
88
|
+
## Usage Guide
|
|
89
|
+
|
|
90
|
+
1. **View Overview**: Read this file to understand the overall structure
|
|
91
|
+
2. **Architecture First**: Start with [architecture.md](./architecture.md) for overall design
|
|
92
|
+
3. **On-demand Loading**: Open the corresponding module document for your development phase
|
|
93
|
+
4. **Backend Development**: Refer to [backend-api.md](./backend-api.md) and [backend-impl.md](./backend-impl.md)
|
|
94
|
+
5. **Frontend Development**: Refer to [frontend-api.md](./frontend-api.md) and [frontend-impl.md](./frontend-impl.md)
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
*This document follows SDD specification and includes technical implementation details (SQL, code, file paths)*
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Architecture Design
|
|
2
|
+
|
|
3
|
+
> This document describes overall architecture, technology stack and module breakdown
|
|
4
|
+
|
|
5
|
+
## 1. Overall Architecture
|
|
6
|
+
|
|
7
|
+
### 1.1 Architecture Diagram
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
┌─────────────────────────────────────────────────────────────────────────┐
|
|
11
|
+
│ Frontend │
|
|
12
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
13
|
+
│ Page Layer │
|
|
14
|
+
│ ├── Page Components ({component_framework}) │
|
|
15
|
+
│ ├── Route Configuration ({router}) │
|
|
16
|
+
│ └── Styles ({style_solution}) │
|
|
17
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
18
|
+
│ State Management Layer │
|
|
19
|
+
│ ├── Store ({state_management}) │
|
|
20
|
+
│ └── Actions │
|
|
21
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
22
|
+
│ API Service Layer │
|
|
23
|
+
│ ├── API Wrapper │
|
|
24
|
+
│ └── Request Interceptors │
|
|
25
|
+
└──────────────────────────────────────┬──────────────────────────────────┘
|
|
26
|
+
│ HTTP API
|
|
27
|
+
┌──────────────────────────────────────▼──────────────────────────────────┐
|
|
28
|
+
│ Backend │
|
|
29
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
30
|
+
│ Controller/Handler Layer │
|
|
31
|
+
│ ├── REST API │
|
|
32
|
+
│ └── Parameter Validation │
|
|
33
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
34
|
+
│ Service Layer │
|
|
35
|
+
│ ├── Business Logic │
|
|
36
|
+
│ └── Transaction Management │
|
|
37
|
+
├─────────────────────────────────────────────────────────────────────────┤
|
|
38
|
+
│ Repository/Data Access Layer │
|
|
39
|
+
│ ├── Data Access │
|
|
40
|
+
│ └── Query Mapping │
|
|
41
|
+
└──────────────────────────────────────┬──────────────────────────────────┘
|
|
42
|
+
│ {database_driver}
|
|
43
|
+
┌──────────────────────────────────────▼──────────────────────────────────┐
|
|
44
|
+
│ Database ({database}) │
|
|
45
|
+
└─────────────────────────────────────────────────────────────────────────┘
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 1.2 Technology Stack
|
|
49
|
+
|
|
50
|
+
> Read technology stack information from constitution.md or project configuration.
|
|
51
|
+
|
|
52
|
+
| Layer | Technology | Version | Notes |
|
|
53
|
+
|-------|-----------|---------|-------|
|
|
54
|
+
| Frontend Framework | {frontend_framework} | {frontend_version} | {frontend_notes} |
|
|
55
|
+
| UI Library | {ui_library} | {ui_version} | {ui_notes} |
|
|
56
|
+
| State Management | {state_management} | {state_version} | {state_notes} |
|
|
57
|
+
| Backend Framework | {backend_framework} | {backend_version} | {backend_notes} |
|
|
58
|
+
| ORM Framework | {orm_framework} | {orm_version} | {orm_notes} |
|
|
59
|
+
| Database | {database} | {database_version} | {database_notes} |
|
|
60
|
+
|
|
61
|
+
### 1.3 Module Breakdown
|
|
62
|
+
|
|
63
|
+
**Frontend Modules**:
|
|
64
|
+
- Page module: Responsible for UI display and user interaction
|
|
65
|
+
- Store module: Responsible for state management and data flow
|
|
66
|
+
- API module: Responsible for backend communication
|
|
67
|
+
|
|
68
|
+
**Backend Modules**:
|
|
69
|
+
- Controller module: Responsible for interface definition and parameter validation
|
|
70
|
+
- Service module: Responsible for business logic implementation
|
|
71
|
+
- Repository module: Responsible for data access
|
|
72
|
+
|
|
73
|
+
## 2. Key Design Decisions
|
|
74
|
+
|
|
75
|
+
### Decision 1: {decision_title}
|
|
76
|
+
|
|
77
|
+
**Background**: {why this decision is needed}
|
|
78
|
+
|
|
79
|
+
**Options Comparison**:
|
|
80
|
+
|
|
81
|
+
| Option | Pros | Cons | Conclusion |
|
|
82
|
+
|--------|------|------|------------|
|
|
83
|
+
| Option A | Pro 1, Pro 2 | Con 1, Con 2 | Not adopted |
|
|
84
|
+
| Option B | Pro 1, Pro 2 | Con 1, Con 2 | Adopted |
|
|
85
|
+
|
|
86
|
+
**Final Decision**: Adopt Option B
|
|
87
|
+
|
|
88
|
+
**Rationale**: {detailed explanation of why this option was chosen}
|
|
89
|
+
|
|
90
|
+
### Decision 2: {decision_title}
|
|
91
|
+
|
|
92
|
+
{Same format as above}
|
|
93
|
+
|
|
94
|
+
## 3. Module Dependencies
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
Frontend Pages -> Frontend Store -> Frontend API -> Backend Controller -> Backend Service -> Backend Repository -> Database
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## 4. Interface Design Principles
|
|
101
|
+
|
|
102
|
+
1. **RESTful Style**: Follow REST conventions
|
|
103
|
+
2. **Unified Response Format**: Use standard response structure
|
|
104
|
+
3. **Version Control**: API paths include version number (/v1/)
|
|
105
|
+
4. **Error Handling**: Unified error codes and error messages
|
|
106
|
+
|
|
107
|
+
## 5. Data Flow Design
|
|
108
|
+
|
|
109
|
+
### 5.1 Query Flow
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
User Action -> Page Component -> Store.action -> API Request -> Controller -> Service -> Repository -> Database
|
|
113
|
+
|
|
|
114
|
+
User Interface <- Page Component <- Store.state <- API Response <- Controller <- Service <- Repository <- Query Result
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### 5.2 Save Flow
|
|
118
|
+
|
|
119
|
+
```
|
|
120
|
+
User Action -> Page Component -> Store.action -> API Request -> Controller -> Service -> Repository -> Database
|
|
121
|
+
| |
|
|
122
|
+
Validation Business Check
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
Back to [Plan Index](./README.md)
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Backend API Design
|
|
2
|
+
|
|
3
|
+
> This document describes backend API interface definitions
|
|
4
|
+
|
|
5
|
+
## 1. API Handler Design
|
|
6
|
+
|
|
7
|
+
### 1.1 Handler/Controller Class
|
|
8
|
+
|
|
9
|
+
**File Path**: `{backend_source_path}/controllers/{Name}Controller.{ext}`
|
|
10
|
+
|
|
11
|
+
```{backend_language}
|
|
12
|
+
// {Name}Controller - API endpoints for {module}/{resource}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## 2. API Interface List
|
|
16
|
+
|
|
17
|
+
### 2.1 Query Interface
|
|
18
|
+
|
|
19
|
+
#### GET /v1/{module}/{resource}
|
|
20
|
+
|
|
21
|
+
**Purpose**: Query list
|
|
22
|
+
|
|
23
|
+
**Request Parameters**:
|
|
24
|
+
|
|
25
|
+
| Parameter | Type | Required | Description |
|
|
26
|
+
|-----------|------|----------|-------------|
|
|
27
|
+
| keyword | String | No | Keyword search |
|
|
28
|
+
| status | String | No | Status filter |
|
|
29
|
+
| pageNum | Integer | No | Page number (default 1) |
|
|
30
|
+
| pageSize | Integer | No | Page size (default 20) |
|
|
31
|
+
|
|
32
|
+
**Response Example**:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"status": "0",
|
|
37
|
+
"message": "success",
|
|
38
|
+
"data": {
|
|
39
|
+
"total": 100,
|
|
40
|
+
"list": [
|
|
41
|
+
{
|
|
42
|
+
"id": "1",
|
|
43
|
+
"name": "Name",
|
|
44
|
+
"status": "ACTIVE"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2.2 Detail Interface
|
|
52
|
+
|
|
53
|
+
#### GET /v1/{module}/{resource}/{id}
|
|
54
|
+
|
|
55
|
+
**Purpose**: Query detail
|
|
56
|
+
|
|
57
|
+
**Path Parameters**:
|
|
58
|
+
|
|
59
|
+
| Parameter | Type | Required | Description |
|
|
60
|
+
|-----------|------|----------|-------------|
|
|
61
|
+
| id | Long | Yes | Resource ID |
|
|
62
|
+
|
|
63
|
+
**Response Example**:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"status": "0",
|
|
68
|
+
"message": "success",
|
|
69
|
+
"data": {
|
|
70
|
+
"id": "1",
|
|
71
|
+
"name": "Name",
|
|
72
|
+
"description": "Description"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### 2.3 Create Interface
|
|
78
|
+
|
|
79
|
+
#### POST /v1/{module}/{resource}
|
|
80
|
+
|
|
81
|
+
**Purpose**: Create resource
|
|
82
|
+
|
|
83
|
+
**Request Body**:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"name": "Name",
|
|
88
|
+
"description": "Description"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Response Example**:
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"status": "0",
|
|
97
|
+
"message": "Created successfully",
|
|
98
|
+
"data": {
|
|
99
|
+
"id": "1"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 2.4 Update Interface
|
|
105
|
+
|
|
106
|
+
#### PUT /v1/{module}/{resource}/{id}
|
|
107
|
+
|
|
108
|
+
**Purpose**: Update resource
|
|
109
|
+
|
|
110
|
+
**Path Parameters**:
|
|
111
|
+
|
|
112
|
+
| Parameter | Type | Required | Description |
|
|
113
|
+
|-----------|------|----------|-------------|
|
|
114
|
+
| id | Long | Yes | Resource ID |
|
|
115
|
+
|
|
116
|
+
**Request Body**:
|
|
117
|
+
|
|
118
|
+
```json
|
|
119
|
+
{
|
|
120
|
+
"name": "New Name",
|
|
121
|
+
"description": "New Description"
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Response Example**:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
{
|
|
129
|
+
"status": "0",
|
|
130
|
+
"message": "Updated successfully"
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 2.5 Delete Interface
|
|
135
|
+
|
|
136
|
+
#### DELETE /v1/{module}/{resource}/{id}
|
|
137
|
+
|
|
138
|
+
**Purpose**: Delete resource
|
|
139
|
+
|
|
140
|
+
**Path Parameters**:
|
|
141
|
+
|
|
142
|
+
| Parameter | Type | Required | Description |
|
|
143
|
+
|-----------|------|----------|-------------|
|
|
144
|
+
| id | Long | Yes | Resource ID |
|
|
145
|
+
|
|
146
|
+
**Response Example**:
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{
|
|
150
|
+
"status": "0",
|
|
151
|
+
"message": "Deleted successfully"
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## 3. Unified Response Format
|
|
156
|
+
|
|
157
|
+
### 3.1 Success Response
|
|
158
|
+
|
|
159
|
+
```json
|
|
160
|
+
{
|
|
161
|
+
"status": "0",
|
|
162
|
+
"message": "success",
|
|
163
|
+
"data": {}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### 3.2 Error Response
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"status": "1",
|
|
172
|
+
"message": "Error message",
|
|
173
|
+
"data": null
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## 4. Error Code Definitions
|
|
178
|
+
|
|
179
|
+
| Error Code | Description | HTTP Status |
|
|
180
|
+
|------------|-------------|-------------|
|
|
181
|
+
| 0 | Success | 200 |
|
|
182
|
+
| 1 | Business error | 200 |
|
|
183
|
+
| 400 | Parameter error | 400 |
|
|
184
|
+
| 401 | Unauthorized | 401 |
|
|
185
|
+
| 403 | Forbidden | 403 |
|
|
186
|
+
| 404 | Not found | 404 |
|
|
187
|
+
| 500 | Server error | 500 |
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
Back to [Plan Index](./README.md)
|