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,134 @@
|
|
|
1
|
+
# Backend Implementation Details
|
|
2
|
+
|
|
3
|
+
> This document describes backend Service and Repository implementation
|
|
4
|
+
|
|
5
|
+
## 1. Service Layer Implementation
|
|
6
|
+
|
|
7
|
+
### 1.1 Service Interface
|
|
8
|
+
|
|
9
|
+
**File Path**: `{backend_source_path}/services/{Name}Service.{ext}`
|
|
10
|
+
|
|
11
|
+
```{backend_language}
|
|
12
|
+
// {Name}Service interface
|
|
13
|
+
// - list(keyword, status, pageNum, pageSize) -> PageInfo
|
|
14
|
+
// - getById(id) -> DTO
|
|
15
|
+
// - create(request) -> id
|
|
16
|
+
// - update(id, request)
|
|
17
|
+
// - delete(id)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 1.2 Service Implementation
|
|
21
|
+
|
|
22
|
+
**File Path**: `{backend_source_path}/services/impl/{Name}ServiceImpl.{ext}`
|
|
23
|
+
|
|
24
|
+
```{backend_language}
|
|
25
|
+
// {Name}ServiceImpl
|
|
26
|
+
//
|
|
27
|
+
// list():
|
|
28
|
+
// 1. Build query conditions
|
|
29
|
+
// 2. Execute paginated query
|
|
30
|
+
// 3. Convert to DTOs
|
|
31
|
+
//
|
|
32
|
+
// create():
|
|
33
|
+
// 1. Validate parameters
|
|
34
|
+
// 2. Convert to entity
|
|
35
|
+
// 3. Save to database
|
|
36
|
+
// 4. Return ID
|
|
37
|
+
//
|
|
38
|
+
// update():
|
|
39
|
+
// 1. Check resource exists
|
|
40
|
+
// 2. Validate parameters
|
|
41
|
+
// 3. Business rule validation
|
|
42
|
+
// 4. Convert and update
|
|
43
|
+
//
|
|
44
|
+
// delete():
|
|
45
|
+
// 1. Check resource exists
|
|
46
|
+
// 2. Check can delete (dependency check)
|
|
47
|
+
// 3. Execute delete
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 2. Repository/Data Access Layer Implementation
|
|
51
|
+
|
|
52
|
+
### 2.1 Repository Interface
|
|
53
|
+
|
|
54
|
+
**File Path**: `{backend_source_path}/repositories/{Name}Repository.{ext}`
|
|
55
|
+
|
|
56
|
+
```{backend_language}
|
|
57
|
+
// {Name}Repository interface
|
|
58
|
+
// - selectByQuery(query) -> List<Entity>
|
|
59
|
+
// - selectById(id) -> Entity
|
|
60
|
+
// - insert(entity) -> int
|
|
61
|
+
// - updateById(entity) -> int
|
|
62
|
+
// - deleteById(id) -> int
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 2.2 Query Mapping
|
|
66
|
+
|
|
67
|
+
**File Path**: `{backend_source_path}/mappers/{Name}Mapper.{ext}`
|
|
68
|
+
|
|
69
|
+
```{mapper_language}
|
|
70
|
+
<!-- Result mapping for {table_name} -->
|
|
71
|
+
<!-- Base columns: id, name, description, status, created_by, created_time, updated_by, updated_time -->
|
|
72
|
+
|
|
73
|
+
<!-- Query list with dynamic conditions (keyword search, status filter) -->
|
|
74
|
+
<!-- Query by ID -->
|
|
75
|
+
<!-- Insert -->
|
|
76
|
+
<!-- Update (dynamic set) -->
|
|
77
|
+
<!-- Delete -->
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## 3. Entity/Model Classes
|
|
81
|
+
|
|
82
|
+
**File Path**: `{backend_source_path}/models/{Name}Entity.{ext}`
|
|
83
|
+
|
|
84
|
+
```{backend_language}
|
|
85
|
+
// {Name}Entity - maps to {table_name} table
|
|
86
|
+
// Fields:
|
|
87
|
+
// - id: primary key
|
|
88
|
+
// - name: name
|
|
89
|
+
// - description: description
|
|
90
|
+
// - status: status
|
|
91
|
+
// - createdBy: creator
|
|
92
|
+
// - createdTime: creation time
|
|
93
|
+
// - updatedBy: updater
|
|
94
|
+
// - updatedTime: update time
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## 4. Business Logic Notes
|
|
98
|
+
|
|
99
|
+
### 4.1 Core Business Flows
|
|
100
|
+
|
|
101
|
+
1. **Create Flow**:
|
|
102
|
+
- Parameter validation
|
|
103
|
+
- Business rule validation
|
|
104
|
+
- Data conversion
|
|
105
|
+
- Save to database
|
|
106
|
+
- Return ID
|
|
107
|
+
|
|
108
|
+
2. **Update Flow**:
|
|
109
|
+
- Check resource exists
|
|
110
|
+
- Parameter validation
|
|
111
|
+
- Business rule validation
|
|
112
|
+
- Data conversion
|
|
113
|
+
- Update database
|
|
114
|
+
|
|
115
|
+
3. **Delete Flow**:
|
|
116
|
+
- Check resource exists
|
|
117
|
+
- Check can delete (dependency check)
|
|
118
|
+
- Execute delete
|
|
119
|
+
|
|
120
|
+
### 4.2 Transaction Management
|
|
121
|
+
|
|
122
|
+
- All write operations (create, update, delete) use transactions
|
|
123
|
+
- Query operations do not use transactions
|
|
124
|
+
- Use default transaction propagation
|
|
125
|
+
|
|
126
|
+
### 4.3 Exception Handling
|
|
127
|
+
|
|
128
|
+
- Parameter errors: Throw validation exceptions
|
|
129
|
+
- Business errors: Throw business exceptions
|
|
130
|
+
- System errors: Throw system exceptions
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
Back to [Plan Index](./README.md)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
> This document records version change history for the implementation plan
|
|
4
|
+
|
|
5
|
+
## Version History
|
|
6
|
+
|
|
7
|
+
| Version | Date | Change | Changed By |
|
|
8
|
+
|---------|------|--------|------------|
|
|
9
|
+
| 1.0 | {date} | Initial version | {author} |
|
|
10
|
+
|
|
11
|
+
## Detailed Changes
|
|
12
|
+
|
|
13
|
+
### v1.0 (Initial Version)
|
|
14
|
+
|
|
15
|
+
**Architecture Design**:
|
|
16
|
+
- Frontend-backend separation architecture
|
|
17
|
+
- Technology stack selected per constitution.md
|
|
18
|
+
|
|
19
|
+
**Data Model**:
|
|
20
|
+
- New table: {table_name}
|
|
21
|
+
- DTO design complete
|
|
22
|
+
|
|
23
|
+
**API Design**:
|
|
24
|
+
- RESTful API
|
|
25
|
+
- Unified response format
|
|
26
|
+
|
|
27
|
+
**Implementation Details**:
|
|
28
|
+
- Service layer implementation
|
|
29
|
+
- Repository layer implementation
|
|
30
|
+
- Frontend component implementation
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
Back to [Plan Index](./README.md)
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# Data Model
|
|
2
|
+
|
|
3
|
+
> This document describes database design (DDL) and data transfer objects (DTO)
|
|
4
|
+
|
|
5
|
+
## 1. Database Design
|
|
6
|
+
|
|
7
|
+
### 1.1 New Tables
|
|
8
|
+
|
|
9
|
+
#### Table: {table_name}
|
|
10
|
+
|
|
11
|
+
**Description**: {table_purpose}
|
|
12
|
+
|
|
13
|
+
**DDL**:
|
|
14
|
+
|
|
15
|
+
```sql
|
|
16
|
+
CREATE TABLE {table_name} (
|
|
17
|
+
id BIGSERIAL PRIMARY KEY,
|
|
18
|
+
{column_name} VARCHAR(100) NOT NULL,
|
|
19
|
+
created_by VARCHAR(50) NOT NULL,
|
|
20
|
+
created_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
21
|
+
updated_by VARCHAR(50),
|
|
22
|
+
updated_time TIMESTAMP,
|
|
23
|
+
CONSTRAINT uk_{table_name}_{column} UNIQUE ({column_name})
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
CREATE INDEX idx_{table_name}_{column} ON {table_name}({column_name});
|
|
27
|
+
|
|
28
|
+
COMMENT ON TABLE {table_name} IS '{table_description}';
|
|
29
|
+
COMMENT ON COLUMN {table_name}.{column_name} IS '{column_description}';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### 1.2 Modified Tables
|
|
33
|
+
|
|
34
|
+
#### Table: {existing_table}
|
|
35
|
+
|
|
36
|
+
**Change Description**: {change_reason}
|
|
37
|
+
|
|
38
|
+
**DDL**:
|
|
39
|
+
|
|
40
|
+
```sql
|
|
41
|
+
ALTER TABLE {existing_table} ADD COLUMN {new_column} VARCHAR(100);
|
|
42
|
+
COMMENT ON COLUMN {existing_table}.{new_column} IS '{column_description}';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 1.3 Entity Relationship Diagram
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
┌─────────────┐ ┌─────────────┐
|
|
49
|
+
│ Table A │ 1 N │ Table B │
|
|
50
|
+
│─────────────│─────────│─────────────│
|
|
51
|
+
│ id (PK) │ │ id (PK) │
|
|
52
|
+
│ name │ │ a_id (FK) │
|
|
53
|
+
└─────────────┘ └─────────────┘
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 2. DTO Design
|
|
57
|
+
|
|
58
|
+
### 2.1 Request DTO
|
|
59
|
+
|
|
60
|
+
#### {Name}RequestDTO
|
|
61
|
+
|
|
62
|
+
**Purpose**: {purpose_description}
|
|
63
|
+
|
|
64
|
+
```{dto_language}
|
|
65
|
+
class {Name}RequestDTO {
|
|
66
|
+
/** {field_description} */
|
|
67
|
+
{field1}: {type} // required
|
|
68
|
+
|
|
69
|
+
/** {field_description} */
|
|
70
|
+
{field2}: {type} // optional
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### 2.2 Response DTO
|
|
75
|
+
|
|
76
|
+
#### {Name}ResponseDTO
|
|
77
|
+
|
|
78
|
+
**Purpose**: {purpose_description}
|
|
79
|
+
|
|
80
|
+
```{dto_language}
|
|
81
|
+
class {Name}ResponseDTO {
|
|
82
|
+
{id}: {type}
|
|
83
|
+
{field1}: {type}
|
|
84
|
+
{field2}: {type}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### 2.3 DTO Conversion
|
|
89
|
+
|
|
90
|
+
```{dto_language}
|
|
91
|
+
// Entity -> DTO
|
|
92
|
+
function toDTO(entity) {
|
|
93
|
+
return {
|
|
94
|
+
id: entity.id,
|
|
95
|
+
field1: entity.field1,
|
|
96
|
+
// ...
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// DTO -> Entity
|
|
101
|
+
function toEntity(dto) {
|
|
102
|
+
return {
|
|
103
|
+
field1: dto.field1,
|
|
104
|
+
// ...
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## 3. Data Dictionary
|
|
110
|
+
|
|
111
|
+
### 3.1 Enum Types
|
|
112
|
+
|
|
113
|
+
#### {EnumName}
|
|
114
|
+
|
|
115
|
+
| Value | Description | Notes |
|
|
116
|
+
|-------|-------------|-------|
|
|
117
|
+
| VALUE1 | Description 1 | Notes 1 |
|
|
118
|
+
| VALUE2 | Description 2 | Notes 2 |
|
|
119
|
+
|
|
120
|
+
### 3.2 State Transitions
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
Initial -> Processing -> Complete
|
|
124
|
+
|
|
|
125
|
+
Failed
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
Back to [Plan Index](./README.md)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Frontend API Integration
|
|
2
|
+
|
|
3
|
+
> This document describes how the frontend integrates with backend APIs
|
|
4
|
+
|
|
5
|
+
## 1. API Service Layer
|
|
6
|
+
|
|
7
|
+
### 1.1 API File Structure
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
{frontend_source_path}/api/
|
|
11
|
+
├── index.{ext} # API unified exports
|
|
12
|
+
├── {module}.{ext} # Module API definitions
|
|
13
|
+
└── request.{ext} # Request wrapper (existing)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### 1.2 API Definition
|
|
17
|
+
|
|
18
|
+
**File Path**: `{frontend_source_path}/api/{module}.{ext}`
|
|
19
|
+
|
|
20
|
+
```{frontend_language}
|
|
21
|
+
import { request } from '{http_client_path}';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Query list
|
|
25
|
+
*/
|
|
26
|
+
export const list = (params) => {
|
|
27
|
+
return request({
|
|
28
|
+
url: '/v1/{module}/{resource}',
|
|
29
|
+
method: 'GET',
|
|
30
|
+
params
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Query detail
|
|
36
|
+
*/
|
|
37
|
+
export const getById = (id) => {
|
|
38
|
+
return request({
|
|
39
|
+
url: `/v1/{module}/${id}`,
|
|
40
|
+
method: 'GET'
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create
|
|
46
|
+
*/
|
|
47
|
+
export const create = (data) => {
|
|
48
|
+
return request({
|
|
49
|
+
url: '/v1/{module}/{resource}',
|
|
50
|
+
method: 'POST',
|
|
51
|
+
data
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Update
|
|
57
|
+
*/
|
|
58
|
+
export const update = (id, data) => {
|
|
59
|
+
return request({
|
|
60
|
+
url: `/v1/{module}/${id}`,
|
|
61
|
+
method: 'PUT',
|
|
62
|
+
data
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Delete
|
|
68
|
+
*/
|
|
69
|
+
export const deleteById = (id) => {
|
|
70
|
+
return request({
|
|
71
|
+
url: `/v1/{module}/${id}`,
|
|
72
|
+
method: 'DELETE'
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 2. Request Response Handling
|
|
78
|
+
|
|
79
|
+
### 2.1 Success Response
|
|
80
|
+
|
|
81
|
+
```{frontend_language}
|
|
82
|
+
// Backend response format (adjust to match your API contract)
|
|
83
|
+
{
|
|
84
|
+
status: '0', // Check your project's actual convention (string vs number)
|
|
85
|
+
message: 'success',
|
|
86
|
+
data: {}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Frontend handling
|
|
90
|
+
const response = await list({ keyword: 'test' });
|
|
91
|
+
if (response.status === '0') { // Adjust status check to match your project
|
|
92
|
+
console.log(response.data);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 2.2 Error Handling
|
|
97
|
+
|
|
98
|
+
```{frontend_language}
|
|
99
|
+
try {
|
|
100
|
+
const response = await create(data);
|
|
101
|
+
if (response.status === '0') {
|
|
102
|
+
// Success handling
|
|
103
|
+
} else {
|
|
104
|
+
// Business error handling
|
|
105
|
+
}
|
|
106
|
+
} catch (error) {
|
|
107
|
+
// Network error handling
|
|
108
|
+
console.error(error);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 3. Notes
|
|
113
|
+
|
|
114
|
+
### 3.1 Response Status Check
|
|
115
|
+
|
|
116
|
+
**Important**: Check your project's API response convention for the status field type and success value.
|
|
117
|
+
|
|
118
|
+
### 3.2 Error Handling
|
|
119
|
+
|
|
120
|
+
- Network errors: catch with try-catch
|
|
121
|
+
- Business errors: check response status
|
|
122
|
+
- User notification: use appropriate UI feedback
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
Back to [Plan Index](./README.md)
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Frontend Implementation Details
|
|
2
|
+
|
|
3
|
+
> This document describes frontend component, Store and routing implementation
|
|
4
|
+
|
|
5
|
+
## 1. Store/State Management Design
|
|
6
|
+
|
|
7
|
+
### 1.1 Store File
|
|
8
|
+
|
|
9
|
+
**File Path**: `{frontend_source_path}/stores/{Name}Store.{ext}`
|
|
10
|
+
|
|
11
|
+
```{frontend_language}
|
|
12
|
+
// {Name}Store - State management for {feature}
|
|
13
|
+
//
|
|
14
|
+
// State:
|
|
15
|
+
// - list: Array
|
|
16
|
+
// - loading: boolean
|
|
17
|
+
// - total: number
|
|
18
|
+
// - currentPage: number
|
|
19
|
+
// - pageSize: number
|
|
20
|
+
//
|
|
21
|
+
// Actions:
|
|
22
|
+
// - fetchList(params): Fetch paginated list
|
|
23
|
+
// - create(data): Create new item
|
|
24
|
+
// - setPage(page, pageSize): Update pagination state
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## 2. Page Components
|
|
28
|
+
|
|
29
|
+
### 2.1 List Page
|
|
30
|
+
|
|
31
|
+
**File Path**: `{frontend_source_path}/pages/{module}/{feature}/List.{ext}`
|
|
32
|
+
|
|
33
|
+
```{frontend_language}
|
|
34
|
+
// {Name}List component
|
|
35
|
+
//
|
|
36
|
+
// Features:
|
|
37
|
+
// - Search bar with keyword input
|
|
38
|
+
// - Data table with pagination
|
|
39
|
+
// - Action buttons (edit, delete)
|
|
40
|
+
// - Create button
|
|
41
|
+
//
|
|
42
|
+
// Dependencies:
|
|
43
|
+
// - {Name}Store for state management
|
|
44
|
+
// - UI table component for data display
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### 2.2 Detail Page
|
|
48
|
+
|
|
49
|
+
**File Path**: `{frontend_source_path}/pages/{module}/{feature}/Detail.{ext}`
|
|
50
|
+
|
|
51
|
+
```{frontend_language}
|
|
52
|
+
// {Name}Detail component
|
|
53
|
+
//
|
|
54
|
+
// Features:
|
|
55
|
+
// - Display item details
|
|
56
|
+
// - Loading state
|
|
57
|
+
// - Empty state handling
|
|
58
|
+
//
|
|
59
|
+
// Props:
|
|
60
|
+
// - id: Item ID to display
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 3. Route Configuration
|
|
64
|
+
|
|
65
|
+
### 3.1 Route Definition
|
|
66
|
+
|
|
67
|
+
**File Path**: `{frontend_source_path}/routes/{module}/index.{ext}`
|
|
68
|
+
|
|
69
|
+
```{frontend_language}
|
|
70
|
+
// Route configuration for {feature}
|
|
71
|
+
//
|
|
72
|
+
// Routes:
|
|
73
|
+
// - /{feature}/list -> List page
|
|
74
|
+
// - /{feature}/detail/:id -> Detail page
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 4. Style Files
|
|
78
|
+
|
|
79
|
+
### 4.1 Styles
|
|
80
|
+
|
|
81
|
+
**File Path**: `{frontend_source_path}/pages/{module}/{feature}/List.{style_ext}`
|
|
82
|
+
|
|
83
|
+
```{style_language}
|
|
84
|
+
// Styles for {module}-{feature}-list
|
|
85
|
+
// - Container padding
|
|
86
|
+
// - Toolbar layout
|
|
87
|
+
// - Table styling
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 5. Component Communication
|
|
91
|
+
|
|
92
|
+
### 5.1 Parent-Child Communication
|
|
93
|
+
|
|
94
|
+
```{frontend_language}
|
|
95
|
+
// Parent passes data and callbacks to child
|
|
96
|
+
// Child triggers callbacks to notify parent of changes
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 5.2 Store Sharing
|
|
100
|
+
|
|
101
|
+
```{frontend_language}
|
|
102
|
+
// Multiple components import the same Store instance
|
|
103
|
+
// Shared state across components
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
---
|
|
107
|
+
|
|
108
|
+
Back to [Plan Index](./README.md)
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# Performance Optimization
|
|
2
|
+
|
|
3
|
+
> This document describes performance optimization strategies
|
|
4
|
+
|
|
5
|
+
## 1. Database Optimization
|
|
6
|
+
|
|
7
|
+
### 1.1 Index Design
|
|
8
|
+
|
|
9
|
+
```sql
|
|
10
|
+
-- Single column index
|
|
11
|
+
CREATE INDEX idx_{table}_{column} ON {table}({column});
|
|
12
|
+
|
|
13
|
+
-- Composite index
|
|
14
|
+
CREATE INDEX idx_{table}_{col1}_{col2} ON {table}({col1}, {col2});
|
|
15
|
+
|
|
16
|
+
-- Unique index
|
|
17
|
+
CREATE UNIQUE INDEX uk_{table}_{column} ON {table}({column});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### 1.2 Query Optimization
|
|
21
|
+
|
|
22
|
+
- Avoid SELECT *
|
|
23
|
+
- Use pagination
|
|
24
|
+
- Avoid N+1 queries
|
|
25
|
+
- Use batch operations
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
// Bad: N+1 query
|
|
29
|
+
for each item in items:
|
|
30
|
+
query database for item details
|
|
31
|
+
|
|
32
|
+
// Good: Batch query
|
|
33
|
+
collect all item IDs
|
|
34
|
+
query database for all item details at once
|
|
35
|
+
use Map for lookup
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## 2. Caching Strategy
|
|
39
|
+
|
|
40
|
+
### 2.1 Application Cache
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
// Cache frequently accessed data
|
|
44
|
+
// Invalidate cache on update/delete
|
|
45
|
+
// Set appropriate TTL
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 2.2 Cache Invalidation Strategy
|
|
49
|
+
|
|
50
|
+
- Active invalidation: Clear cache on update/delete
|
|
51
|
+
- Passive invalidation: Set expiration time (TTL)
|
|
52
|
+
- Cache warmup: Load hot data on system startup
|
|
53
|
+
|
|
54
|
+
## 3. Frontend Optimization
|
|
55
|
+
|
|
56
|
+
### 3.1 Code Splitting
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
// Route-level lazy loading
|
|
60
|
+
// Load components on demand
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### 3.2 List Optimization
|
|
64
|
+
|
|
65
|
+
- Virtual scrolling (for large data sets)
|
|
66
|
+
- Pagination
|
|
67
|
+
- Debounce/throttle user input
|
|
68
|
+
|
|
69
|
+
```
|
|
70
|
+
// Debounce search input
|
|
71
|
+
const debouncedSearch = debounce(handleSearch, 300);
|
|
72
|
+
|
|
73
|
+
// Throttle scroll handler
|
|
74
|
+
const throttledScroll = throttle(handleScroll, 100);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 4. API Optimization
|
|
78
|
+
|
|
79
|
+
### 4.1 Batch APIs
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
// Batch query endpoint
|
|
83
|
+
// POST /batch with list of IDs
|
|
84
|
+
// Returns map of ID to data
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### 4.2 Async Processing
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
// Long-running operations processed asynchronously
|
|
91
|
+
// Return task ID, poll for completion
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 5. Performance Monitoring
|
|
95
|
+
|
|
96
|
+
### 5.1 Slow Query Monitoring
|
|
97
|
+
|
|
98
|
+
```sql
|
|
99
|
+
-- Enable slow query log
|
|
100
|
+
-- Set appropriate threshold
|
|
101
|
+
-- Monitor and optimize slow queries
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### 5.2 API Performance Monitoring
|
|
105
|
+
|
|
106
|
+
- Response time monitoring
|
|
107
|
+
- QPS monitoring
|
|
108
|
+
- Error rate monitoring
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
Back to [Plan Index](./README.md)
|