ai-spector 0.1.1

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 (63) hide show
  1. package/README.md +169 -0
  2. package/_templates/basic_design/db-design-template.md +177 -0
  3. package/_templates/basic_design/detail-api-template.md +278 -0
  4. package/_templates/basic_design/detail-screen-template.md +281 -0
  5. package/_templates/basic_design/list-api-template.md +130 -0
  6. package/_templates/basic_design/list-screen-template.md +242 -0
  7. package/_templates/detail_design/common/architecture-overview-template.md +302 -0
  8. package/_templates/detail_design/common/deployment-infrastructure-template.md +461 -0
  9. package/_templates/detail_design/common/error-handling-patterns-template.md +460 -0
  10. package/_templates/detail_design/common/integration-patterns-template.md +410 -0
  11. package/_templates/detail_design/common/performance-standards-template.md +406 -0
  12. package/_templates/detail_design/common/security-patterns-template.md +395 -0
  13. package/_templates/detail_design/feature-detail-design-template.md +773 -0
  14. package/_templates/detail_design/feature-list-template.md +39 -0
  15. package/_templates/srs/1-introduction.md +58 -0
  16. package/_templates/srs/2-overall-description.md +91 -0
  17. package/_templates/srs/3-use-case-detail-template.md +142 -0
  18. package/_templates/srs/3-use-cases.md +53 -0
  19. package/_templates/srs/4-system-feature-detail-template.md +131 -0
  20. package/_templates/srs/4-system-features-list-template.md +39 -0
  21. package/_templates/srs/5-data-requirements.md +59 -0
  22. package/_templates/srs/6-external-interfaces.md +56 -0
  23. package/_templates/srs/7-quality-attributes.md +74 -0
  24. package/_templates/srs/8-internationalization.md +36 -0
  25. package/_templates/srs/9-other-requirements.md +46 -0
  26. package/assets/cursor/commands/analyze.md +39 -0
  27. package/assets/cursor/commands/generate-detail-design.md +35 -0
  28. package/assets/cursor/commands/generate-srs.md +38 -0
  29. package/assets/cursor/skills/spec-writer/SKILL.md +33 -0
  30. package/assets/workflow/config/analyze.graphify.json +36 -0
  31. package/assets/workflow/config/completeness-rules.detail-design.json +57 -0
  32. package/assets/workflow/config/completeness-rules.srs.json +72 -0
  33. package/assets/workflow/config/dag.detail-design.json +64 -0
  34. package/assets/workflow/config/dag.srs.json +87 -0
  35. package/assets/workflow/state/state.template.json +26 -0
  36. package/assets/workflow/templates/basic_design/db-design-template.md +177 -0
  37. package/assets/workflow/templates/basic_design/detail-api-template.md +278 -0
  38. package/assets/workflow/templates/basic_design/detail-screen-template.md +281 -0
  39. package/assets/workflow/templates/basic_design/list-api-template.md +130 -0
  40. package/assets/workflow/templates/basic_design/list-screen-template.md +242 -0
  41. package/assets/workflow/templates/detail_design/common/architecture-overview-template.md +302 -0
  42. package/assets/workflow/templates/detail_design/common/deployment-infrastructure-template.md +461 -0
  43. package/assets/workflow/templates/detail_design/common/error-handling-patterns-template.md +460 -0
  44. package/assets/workflow/templates/detail_design/common/integration-patterns-template.md +410 -0
  45. package/assets/workflow/templates/detail_design/common/performance-standards-template.md +406 -0
  46. package/assets/workflow/templates/detail_design/common/security-patterns-template.md +395 -0
  47. package/assets/workflow/templates/detail_design/feature-detail-design-template.md +773 -0
  48. package/assets/workflow/templates/detail_design/feature-list-template.md +39 -0
  49. package/assets/workflow/templates/srs/1-introduction.md +58 -0
  50. package/assets/workflow/templates/srs/2-overall-description.md +91 -0
  51. package/assets/workflow/templates/srs/3-use-case-detail-template.md +142 -0
  52. package/assets/workflow/templates/srs/3-use-cases.md +53 -0
  53. package/assets/workflow/templates/srs/4-system-feature-detail-template.md +131 -0
  54. package/assets/workflow/templates/srs/4-system-features-list-template.md +39 -0
  55. package/assets/workflow/templates/srs/5-data-requirements.md +59 -0
  56. package/assets/workflow/templates/srs/6-external-interfaces.md +56 -0
  57. package/assets/workflow/templates/srs/7-quality-attributes.md +74 -0
  58. package/assets/workflow/templates/srs/8-internationalization.md +36 -0
  59. package/assets/workflow/templates/srs/9-other-requirements.md +46 -0
  60. package/bin/spec-writer.js +56 -0
  61. package/package.json +25 -0
  62. package/src/cli/helpers/fs.js +50 -0
  63. package/src/cli/init.js +178 -0
@@ -0,0 +1,406 @@
1
+ # Performance Standards: <Project Name>
2
+
3
+ > This document defines performance requirements, optimization strategies, caching approaches, and scalability patterns used across all features.
4
+
5
+ **Source Requirements:** SRS Section 7.2 (Performance Requirements)
6
+
7
+ ---
8
+
9
+ ## 1. Overview
10
+
11
+ **Purpose:**
12
+ > This document establishes performance standards and optimization guidelines that ensure the system meets performance requirements and scales effectively.
13
+
14
+ **Performance Principles:**
15
+ - Measure before optimizing
16
+ - Optimize bottlenecks, not everything
17
+ - Cache aggressively where appropriate
18
+ - Design for horizontal scalability
19
+ - Monitor and alert on performance metrics
20
+
21
+ ---
22
+
23
+ ## 2. Performance Requirements
24
+
25
+ ### 2.1 Response Time Targets
26
+
27
+ **API Response Times:**
28
+ - **P50 (Median):** <Target, e.g., < 100ms>
29
+ - **P95 (95th percentile):** <Target, e.g., < 200ms>
30
+ - **P99 (99th percentile):** <Target, e.g., < 500ms>
31
+ - **P99.9 (99.9th percentile):** <Target, e.g., < 1000ms>
32
+
33
+ **Page Load Times:**
34
+ - **First Contentful Paint (FCP):** <Target, e.g., < 1.5s>
35
+ - **Largest Contentful Paint (LCP):** <Target, e.g., < 2.5s>
36
+ - **Time to Interactive (TTI):** <Target, e.g., < 3.5s>
37
+
38
+ **Database Query Times:**
39
+ - **Simple queries:** <Target, e.g., < 10ms>
40
+ - **Complex queries:** <Target, e.g., < 100ms>
41
+ - **Aggregation queries:** <Target, e.g., < 500ms>
42
+
43
+ ### 2.2 Throughput Targets
44
+
45
+ **API Throughput:**
46
+ - **Requests per second (RPS):** <Target, e.g., 1000 RPS>
47
+ - **Concurrent users:** <Target, e.g., 10,000 concurrent>
48
+ - **Peak load handling:** <Target, e.g., 3x normal load>
49
+
50
+ **Database Throughput:**
51
+ - **Transactions per second (TPS):** <Target>
52
+ - **Read operations per second:** <Target>
53
+ - **Write operations per second:** <Target>
54
+
55
+ ### 2.3 Resource Utilization
56
+
57
+ **CPU Usage:**
58
+ - **Average:** <Target, e.g., < 70%>
59
+ - **Peak:** <Target, e.g., < 90%>
60
+
61
+ **Memory Usage:**
62
+ - **Average:** <Target, e.g., < 80%>
63
+ - **Peak:** <Target, e.g., < 90%>
64
+
65
+ **Database Connections:**
66
+ - **Connection pool size:** <Configuration>
67
+ - **Max connections:** <Limit>
68
+
69
+ ---
70
+
71
+ ## 3. Caching Strategies
72
+
73
+ ### 3.1 Caching Layers
74
+
75
+ **Multi-Layer Caching:**
76
+
77
+ ```mermaid
78
+ flowchart TD
79
+ Client[Client] -->|Request| CDN[CDN Cache]
80
+ CDN -->|Cache Miss| AppCache[Application Cache]
81
+ AppCache -->|Cache Miss| Database[(Database)]
82
+ Database -->|Store| AppCache
83
+ AppCache -->|Store| CDN
84
+ CDN -->|Response| Client
85
+ ```
86
+
87
+ **Caching Layers:**
88
+ 1. **CDN Cache:** Static assets, API responses
89
+ 2. **Application Cache:** In-memory cache (Redis, Memcached)
90
+ 3. **Database Cache:** Query result cache
91
+ 4. **Browser Cache:** Client-side caching
92
+
93
+ ### 3.2 Cache Types
94
+
95
+ **Cache-Aside (Lazy Loading):**
96
+ ```
97
+ 1. Check cache
98
+ 2. If cache miss, fetch from database
99
+ 3. Store in cache
100
+ 4. Return data
101
+ ```
102
+
103
+ **Write-Through:**
104
+ ```
105
+ 1. Write to database
106
+ 2. Write to cache
107
+ 3. Return success
108
+ ```
109
+
110
+ **Write-Back (Write-Behind):**
111
+ ```
112
+ 1. Write to cache
113
+ 2. Return success immediately
114
+ 3. Asynchronously write to database
115
+ ```
116
+
117
+ **Refresh-Ahead:**
118
+ ```
119
+ 1. Proactively refresh cache before expiration
120
+ 2. Serve from cache
121
+ ```
122
+
123
+ ### 3.3 Cache Invalidation
124
+
125
+ **Invalidation Strategies:**
126
+ - **Time-based expiration:** Cache expires after TTL
127
+ - **Event-based invalidation:** Invalidate on data changes
128
+ - **Tag-based invalidation:** Invalidate by tags
129
+ - **Manual invalidation:** Explicit cache clearing
130
+
131
+ **Cache Keys:**
132
+ - Format: `<resource>:<identifier>:<version>`
133
+ - Example: `user:123:v1`, `product:456:cache`
134
+
135
+ **TTL Configuration:**
136
+ - **Static data:** Long TTL (hours/days)
137
+ - **Semi-static data:** Medium TTL (minutes)
138
+ - **Dynamic data:** Short TTL (seconds) or no cache
139
+
140
+ ### 3.4 What to Cache
141
+
142
+ **Good Candidates:**
143
+ - Frequently accessed data
144
+ - Expensive computations
145
+ - Database query results
146
+ - API responses
147
+ - Static content
148
+ - User sessions
149
+
150
+ **Don't Cache:**
151
+ - Frequently changing data
152
+ - User-specific sensitive data (unless encrypted)
153
+ - Large binary data
154
+ - Real-time data
155
+
156
+ ---
157
+
158
+ ## 4. Database Optimization
159
+
160
+ ### 4.1 Query Optimization
161
+
162
+ **Optimization Techniques:**
163
+ - Use appropriate indexes
164
+ - Avoid N+1 queries
165
+ - Use query pagination
166
+ - Select only needed columns
167
+ - Use database-specific optimizations
168
+
169
+ **Indexing Strategy:**
170
+ - Index frequently queried columns
171
+ - Index foreign keys
172
+ - Composite indexes for multi-column queries
173
+ - Monitor index usage
174
+ - Remove unused indexes
175
+
176
+ ### 4.2 Connection Pooling
177
+
178
+ **Connection Pool Configuration:**
179
+ - **Min connections:** <Number>
180
+ - **Max connections:** <Number>
181
+ - **Idle timeout:** <Duration>
182
+ - **Connection timeout:** <Duration>
183
+
184
+ **Best Practices:**
185
+ - Reuse connections
186
+ - Monitor pool usage
187
+ - Set appropriate pool size
188
+ - Handle connection failures gracefully
189
+
190
+ ### 4.3 Database Scaling
191
+
192
+ **Scaling Strategies:**
193
+ - **Read replicas:** Distribute read load
194
+ - **Sharding:** Partition data across databases
195
+ - **Partitioning:** Partition tables by range/hash
196
+ - **Archiving:** Move old data to archive storage
197
+
198
+ ---
199
+
200
+ ## 5. API Optimization
201
+
202
+ ### 5.1 Response Optimization
203
+
204
+ **Techniques:**
205
+ - **Pagination:** Limit response size
206
+ - **Field selection:** Allow clients to request specific fields
207
+ - **Compression:** Gzip/Brotli compression
208
+ - **Response caching:** Cache API responses
209
+ - **Batch requests:** Combine multiple requests
210
+
211
+ ### 5.2 Request Optimization
212
+
213
+ **Techniques:**
214
+ - **Request validation:** Fail fast on invalid requests
215
+ - **Rate limiting:** Prevent abuse
216
+ - **Request batching:** Combine multiple operations
217
+ - **Async processing:** Process long-running tasks asynchronously
218
+
219
+ ### 5.3 API Design for Performance
220
+
221
+ **Best Practices:**
222
+ - Use appropriate HTTP methods
223
+ - Implement proper status codes
224
+ - Use HTTP caching headers
225
+ - Support conditional requests (ETag, Last-Modified)
226
+ - Provide bulk operations endpoints
227
+
228
+ ---
229
+
230
+ ## 6. Scalability Patterns
231
+
232
+ ### 6.1 Horizontal Scaling
233
+
234
+ **Approach:**
235
+ - Stateless application servers
236
+ - Load balancing
237
+ - Shared state in external store (Redis, database)
238
+ - Auto-scaling based on metrics
239
+
240
+ **Scaling Triggers:**
241
+ - CPU utilization > threshold
242
+ - Memory utilization > threshold
243
+ - Request queue length > threshold
244
+ - Response time > threshold
245
+
246
+ ### 6.2 Vertical Scaling
247
+
248
+ **Approach:**
249
+ - Increase server resources (CPU, RAM)
250
+ - Upgrade database instance
251
+ - Optimize application code
252
+ - Use faster hardware
253
+
254
+ **When to Use:**
255
+ - Small to medium scale
256
+ - Quick performance boost needed
257
+ - Cost-effective for current load
258
+
259
+ ### 6.3 Auto-Scaling Configuration
260
+
261
+ **Scaling Policies:**
262
+ - **Scale-up:** Add instances when metrics exceed threshold
263
+ - **Scale-down:** Remove instances when metrics below threshold
264
+ - **Cooldown period:** Wait before scaling again
265
+ - **Min/Max instances:** Set boundaries
266
+
267
+ ---
268
+
269
+ ## 7. Performance Monitoring
270
+
271
+ ### 7.1 Key Metrics
272
+
273
+ **Application Metrics:**
274
+ - Response time (P50, P95, P99, P99.9)
275
+ - Request rate (RPS)
276
+ - Error rate
277
+ - Active connections
278
+ - Queue length
279
+
280
+ **Infrastructure Metrics:**
281
+ - CPU utilization
282
+ - Memory utilization
283
+ - Disk I/O
284
+ - Network I/O
285
+ - Database connections
286
+
287
+ **Business Metrics:**
288
+ - User actions per second
289
+ - Transaction completion rate
290
+ - User satisfaction scores
291
+
292
+ ### 7.2 Monitoring Tools
293
+
294
+ **Tools:**
295
+ - <APM tool, e.g., New Relic, Datadog>
296
+ - <Application logs>
297
+ - <Database monitoring>
298
+ - <Infrastructure monitoring>
299
+
300
+ **Dashboards:**
301
+ - Real-time performance dashboard
302
+ - Historical performance trends
303
+ - Error rate dashboard
304
+ - Resource utilization dashboard
305
+
306
+ ### 7.3 Alerting
307
+
308
+ **Alert Conditions:**
309
+ - Response time > threshold
310
+ - Error rate > threshold
311
+ - Resource utilization > threshold
312
+ - Service availability < threshold
313
+
314
+ **Alert Channels:**
315
+ - Email notifications
316
+ - Slack/Teams notifications
317
+ - PagerDuty escalations
318
+ - SMS notifications
319
+
320
+ ---
321
+
322
+ ## 8. Performance Testing
323
+
324
+ ### 8.1 Testing Types
325
+
326
+ **Load Testing:**
327
+ - Test under expected load
328
+ - Identify performance bottlenecks
329
+ - Verify system meets requirements
330
+
331
+ **Stress Testing:**
332
+ - Test beyond normal capacity
333
+ - Find breaking points
334
+ - Test system recovery
335
+
336
+ **Spike Testing:**
337
+ - Test sudden load increases
338
+ - Verify system handles spikes
339
+ - Test auto-scaling
340
+
341
+ **Endurance Testing:**
342
+ - Test over extended period
343
+ - Identify memory leaks
344
+ - Test resource stability
345
+
346
+ ### 8.2 Performance Test Scenarios
347
+
348
+ **Scenarios:**
349
+ - Normal load scenario
350
+ - Peak load scenario
351
+ - Gradual load increase
352
+ - Sudden load spike
353
+ - Sustained high load
354
+
355
+ ### 8.3 Performance Benchmarks
356
+
357
+ **Baseline Metrics:**
358
+ - Establish baseline performance
359
+ - Document expected performance
360
+ - Set performance targets
361
+ - Track performance over time
362
+
363
+ ---
364
+
365
+ ## 9. Optimization Checklist
366
+
367
+ **Application Optimization:**
368
+ - [ ] Database queries optimized
369
+ - [ ] Appropriate indexes created
370
+ - [ ] Caching implemented
371
+ - [ ] N+1 queries eliminated
372
+ - [ ] Pagination implemented
373
+ - [ ] Response compression enabled
374
+ - [ ] Unnecessary data processing removed
375
+ - [ ] Async processing for long operations
376
+
377
+ **Infrastructure Optimization:**
378
+ - [ ] Connection pooling configured
379
+ - [ ] Load balancing configured
380
+ - [ ] Auto-scaling configured
381
+ - [ ] CDN configured
382
+ - [ ] Caching layer configured
383
+ - [ ] Monitoring and alerting set up
384
+
385
+ ---
386
+
387
+ ## 10. References
388
+
389
+ **Related Documents:**
390
+ - [Architecture Overview](../common/architecture-overview-template.md)
391
+ - [Feature Detail Design Template](../feature-detail-design-template.md)
392
+
393
+ **SRS References:**
394
+ - SRS Section 7.2: Performance Requirements
395
+
396
+ ---
397
+
398
+ ## 11. Notes
399
+
400
+ **Performance Considerations:**
401
+ - <Consideration 1>
402
+ - <Consideration 2>
403
+
404
+ **Future Enhancements:**
405
+ - <Enhancement 1>
406
+ - <Enhancement 2>