ai-spector 0.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.
Files changed (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +150 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +173 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/commands/analyze.d.ts +9 -0
  8. package/dist/commands/analyze.d.ts.map +1 -0
  9. package/dist/commands/analyze.js +62 -0
  10. package/dist/commands/analyze.js.map +1 -0
  11. package/dist/commands/bootstrap.d.ts +4 -0
  12. package/dist/commands/bootstrap.d.ts.map +1 -0
  13. package/dist/commands/bootstrap.js +58 -0
  14. package/dist/commands/bootstrap.js.map +1 -0
  15. package/dist/commands/graph-impact.d.ts +10 -0
  16. package/dist/commands/graph-impact.d.ts.map +1 -0
  17. package/dist/commands/graph-impact.js +31 -0
  18. package/dist/commands/graph-impact.js.map +1 -0
  19. package/dist/commands/graph-merge.d.ts +11 -0
  20. package/dist/commands/graph-merge.d.ts.map +1 -0
  21. package/dist/commands/graph-merge.js +88 -0
  22. package/dist/commands/graph-merge.js.map +1 -0
  23. package/dist/commands/graph-query.d.ts +10 -0
  24. package/dist/commands/graph-query.d.ts.map +1 -0
  25. package/dist/commands/graph-query.js +31 -0
  26. package/dist/commands/graph-query.js.map +1 -0
  27. package/dist/commands/graph-visualize.d.ts +10 -0
  28. package/dist/commands/graph-visualize.d.ts.map +1 -0
  29. package/dist/commands/graph-visualize.js +72 -0
  30. package/dist/commands/graph-visualize.js.map +1 -0
  31. package/dist/commands/init.d.ts +6 -0
  32. package/dist/commands/init.d.ts.map +1 -0
  33. package/dist/commands/init.js +47 -0
  34. package/dist/commands/init.js.map +1 -0
  35. package/dist/commands/validate.d.ts +10 -0
  36. package/dist/commands/validate.d.ts.map +1 -0
  37. package/dist/commands/validate.js +89 -0
  38. package/dist/commands/validate.js.map +1 -0
  39. package/dist/config/load.d.ts +21 -0
  40. package/dist/config/load.d.ts.map +1 -0
  41. package/dist/config/load.js +77 -0
  42. package/dist/config/load.js.map +1 -0
  43. package/dist/config/types.d.ts +22 -0
  44. package/dist/config/types.d.ts.map +1 -0
  45. package/dist/config/types.js +2 -0
  46. package/dist/config/types.js.map +1 -0
  47. package/dist/graph/InMemoryGraph.d.ts +20 -0
  48. package/dist/graph/InMemoryGraph.d.ts.map +1 -0
  49. package/dist/graph/InMemoryGraph.js +181 -0
  50. package/dist/graph/InMemoryGraph.js.map +1 -0
  51. package/dist/graph/defaults.d.ts +10 -0
  52. package/dist/graph/defaults.d.ts.map +1 -0
  53. package/dist/graph/defaults.js +10 -0
  54. package/dist/graph/defaults.js.map +1 -0
  55. package/dist/graph/impact.d.ts +32 -0
  56. package/dist/graph/impact.d.ts.map +1 -0
  57. package/dist/graph/impact.js +88 -0
  58. package/dist/graph/impact.js.map +1 -0
  59. package/dist/graph/knowledge.d.ts +53 -0
  60. package/dist/graph/knowledge.d.ts.map +1 -0
  61. package/dist/graph/knowledge.js +79 -0
  62. package/dist/graph/knowledge.js.map +1 -0
  63. package/dist/graph/load.d.ts +4 -0
  64. package/dist/graph/load.d.ts.map +1 -0
  65. package/dist/graph/load.js +12 -0
  66. package/dist/graph/load.js.map +1 -0
  67. package/dist/graph/loadGraph.d.ts +3 -0
  68. package/dist/graph/loadGraph.d.ts.map +1 -0
  69. package/dist/graph/loadGraph.js +7 -0
  70. package/dist/graph/loadGraph.js.map +1 -0
  71. package/dist/graph/merge.d.ts +15 -0
  72. package/dist/graph/merge.d.ts.map +1 -0
  73. package/dist/graph/merge.js +63 -0
  74. package/dist/graph/merge.js.map +1 -0
  75. package/dist/graph/query.d.ts +18 -0
  76. package/dist/graph/query.d.ts.map +1 -0
  77. package/dist/graph/query.js +132 -0
  78. package/dist/graph/query.js.map +1 -0
  79. package/dist/registry/build.d.ts +3 -0
  80. package/dist/registry/build.d.ts.map +1 -0
  81. package/dist/registry/build.js +53 -0
  82. package/dist/registry/build.js.map +1 -0
  83. package/dist/registry/slug.d.ts +4 -0
  84. package/dist/registry/slug.d.ts.map +1 -0
  85. package/dist/registry/slug.js +16 -0
  86. package/dist/registry/slug.js.map +1 -0
  87. package/dist/types.d.ts +45 -0
  88. package/dist/types.d.ts.map +1 -0
  89. package/dist/types.js +2 -0
  90. package/dist/types.js.map +1 -0
  91. package/dist/util/fs.d.ts +6 -0
  92. package/dist/util/fs.d.ts.map +1 -0
  93. package/dist/util/fs.js +24 -0
  94. package/dist/util/fs.js.map +1 -0
  95. package/dist/util/paths.d.ts +16 -0
  96. package/dist/util/paths.d.ts.map +1 -0
  97. package/dist/util/paths.js +19 -0
  98. package/dist/util/paths.js.map +1 -0
  99. package/dist/visualize/html.d.ts +13 -0
  100. package/dist/visualize/html.d.ts.map +1 -0
  101. package/dist/visualize/html.js +374 -0
  102. package/dist/visualize/html.js.map +1 -0
  103. package/dist/visualize/stats.d.ts +21 -0
  104. package/dist/visualize/stats.d.ts.map +1 -0
  105. package/dist/visualize/stats.js +45 -0
  106. package/dist/visualize/stats.js.map +1 -0
  107. package/documents.json +64 -0
  108. package/package.json +65 -0
  109. package/scaffold/.ai-spector/.docflow/config/analyze.graphify.json +40 -0
  110. package/scaffold/.ai-spector/.docflow/config/completeness-rules.basic-design.json +18 -0
  111. package/scaffold/.ai-spector/.docflow/config/completeness-rules.detail-design.json +57 -0
  112. package/scaffold/.ai-spector/.docflow/config/completeness-rules.srs.json +72 -0
  113. package/scaffold/.ai-spector/.docflow/config/dag.basic-design.json +38 -0
  114. package/scaffold/.ai-spector/.docflow/config/dag.detail-design.json +64 -0
  115. package/scaffold/.ai-spector/.docflow/config/dag.srs.json +87 -0
  116. package/scaffold/.ai-spector/.docflow/config/data-source.json +5 -0
  117. package/scaffold/.ai-spector/.docflow/config/index.docs.json +22 -0
  118. package/scaffold/.ai-spector/.docflow/config/workflow.dependencies.json +271 -0
  119. package/scaffold/.ai-spector/.docflow/extract/patch.example.json +20 -0
  120. package/scaffold/.ai-spector/.docflow/state.json +11 -0
  121. package/scaffold/.ai-spector/docflow.config.json +7 -0
  122. package/scaffold/.ai-spector/index/README.md +18 -0
  123. package/scaffold/.ai-spector/index/basic-design.md +5 -0
  124. package/scaffold/.ai-spector/index/srs.md +5 -0
  125. package/scaffold/.cursor/commands/_cli-failures.md +110 -0
  126. package/scaffold/.cursor/commands/_graph.md +48 -0
  127. package/scaffold/.cursor/commands/_prerequisites.md +48 -0
  128. package/scaffold/.cursor/commands/_workflow.md +50 -0
  129. package/scaffold/.cursor/commands/analyze.md +92 -0
  130. package/scaffold/.cursor/commands/generate-basic-design.md +26 -0
  131. package/scaffold/.cursor/commands/generate-detail-design.md +19 -0
  132. package/scaffold/.cursor/commands/generate-srs.md +63 -0
  133. package/scaffold/.cursor/commands/graph-impact.md +45 -0
  134. package/scaffold/.cursor/commands/index-docs.md +36 -0
  135. package/scaffold/.cursor/commands/sync-graph.md +30 -0
  136. package/scaffold/.cursor/commands/validate-graph.md +28 -0
  137. package/scaffold/.cursor/commands/visualize-graph.md +24 -0
  138. package/scaffold/.cursor/skills/ai-spector/SKILL.md +39 -0
  139. package/scaffold/docs/data-source/README.md +7 -0
  140. package/schemas/rules.impact.json +17 -0
  141. package/schemas/rules.traceability.json +30 -0
  142. package/schemas/schema.extract-patch.json +19 -0
  143. package/schemas/schema.graph.json +83 -0
  144. package/schemas/schema.knowledge.json +107 -0
  145. package/templates/basic_design/db-design-template.md +177 -0
  146. package/templates/basic_design/detail-api-template.md +278 -0
  147. package/templates/basic_design/detail-screen-template.md +281 -0
  148. package/templates/basic_design/list-api-template.md +130 -0
  149. package/templates/basic_design/list-screen-template.md +242 -0
  150. package/templates/detail_design/common/architecture-overview-template.md +302 -0
  151. package/templates/detail_design/common/deployment-infrastructure-template.md +461 -0
  152. package/templates/detail_design/common/error-handling-patterns-template.md +460 -0
  153. package/templates/detail_design/common/integration-patterns-template.md +410 -0
  154. package/templates/detail_design/common/performance-standards-template.md +406 -0
  155. package/templates/detail_design/common/security-patterns-template.md +395 -0
  156. package/templates/detail_design/feature-detail-design-template.md +773 -0
  157. package/templates/detail_design/feature-list-template.md +39 -0
  158. package/templates/srs/1-introduction.md +58 -0
  159. package/templates/srs/2-overall-description.md +91 -0
  160. package/templates/srs/3-use-case-detail-template.md +142 -0
  161. package/templates/srs/3-use-cases.md +53 -0
  162. package/templates/srs/4-system-feature-detail-template.md +131 -0
  163. package/templates/srs/4-system-features-list-template.md +39 -0
  164. package/templates/srs/5-data-requirements.md +59 -0
  165. package/templates/srs/6-external-interfaces.md +56 -0
  166. package/templates/srs/7-quality-attributes.md +74 -0
  167. package/templates/srs/8-internationalization.md +36 -0
  168. package/templates/srs/9-other-requirements.md +46 -0
@@ -0,0 +1,773 @@
1
+ # Detail Design: <Feature Name>
2
+
3
+ > This document is the **detail spec for one feature**. It describes the detailed design and implementation approach for <Feature Name>, including component design, sequence diagrams, API specifications, database schema, UI design, and implementation considerations.
4
+ >
5
+ > For the list of all features, see [Detail Design: Feature List](feature-list-template.md).
6
+
7
+ **Source Requirements:** SRS Section 4.X - <Feature Name>
8
+
9
+ **Related Documents:**
10
+ - [Feature List](feature-list-template.md) — index of all features
11
+ - [Architecture Overview](common/architecture-overview-template.md)
12
+ - [Security Patterns](common/security-patterns-template.md)
13
+ - [Error Handling Patterns](common/error-handling-patterns-template.md)
14
+ - [Performance Standards](common/performance-standards-template.md)
15
+ - [Integration Patterns](common/integration-patterns-template.md)
16
+ - [Deployment & Infrastructure](common/deployment-infrastructure-template.md)
17
+ - [Basic Design - API Design](../../basic_design/api-design-template.md)
18
+ - [Basic Design - Database Design](../../basic_design/db-design-template.md)
19
+ - [Basic Design - Mockup Screens](../../basic_design/mockup-screens-template.md)
20
+
21
+ ---
22
+
23
+ ## 1. Feature Implementation Overview
24
+
25
+ ### 1.1 Feature Summary
26
+
27
+ **Feature Name:** <Feature Name>
28
+
29
+ **SRS Reference:** SRS Section 4.X
30
+
31
+ **Priority:** <High/Medium/Low>
32
+
33
+ **Brief Description:**
34
+ > Provide a concise description of how this feature will be implemented at a high level.
35
+
36
+ **Implementation Approach:**
37
+ > Describe the overall approach to implementing this feature (e.g., microservice, module, component).
38
+
39
+ **Architecture Reference:**
40
+ > Reference the [Architecture Overview](common/architecture-overview-template.md) for system-wide architecture patterns.
41
+
42
+ ### 1.2 Design Decisions
43
+
44
+ **Key Design Decisions:**
45
+
46
+ | Decision | Rationale | Alternatives Considered |
47
+ |----------|-----------|------------------------|
48
+ | <Decision 1> | <Why this approach> | <Alternative 1, Alternative 2> |
49
+ | <Decision 2> | <Why this approach> | <Alternative 1, Alternative 2> |
50
+
51
+ **Technology Choices:**
52
+ - <Technology 1>: <Reason>
53
+ - <Technology 2>: <Reason>
54
+
55
+ ### 1.3 Dependencies
56
+
57
+ **Internal Dependencies:**
58
+ - <Feature/Module 1>: <Dependency description>
59
+ - <Feature/Module 2>: <Dependency description>
60
+
61
+ **External Dependencies:**
62
+ - <External Service 1>: <Dependency description>
63
+ - <External Service 2>: <Dependency description>
64
+
65
+ **Infrastructure Dependencies:**
66
+ - <Infrastructure Component 1>: <Dependency description>
67
+ - <Infrastructure Component 2>: <Dependency description>
68
+
69
+ ---
70
+
71
+ ## 2. Component Design
72
+
73
+ ### 2.1 Component Overview
74
+
75
+ > Describe the components/modules needed to implement this feature.
76
+
77
+ **Component Diagram:**
78
+
79
+ ```mermaid
80
+ C4Component
81
+ title <Feature Name> Component Diagram
82
+
83
+ Container_Boundary(featureBoundary, "<Feature Name>") {
84
+ Component(controller, "<Feature> Controller", "Express Router", "Handles HTTP requests")
85
+ Component(service, "<Feature> Service", "Business Logic", "Implements business rules")
86
+ Component(repository, "<Feature> Repository", "Data Access", "Database operations")
87
+ Component(validator, "<Feature> Validator", "Validation", "Validates input")
88
+ ComponentDb(database, "Database")
89
+ }
90
+
91
+ System_Ext(externalService, "External Service")
92
+
93
+ Rel(controller, validator, "Uses")
94
+ Rel(controller, service, "Calls")
95
+ Rel(service, repository, "Uses")
96
+ Rel(repository, database, "Reads from and writes to")
97
+ Rel(service, externalService, "Calls")
98
+ ```
99
+
100
+ ### 2.2 Component Responsibilities
101
+
102
+ **<Component Name>:**
103
+ - **Purpose:** <What this component does>
104
+ - **Responsibilities:**
105
+ - <Responsibility 1>
106
+ - <Responsibility 2>
107
+ - <Responsibility 3>
108
+ - **Interfaces:**
109
+ - Input: <Input description>
110
+ - Output: <Output description>
111
+ - **Dependencies:** <Other components/services>
112
+
113
+ ### 2.3 Class Design
114
+
115
+ **Class Diagram (if applicable):**
116
+
117
+ ```mermaid
118
+ classDiagram
119
+ class FeatureController {
120
+ +handleRequest()
121
+ +validateInput()
122
+ +handleError()
123
+ }
124
+
125
+ class FeatureService {
126
+ +processBusinessLogic()
127
+ +validateBusinessRules()
128
+ +handleExceptions()
129
+ }
130
+
131
+ class FeatureRepository {
132
+ +create()
133
+ +read()
134
+ +update()
135
+ +delete()
136
+ }
137
+
138
+ FeatureController --> FeatureService
139
+ FeatureService --> FeatureRepository
140
+ ```
141
+
142
+ **Key Classes:**
143
+
144
+ | Class | Purpose | Key Methods |
145
+ |-------|---------|-------------|
146
+ | `<Class Name>` | <Purpose> | `<method1()>, <method2()>` |
147
+ | `<Class Name>` | <Purpose> | `<method1()>, <method2()>` |
148
+
149
+ ---
150
+
151
+ ## 3. Sequence Diagrams
152
+
153
+ ### 3.1 Primary Flow: <Use Case Name>
154
+
155
+ **SRS Reference:** SRS Section 4.X.X - <Use Case>
156
+
157
+ **Sequence Diagram:**
158
+
159
+ ```mermaid
160
+ sequenceDiagram
161
+ participant User as User
162
+ participant UI as UI Component
163
+ participant API as API Gateway
164
+ participant Service as Feature Service
165
+ participant DB as Database
166
+ participant Ext as External Service
167
+
168
+ User->>UI: <User Action>
169
+ UI->>API: HTTP Request
170
+ API->>API: Validate & Authenticate
171
+ API->>Service: Call Service Method
172
+ Service->>Service: Business Logic
173
+ Service->>DB: Database Query
174
+ DB-->>Service: Result
175
+ alt External Service Needed
176
+ Service->>Ext: External API Call
177
+ Ext-->>Service: Response
178
+ end
179
+ Service-->>API: Service Response
180
+ API-->>UI: HTTP Response
181
+ UI-->>User: Display Result
182
+ ```
183
+
184
+ **Flow Description:**
185
+ 1. <Step 1>
186
+ 2. <Step 2>
187
+ 3. <Step 3>
188
+
189
+ ### 3.2 Alternative Flow: <Alternative Scenario>
190
+
191
+ **SRS Reference:** SRS Section 4.X.X - <Alternative Flow>
192
+
193
+ **Sequence Diagram:**
194
+
195
+ ```mermaid
196
+ sequenceDiagram
197
+ participant User as User
198
+ participant UI as UI Component
199
+ participant API as API Gateway
200
+ participant Service as Feature Service
201
+ participant DB as Database
202
+
203
+ User->>UI: <User Action>
204
+ UI->>API: HTTP Request
205
+ API->>API: Validate & Authenticate
206
+ API->>Service: Call Service Method
207
+ Service->>Service: Business Logic
208
+ Service->>DB: Database Query
209
+ DB-->>Service: Error
210
+ Service-->>API: Error Response
211
+ API-->>UI: HTTP Error Response
212
+ UI-->>User: Display Error
213
+ ```
214
+
215
+ ### 3.3 Error Flow: <Error Scenario>
216
+
217
+ **SRS Reference:** SRS Section 4.X.X - <Error Handling>
218
+
219
+ > Describe error handling flow. Reference [Error Handling Patterns](common/error-handling-patterns-template.md) for standard error handling.
220
+
221
+ ---
222
+
223
+ ## 4. API Design
224
+
225
+ ### 4.1 API Overview
226
+
227
+ **Base Path:** `/api/v1/<feature>`
228
+
229
+ **Authentication:** Required (Reference [Security Patterns](common/security-patterns-template.md))
230
+
231
+ **API Reference:** See [Basic Design - API Design](../../basic_design/api-design-template.md) for API design standards.
232
+
233
+ ### 4.2 Endpoints
234
+
235
+ #### 4.2.1 `POST /api/v1/<feature>`
236
+
237
+ **Summary:** <Create resource>
238
+
239
+ **SRS Reference:** SRS Section 4.X.X - <Requirement>
240
+
241
+ **Operation ID:** `create<Resource>`
242
+
243
+ **Authentication:** Required
244
+
245
+ **Request:**
246
+
247
+ **Headers:**
248
+ ```
249
+ Authorization: Bearer <token>
250
+ Content-Type: application/json
251
+ ```
252
+
253
+ **Body Schema:**
254
+ ```json
255
+ {
256
+ "field1": "<type>",
257
+ "field2": "<type>",
258
+ "field3": "<type>"
259
+ }
260
+ ```
261
+
262
+ **Field Descriptions:**
263
+
264
+ | Field | Type | Required | Validation | Description |
265
+ |-------|------|----------|------------|-------------|
266
+ | `field1` | `<type>` | Yes | <Validation rules> | <Description> |
267
+ | `field2` | `<type>` | No | <Validation rules> | <Description> |
268
+
269
+ **Example Request:**
270
+ ```json
271
+ {
272
+ "field1": "value1",
273
+ "field2": "value2"
274
+ }
275
+ ```
276
+
277
+ **Responses:**
278
+
279
+ **201 Created:**
280
+ ```json
281
+ {
282
+ "id": "resource123",
283
+ "field1": "value1",
284
+ "field2": "value2",
285
+ "created_at": "2025-01-15T10:30:00Z"
286
+ }
287
+ ```
288
+
289
+ **400 Bad Request:**
290
+ > Reference [Error Handling Patterns](common/error-handling-patterns-template.md) for standard error format.
291
+
292
+ **401 Unauthorized:**
293
+ > Reference [Security Patterns](common/security-patterns-template.md) for authentication errors.
294
+
295
+ #### 4.2.2 `GET /api/v1/<feature>/{id}`
296
+
297
+ **Summary:** <Get resource>
298
+
299
+ **SRS Reference:** SRS Section 4.X.X - <Requirement>
300
+
301
+ **Operation ID:** `get<Resource>`
302
+
303
+ **Authentication:** Required
304
+
305
+ **Path Parameters:**
306
+
307
+ | Parameter | Type | Required | Description |
308
+ |-----------|------|----------|-------------|
309
+ | `id` | string | Yes | Resource identifier |
310
+
311
+ **Query Parameters:**
312
+
313
+ | Parameter | Type | Required | Description |
314
+ |-----------|------|----------|-------------|
315
+ | `include` | string | No | Related resources to include |
316
+ | `fields` | string | No | Fields to return |
317
+
318
+ **Responses:**
319
+
320
+ **200 OK:**
321
+ ```json
322
+ {
323
+ "id": "resource123",
324
+ "field1": "value1",
325
+ "field2": "value2",
326
+ "created_at": "2025-01-15T10:30:00Z"
327
+ }
328
+ ```
329
+
330
+ **404 Not Found:**
331
+ > Reference [Error Handling Patterns](common/error-handling-patterns-template.md).
332
+
333
+ ### 4.3 API Security
334
+
335
+ **Security Requirements:**
336
+ > Reference [Security Patterns](common/security-patterns-template.md) for:
337
+ - Authentication mechanism
338
+ - Authorization requirements
339
+ - Input validation
340
+ - Rate limiting
341
+
342
+ **Feature-Specific Security:**
343
+ - <Security requirement 1>
344
+ - <Security requirement 2>
345
+
346
+ ---
347
+
348
+ ## 5. Database Design
349
+
350
+ ### 5.1 Database Schema
351
+
352
+ **SRS Reference:** SRS Section 5 (Data Requirements)
353
+
354
+ **Database Reference:** See [Basic Design - Database Design](../../basic_design/db-design-template.md) for database design standards.
355
+
356
+ **Entity Relationship Diagram:**
357
+
358
+ ```mermaid
359
+ erDiagram
360
+ ENTITY1 ||--o{ ENTITY2 : "relationship"
361
+ ENTITY1 {
362
+ string id PK
363
+ string field1
364
+ datetime created_at
365
+ }
366
+ ENTITY2 {
367
+ string id PK
368
+ string entity1_id FK
369
+ string field2
370
+ }
371
+ ```
372
+
373
+ ### 5.2 Tables
374
+
375
+ #### 5.2.1 `<table_name>`
376
+
377
+ **Purpose:**
378
+ > Describe what this table stores and its role in this feature.
379
+
380
+ **Primary Key:** `<field_name>` (<data_type>)
381
+
382
+ **Fields:**
383
+
384
+ | Field Name | Data Type | Constraints | Description |
385
+ |------------|-----------|-------------|-------------|
386
+ | `<field_name>` | `<type>` | `<UNIQUE/NOT NULL>` | <Description> |
387
+ | `<field_name>` | `<type>` | `<constraints>` | <Description> |
388
+
389
+ **Indexes:**
390
+ - `<index_name>` on `<field_name>` (<purpose>)
391
+
392
+ **Foreign Keys:**
393
+ - `<field_name>` → `<referenced_table>.<referenced_field>` (<relationship description>)
394
+
395
+ **Business Rules:**
396
+ - <Business rule 1>
397
+ - <Business rule 2>
398
+
399
+ ### 5.3 Data Access Patterns
400
+
401
+ **Read Patterns:**
402
+ - <Pattern 1>: <Description>
403
+ - <Pattern 2>: <Description>
404
+
405
+ **Write Patterns:**
406
+ - <Pattern 1>: <Description>
407
+ - <Pattern 2>: <Description>
408
+
409
+ **Query Optimization:**
410
+ > Reference [Performance Standards](common/performance-standards-template.md) for database optimization guidelines.
411
+
412
+ ---
413
+
414
+ ## 6. UI Design
415
+
416
+ ### 6.1 Screen Overview
417
+
418
+ **SRS Reference:** SRS Section 6.1 (User Interfaces)
419
+
420
+ **UI Reference:** See [Basic Design - Mockup Screens](../../basic_design/mockup-screens-template.md) for UI design standards.
421
+
422
+ **Screens:**
423
+ - <Screen 1>: <Purpose>
424
+ - <Screen 2>: <Purpose>
425
+ - <Screen 3>: <Purpose>
426
+
427
+ ### 6.2 Screen: <Screen Name>
428
+
429
+ **Purpose:**
430
+ > Describe the purpose of this screen and what users can accomplish.
431
+
432
+ **User Role:** <Role that uses this screen>
433
+
434
+ **SRS Reference:** SRS Section 4.X.X - <Feature/Requirement>
435
+
436
+ **Wireframe Reference:**
437
+ > Link to wireframe or mockup image, or provide ASCII wireframe.
438
+
439
+ **Layout Structure:**
440
+
441
+ | Component | Position | Width/Height | Description |
442
+ |-----------|----------|--------------|-------------|
443
+ | **Header** | Top | 100% × 60px | <Description> |
444
+ | **Main Content** | Center | flex: 1 | <Description> |
445
+ | **Sidebar** | Right | 300px × auto | <Description> |
446
+
447
+ **Key Components:**
448
+
449
+ **<Component Name>:**
450
+ - **Purpose:** <What it does>
451
+ - **Visual Representation:**
452
+ ```
453
+ ┌─────────────────────────────┐
454
+ │ [Icon] Title Text │
455
+ │ ─────────────────────────── │
456
+ │ Content area │
457
+ │ [Button] [Button] │
458
+ └─────────────────────────────┘
459
+ ```
460
+ - **Elements:**
461
+ - <Element 1>: <Description>
462
+ - <Element 2>: <Description>
463
+ - **Interactions:**
464
+ - <Interaction 1>: <Description>
465
+ - <Interaction 2>: <Description>
466
+
467
+ ### 6.3 User Flows
468
+
469
+ **Primary Flow:**
470
+ 1. <Step 1>
471
+ 2. <Step 2>
472
+ 3. <Step 3>
473
+
474
+ **Alternative Flow:**
475
+ 1. <Step 1>
476
+ 2. <Step 2>
477
+
478
+ ### 6.4 Responsive Design
479
+
480
+ **Breakpoints:**
481
+ - Mobile: <Width>
482
+ - Tablet: <Width>
483
+ - Desktop: <Width>
484
+
485
+ **Mobile Adaptations:**
486
+ - <Adaptation 1>
487
+ - <Adaptation 2>
488
+
489
+ ---
490
+
491
+ ## 7. Security Considerations
492
+
493
+ ### 7.1 Authentication & Authorization
494
+
495
+ **Reference:** [Security Patterns](common/security-patterns-template.md)
496
+
497
+ **Feature-Specific Requirements:**
498
+ - <Requirement 1>: <Description>
499
+ - <Requirement 2>: <Description>
500
+
501
+ **Authorization Rules:**
502
+ - <Rule 1>: <Who can do what>
503
+ - <Rule 2>: <Who can do what>
504
+
505
+ ### 7.2 Data Protection
506
+
507
+ **Sensitive Data:**
508
+ - <Data type 1>: <Protection method>
509
+ - <Data type 2>: <Protection method>
510
+
511
+ **Encryption:**
512
+ - <What is encrypted>: <Method>
513
+ - <What is encrypted>: <Method>
514
+
515
+ ### 7.3 Input Validation
516
+
517
+ **Validation Rules:**
518
+ - <Field 1>: <Validation rules>
519
+ - <Field 2>: <Validation rules>
520
+
521
+ **Reference:** [Security Patterns](common/security-patterns-template.md) for input validation standards.
522
+
523
+ ---
524
+
525
+ ## 8. Integration Details
526
+
527
+ ### 8.1 Internal Integrations
528
+
529
+ **Integration with <Feature/Module>:**
530
+ - **Purpose:** <Why this integration is needed>
531
+ - **Method:** <API call/Event/Message queue>
532
+ - **Data Flow:** <Description>
533
+ - **Error Handling:** <How errors are handled>
534
+
535
+ ### 8.2 External Integrations
536
+
537
+ **Integration with <External Service>:**
538
+ - **Purpose:** <Why this integration is needed>
539
+ - **Method:** <REST API/Webhook/OAuth>
540
+ - **Authentication:** <Method>
541
+ - **Data Mapping:** <How data is transformed>
542
+ - **Error Handling:** <How errors are handled>
543
+ - **Retry Strategy:** <Retry configuration>
544
+
545
+ **Reference:** [Integration Patterns](common/integration-patterns-template.md) for integration standards.
546
+
547
+ ### 8.3 Event Publishing/Subscribing
548
+
549
+ **Events Published:**
550
+ - `<event.name>`: <Description>
551
+ ```json
552
+ {
553
+ "event_type": "event.name",
554
+ "data": {
555
+ "field1": "value1"
556
+ }
557
+ }
558
+ ```
559
+
560
+ **Events Subscribed:**
561
+ - `<event.name>`: <Description>
562
+ - **Handler:** <What happens when event is received>
563
+ - **Processing:** <How event is processed>
564
+
565
+ ---
566
+
567
+ ## 9. Error Handling
568
+
569
+ ### 9.1 Error Scenarios
570
+
571
+ **Reference:** [Error Handling Patterns](common/error-handling-patterns-template.md) for standard error handling.
572
+
573
+ **Feature-Specific Errors:**
574
+
575
+ | Error Code | HTTP Status | Condition | User Message |
576
+ |------------|-------------|-----------|--------------|
577
+ | `<FEATURE>_VALIDATION_ERROR` | 422 | <When it occurs> | <User-friendly message> |
578
+ | `<FEATURE>_NOT_FOUND` | 404 | <When it occurs> | <User-friendly message> |
579
+ | `<FEATURE>_CONFLICT` | 409 | <When it occurs> | <User-friendly message> |
580
+
581
+ ### 9.2 Error Handling Flow
582
+
583
+ **Error Handling Sequence:**
584
+
585
+ ```mermaid
586
+ sequenceDiagram
587
+ participant Service as Feature Service
588
+ participant ErrorHandler as Error Handler
589
+ participant Logger as Logger
590
+ participant Client as Client
591
+
592
+ Service->>Service: Error Occurs
593
+ Service->>ErrorHandler: Handle Error
594
+ ErrorHandler->>ErrorHandler: Map to Error Code
595
+ ErrorHandler->>Logger: Log Error
596
+ ErrorHandler->>Client: Return Error Response
597
+ ```
598
+
599
+ ### 9.3 Recovery Strategies
600
+
601
+ **Recovery Approaches:**
602
+ - <Error type 1>: <Recovery strategy>
603
+ - <Error type 2>: <Recovery strategy>
604
+
605
+ ---
606
+
607
+ ## 10. Performance Considerations
608
+
609
+ ### 10.1 Performance Requirements
610
+
611
+ **Reference:** [Performance Standards](common/performance-standards-template.md) for performance guidelines.
612
+
613
+ **Feature-Specific Targets:**
614
+ - API Response Time: <Target, e.g., P95 < 200ms>
615
+ - Database Query Time: <Target>
616
+ - Throughput: <Target RPS>
617
+
618
+ ### 10.2 Optimization Strategies
619
+
620
+ **Caching:**
621
+ - <What is cached>: <Cache strategy, TTL>
622
+ - <What is cached>: <Cache strategy, TTL>
623
+
624
+ **Database Optimization:**
625
+ - Indexes: <List of indexes>
626
+ - Query optimization: <Optimization techniques>
627
+ - Connection pooling: <Configuration>
628
+
629
+ **API Optimization:**
630
+ - Pagination: <Pagination strategy>
631
+ - Field selection: <Allow field selection>
632
+ - Compression: <Enable compression>
633
+
634
+ ### 10.3 Scalability
635
+
636
+ **Scaling Approach:**
637
+ - <Horizontal/Vertical>: <Description>
638
+ - Auto-scaling: <Configuration>
639
+ - Load distribution: <Strategy>
640
+
641
+ ---
642
+
643
+ ## 11. Testing Strategy
644
+
645
+ ### 11.1 Unit Testing
646
+
647
+ **Components to Test:**
648
+ - <Component 1>: <Test coverage>
649
+ - <Component 2>: <Test coverage>
650
+
651
+ **Test Cases:**
652
+ - <Test case 1>
653
+ - <Test case 2>
654
+
655
+ ### 11.2 Integration Testing
656
+
657
+ **Integration Points:**
658
+ - <Integration 1>: <Test scenarios>
659
+ - <Integration 2>: <Test scenarios>
660
+
661
+ ### 11.3 End-to-End Testing
662
+
663
+ **E2E Scenarios:**
664
+ - <Scenario 1>: <Steps>
665
+ - <Scenario 2>: <Steps>
666
+
667
+ ### 11.4 Performance Testing
668
+
669
+ **Performance Test Scenarios:**
670
+ - <Scenario 1>: <Load, expected performance>
671
+ - <Scenario 2>: <Load, expected performance>
672
+
673
+ ---
674
+
675
+ ## 12. Deployment Considerations
676
+
677
+ ### 12.1 Deployment Requirements
678
+
679
+ **Reference:** [Deployment & Infrastructure](common/deployment-infrastructure-template.md) for deployment standards.
680
+
681
+ **Feature-Specific Requirements:**
682
+ - <Requirement 1>
683
+ - <Requirement 2>
684
+
685
+ ### 12.2 Configuration
686
+
687
+ **Environment Variables:**
688
+ - `<VAR_NAME>`: <Purpose, default value>
689
+ - `<VAR_NAME>`: <Purpose, default value>
690
+
691
+ **Feature Flags:**
692
+ - `<flag_name>`: <Purpose, default value>
693
+
694
+ ### 12.3 Migration Strategy
695
+
696
+ **Database Migrations:**
697
+ - <Migration 1>: <Description>
698
+ - <Migration 2>: <Description>
699
+
700
+ **Data Migration:**
701
+ - <Migration task 1>: <Description>
702
+ - <Migration task 2>: <Description>
703
+
704
+ ---
705
+
706
+ ## 13. Monitoring and Observability
707
+
708
+ ### 13.1 Metrics
709
+
710
+ **Key Metrics:**
711
+ - <Metric 1>: <Purpose, threshold>
712
+ - <Metric 2>: <Purpose, threshold>
713
+
714
+ ### 13.2 Logging
715
+
716
+ **Log Events:**
717
+ - <Event 1>: <What to log>
718
+ - <Event 2>: <What to log>
719
+
720
+ **Log Format:**
721
+ > Follow standard logging format. Include request_id, user_id, feature context.
722
+
723
+ ### 13.3 Alerting
724
+
725
+ **Alerts:**
726
+ - <Alert condition 1>: <Threshold, action>
727
+ - <Alert condition 2>: <Threshold, action>
728
+
729
+ ---
730
+
731
+ ## 14. References
732
+
733
+ **Detail Design:**
734
+ - [Feature List](feature-list-template.md) — index of all features
735
+
736
+ **Common Design Documents:**
737
+ - [Architecture Overview](common/architecture-overview-template.md)
738
+ - [Security Patterns](common/security-patterns-template.md)
739
+ - [Error Handling Patterns](common/error-handling-patterns-template.md)
740
+ - [Performance Standards](common/performance-standards-template.md)
741
+ - [Integration Patterns](common/integration-patterns-template.md)
742
+ - [Deployment & Infrastructure](common/deployment-infrastructure-template.md)
743
+
744
+ **Basic Design Documents:**
745
+ - [API Design](../../basic_design/api-design-template.md)
746
+ - [Database Design](../../basic_design/db-design-template.md)
747
+ - [Mockup Screens](../../basic_design/mockup-screens-template.md)
748
+
749
+ **SRS References:**
750
+ - SRS Section 4.X: <Feature Name>
751
+ - SRS Section 5: Data Requirements
752
+ - SRS Section 6: External Interfaces
753
+ - SRS Section 7: Quality Attributes
754
+
755
+ ---
756
+
757
+ ## 15. Notes
758
+
759
+ **Implementation Notes:**
760
+ - <Note 1>
761
+ - <Note 2>
762
+
763
+ **Design Decisions:**
764
+ - <Decision 1>: <Rationale>
765
+ - <Decision 2>: <Rationale>
766
+
767
+ **Future Enhancements:**
768
+ - <Enhancement 1>
769
+ - <Enhancement 2>
770
+
771
+ **Open Questions:**
772
+ - <Question 1>
773
+ - <Question 2>