speccrew 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.
- package/.speccrew/agents/speccrew-feature-designer.md +142 -0
- package/.speccrew/agents/speccrew-product-manager.md +61 -0
- package/.speccrew/agents/speccrew-system-designer.md +200 -0
- package/.speccrew/agents/speccrew-system-developer.md +238 -0
- package/.speccrew/agents/speccrew-task-worker.md +80 -0
- package/.speccrew/agents/speccrew-team-leader.md +92 -0
- package/.speccrew/agents/speccrew-test-manager.md +313 -0
- package/.speccrew/skills/speccrew-create-agents/SKILL.md +98 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/designer-agent.md +54 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/dev-agent.md +79 -0
- package/.speccrew/skills/speccrew-create-agents/templates/agents/test-agent.md +80 -0
- package/.speccrew/skills/speccrew-dev-backend/SKILL.md +205 -0
- package/.speccrew/skills/speccrew-dev-backend/templates/TASK-RECORD-TEMPLATE.md +118 -0
- package/.speccrew/skills/speccrew-dev-desktop/SKILL.md +258 -0
- package/.speccrew/skills/speccrew-dev-desktop/templates/TASK-RECORD-TEMPLATE.md +161 -0
- package/.speccrew/skills/speccrew-dev-frontend/SKILL.md +202 -0
- package/.speccrew/skills/speccrew-dev-frontend/templates/TASK-RECORD-TEMPLATE.md +115 -0
- package/.speccrew/skills/speccrew-dev-mobile/SKILL.md +200 -0
- package/.speccrew/skills/speccrew-dev-mobile/templates/TASK-RECORD-TEMPLATE.md +125 -0
- package/.speccrew/skills/speccrew-fd-api-contract/SKILL.md +73 -0
- package/.speccrew/skills/speccrew-fd-api-contract/templates/API-CONTRACT-TEMPLATE.md +96 -0
- package/.speccrew/skills/speccrew-fd-feature-design/SKILL.md +395 -0
- package/.speccrew/skills/speccrew-fd-feature-design/templates/FEATURE-SPEC-TEMPLATE.md +387 -0
- package/.speccrew/skills/speccrew-get-timestamp/SKILL.md +80 -0
- package/.speccrew/skills/speccrew-get-timestamp/scripts/get-timestamp.js +35 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/SKILL.md +1116 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-FASTAPI.md +462 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-JAVA.md +480 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE-NET.md +464 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/FEATURE-DETAIL-TEMPLATE.md +480 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-api-analyze/templates/MODULE-OVERVIEW-TEMPLATE.md +367 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/SKILL.md +667 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/STATUS-FORMATS.md +74 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/batch-orchestrator.js +176 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-next-batch.js +150 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/get-pending-features.js +106 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/mark-stale.js +249 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/process-batch-results.js +848 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-dispatch/scripts/update-feature-status.js +226 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/SKILL.md +264 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/examples/features.json +34 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/generate-inventory.js +867 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-init-features/scripts/test-inventory.js +26 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/SKILL.md +165 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/apply-module-mapping.js +208 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/extract-module-summary.js +180 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-module-classify/scripts/reindex-modules.js +358 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/SKILL.md +1055 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-DESKTOP.md +303 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-ELECTRON.md +327 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MINIAPP.md +292 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI-MOBILE.md +281 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-analyze/templates/FEATURE-DETAIL-TEMPLATE-UI.md +324 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/SKILL.md +270 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/COMPONENT-PATTERN-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/LAYOUT-PATTERN-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-bizs-ui-style-extract/templates/PAGE-TYPE-TEMPLATE.md +33 -0
- package/.speccrew/skills/speccrew-knowledge-graph-query/SKILL.md +229 -0
- package/.speccrew/skills/speccrew-knowledge-graph-query/scripts/graph-query.js +549 -0
- package/.speccrew/skills/speccrew-knowledge-graph-write/SKILL.md +181 -0
- package/.speccrew/skills/speccrew-knowledge-graph-write/scripts/graph-write.js +651 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize/SKILL.md +305 -0
- package/.speccrew/skills/speccrew-knowledge-module-summarize/templates/MODULE-OVERVIEW-TEMPLATE.md +400 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize/SKILL.md +351 -0
- package/.speccrew/skills/speccrew-knowledge-system-summarize/templates/SYSTEM-OVERVIEW-TEMPLATE.md +294 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/SKILL.md +683 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/STATUS-FORMATS.md +550 -0
- package/.speccrew/skills/speccrew-knowledge-techs-dispatch/templates/techs-manifest-EXAMPLE.json +35 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/SKILL.md +1087 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/ARCHITECTURE-TEMPLATE.md +240 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COLOR-SYSTEM-TEMPLATE.md +68 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/COMPONENT-LIBRARY-TEMPLATE.md +86 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-BUILD-TEMPLATE.md +466 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DATA-TEMPLATE.md +432 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DESIGN-TEMPLATE.md +1209 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-DEV-TEMPLATE.md +1433 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-SYSTEM-TEST-TEMPLATE.md +1052 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/CONVENTIONS-UNIT-TEST-TEMPLATE.md +946 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/INDEX-TEMPLATE.md +29 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-LAYOUTS-TEMPLATE.md +69 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +74 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate/templates/TECH-STACK-TEMPLATE.md +232 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate-conventions/SKILL.md +628 -0
- package/.speccrew/skills/speccrew-knowledge-techs-generate-ui-style/SKILL.md +392 -0
- package/.speccrew/skills/speccrew-knowledge-techs-index/SKILL.md +489 -0
- package/.speccrew/skills/speccrew-knowledge-techs-index/templates/INDEX-TEMPLATE.md +243 -0
- package/.speccrew/skills/speccrew-knowledge-techs-init/SKILL.md +269 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/SKILL.md +562 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/BUSINESS-COMPONENTS-TEMPLATE.md +171 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMMON-COMPONENTS-TEMPLATE.md +177 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-INDIVIDUAL-TEMPLATE.md +80 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/COMPONENT-LIBRARY-TEMPLATE.md +118 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-INDIVIDUAL-TEMPLATE.md +97 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/LAYOUT-PATTERNS-TEMPLATE.md +208 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/NAVIGATION-PATTERNS-TEMPLATE.md +157 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-INDIVIDUAL-TEMPLATE.md +123 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/PAGE-TYPE-SUMMARY-TEMPLATE.md +58 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/SPACING-TEMPLATE.md +119 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/STYLE-SYSTEM-TEMPLATE.md +117 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/TYPOGRAPHY-TEMPLATE.md +107 -0
- package/.speccrew/skills/speccrew-knowledge-techs-ui-analyze/templates/UI-STYLE-GUIDE-TEMPLATE.md +171 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/SKILL.md +434 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/BIZS-MODELING-TEMPLATE.md +332 -0
- package/.speccrew/skills/speccrew-pm-requirement-analysis/templates/PRD-TEMPLATE.md +200 -0
- package/.speccrew/skills/speccrew-pm-requirement-assess/SKILL.md +195 -0
- package/.speccrew/skills/speccrew-project-diagnosis/SKILL.md +208 -0
- package/.speccrew/skills/speccrew-project-diagnosis/templates/DIAGNOSIS-REPORT-TEMPLATE.md +202 -0
- package/.speccrew/skills/speccrew-sd-backend/SKILL.md +188 -0
- package/.speccrew/skills/speccrew-sd-backend/templates/INDEX-TEMPLATE.md +85 -0
- package/.speccrew/skills/speccrew-sd-backend/templates/SD-BACKEND-TEMPLATE.md +269 -0
- package/.speccrew/skills/speccrew-sd-desktop/SKILL.md +192 -0
- package/.speccrew/skills/speccrew-sd-desktop/templates/INDEX-TEMPLATE.md +271 -0
- package/.speccrew/skills/speccrew-sd-desktop/templates/SD-DESKTOP-TEMPLATE.md +673 -0
- package/.speccrew/skills/speccrew-sd-frontend/SKILL.md +176 -0
- package/.speccrew/skills/speccrew-sd-frontend/templates/INDEX-TEMPLATE.md +184 -0
- package/.speccrew/skills/speccrew-sd-frontend/templates/SD-FRONTEND-TEMPLATE.md +382 -0
- package/.speccrew/skills/speccrew-sd-mobile/SKILL.md +189 -0
- package/.speccrew/skills/speccrew-sd-mobile/templates/INDEX-TEMPLATE.md +219 -0
- package/.speccrew/skills/speccrew-sd-mobile/templates/SD-MOBILE-TEMPLATE.md +534 -0
- package/.speccrew/skills/speccrew-test-case-design/SKILL.md +284 -0
- package/.speccrew/skills/speccrew-test-case-design/templates/TEST-CASE-DESIGN-TEMPLATE.md +263 -0
- package/.speccrew/skills/speccrew-test-code-gen/SKILL.md +313 -0
- package/.speccrew/skills/speccrew-test-code-gen/templates/TEST-CODE-PLAN-TEMPLATE.md +180 -0
- package/.speccrew/skills/speccrew-test-execute/SKILL.md +283 -0
- package/.speccrew/skills/speccrew-test-execute/templates/BUG-REPORT-TEMPLATE.md +50 -0
- package/.speccrew/skills/speccrew-test-execute/templates/TEST-REPORT-TEMPLATE.md +57 -0
- package/.speccrew/skills/speccrew-workflow-diagnose/SKILL.md +155 -0
- package/LICENSE +21 -0
- package/README.ar.md +318 -0
- package/README.en.md +318 -0
- package/README.es.md +318 -0
- package/README.md +340 -0
- package/bin/cli.js +62 -0
- package/lib/commands/doctor.js +138 -0
- package/lib/commands/init.js +231 -0
- package/lib/commands/list.js +114 -0
- package/lib/commands/uninstall.js +117 -0
- package/lib/commands/update.js +351 -0
- package/lib/ide-adapters.js +73 -0
- package/lib/utils.js +104 -0
- package/package.json +28 -0
- package/workspace-template/docs/configs/document-templates.json +667 -0
- package/workspace-template/docs/configs/platform-mapping.json +194 -0
- package/workspace-template/docs/configs/tech-stack-mappings.json +313 -0
- package/workspace-template/docs/configs/validation-rules.json +87 -0
- package/workspace-template/docs/rules/mermaid-rule.md +114 -0
- package/workspace-template/docs/solutions/Agent/346/212/200/350/203/275/345/256/232/344/271/211+/351/234/200/346/261/202/346/226/207/346/241/243+UML/344/275/277/347/224/250/346/250/241/346/235/277/357/274/210ISA-95/345/205/255/346/256/265/345/274/217/350/236/215/345/220/210/347/211/210/357/274/211.md +586 -0
- package/workspace-template/docs/solutions/agent-knowledge-map.md +238 -0
- package/workspace-template/docs/solutions/bizs-knowledge-pipeline.md +678 -0
- package/workspace-template/docs/solutions/harness.md +410 -0
- package/workspace-template/docs/solutions/knowledge-incremental-sync-spec.md +943 -0
- package/workspace-template/docs/solutions/techs-knowledge-pipeline.md +803 -0
- package/workspace-template/docs/solutions/workspace-structure.md +318 -0
|
@@ -0,0 +1,462 @@
|
|
|
1
|
+
# API Feature Detail Template - [Feature Name]
|
|
2
|
+
|
|
3
|
+
> **Tech Stack**: FastAPI + SQLAlchemy + Pydantic
|
|
4
|
+
> **Target Audience**: devcrew-product-manager, devcrew-solution-manager, devcrew-developer
|
|
5
|
+
> **Related Document**: [Module Overview Document](../{{module-name}}-overview.md)
|
|
6
|
+
>
|
|
7
|
+
> <!-- AI-TAG: FEATURE_DETAIL -->
|
|
8
|
+
> <!-- AI-CONTEXT: This document describes FastAPI endpoints, business logic flow, and data models. AI should fill all placeholders when generating. -->
|
|
9
|
+
|
|
10
|
+
<cite>
|
|
11
|
+
**Files Referenced in This Document**
|
|
12
|
+
- [{router}.py](../../{routerSourcePath})
|
|
13
|
+
- [{service}.py](../../{serviceSourcePath})
|
|
14
|
+
- [{model}.py](../../{modelSourcePath})
|
|
15
|
+
- [{schema}.py](../../{schemaSourcePath})
|
|
16
|
+
</cite>
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 1. Content Overview
|
|
21
|
+
|
|
22
|
+
<!-- AI-TAG: OVERVIEW -->
|
|
23
|
+
|
|
24
|
+
### 1.1 Basic Information
|
|
25
|
+
|
|
26
|
+
| Item | Description |
|
|
27
|
+
|------|-------------|
|
|
28
|
+
| Router Name | {Fill in router name} |
|
|
29
|
+
| Module | {e.g., Order Management Module} |
|
|
30
|
+
| Core Function | {1-3 sentences describing core API functionality} |
|
|
31
|
+
| Base Path | {e.g., /api/v1/users} |
|
|
32
|
+
| Tags | {e.g., ["users"]} |
|
|
33
|
+
|
|
34
|
+
### 1.2 API Scope
|
|
35
|
+
|
|
36
|
+
This router includes the following API endpoints:
|
|
37
|
+
- [ ] {GET /} - {List users with pagination}
|
|
38
|
+
- [ ] {POST /} - {Create new user}
|
|
39
|
+
- [ ] {GET /{id}} - {Get user by ID}
|
|
40
|
+
- [ ] {PUT /{id}} - {Update user}
|
|
41
|
+
- [ ] {DELETE /{id}} - {Delete user}
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 2. API Endpoint Definitions
|
|
46
|
+
|
|
47
|
+
<!-- AI-TAG: API_ENDPOINTS -->
|
|
48
|
+
<!-- AI-NOTE: Document all public API endpoints exposed by this router -->
|
|
49
|
+
|
|
50
|
+
### 2.1 {Endpoint Name} - {HTTP Method} {API Path}
|
|
51
|
+
|
|
52
|
+
**Endpoint Information:**
|
|
53
|
+
|
|
54
|
+
| Item | Description |
|
|
55
|
+
|------|-------------|
|
|
56
|
+
| Method | {GET/POST/PUT/DELETE} |
|
|
57
|
+
| Path | {/api/v1/users} |
|
|
58
|
+
| Description | {Brief description of what this endpoint does} |
|
|
59
|
+
| Dependencies | {e.g., get_current_user, get_db} |
|
|
60
|
+
|
|
61
|
+
**Request Parameters:**
|
|
62
|
+
|
|
63
|
+
| Parameter | Type | Required | Description | Validation Rules |
|
|
64
|
+
|-----------|------|----------|-------------|------------------|
|
|
65
|
+
| {param1} | {str/int} | {Yes/No} | {Description} | {e.g., min_length=1, max_length=50} |
|
|
66
|
+
| {param2} | {int} | {No} | {Description} | {e.g., ge=1, le=100} |
|
|
67
|
+
| {skip} | {int} | {No} | {Records to skip} | {Default 0} |
|
|
68
|
+
| {limit} | {int} | {No} | {Max records to return} | {Default 100, max 1000} |
|
|
69
|
+
|
|
70
|
+
**Response Data:**
|
|
71
|
+
|
|
72
|
+
| Field | Type | Description | Nullable |
|
|
73
|
+
|-------|------|-------------|----------|
|
|
74
|
+
| {id} | {int} | {Record ID} | {No} |
|
|
75
|
+
| {field1} | {str} | {Description} | {Yes} |
|
|
76
|
+
| {field2} | {int} | {Description} | {No} |
|
|
77
|
+
| {created_at} | {datetime} | {Creation time} | {No} |
|
|
78
|
+
|
|
79
|
+
**Response Example:**
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
{
|
|
83
|
+
"id": 1,
|
|
84
|
+
"field1": "value1",
|
|
85
|
+
"field2": 100,
|
|
86
|
+
"created_at": "2024-01-01T12:00:00"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Error Codes:**
|
|
91
|
+
|
|
92
|
+
| Error Code | Description | Trigger Condition |
|
|
93
|
+
|------------|-------------|-------------------|
|
|
94
|
+
| {400} | {Validation Error} | {Invalid request parameters} |
|
|
95
|
+
| {401} | {Unauthorized} | {Missing or invalid token} |
|
|
96
|
+
| {403} | {Forbidden} | {Insufficient permissions} |
|
|
97
|
+
| {404} | {Not Found} | {Resource not found} |
|
|
98
|
+
|
|
99
|
+
**Business Flow:**
|
|
100
|
+
|
|
101
|
+
```mermaid
|
|
102
|
+
graph TB
|
|
103
|
+
Start([Request Received]) --> Auth{Dependency Injection}
|
|
104
|
+
|
|
105
|
+
Auth -->|Unauthorized| AuthError[Return 401 Unauthorized]
|
|
106
|
+
AuthError --> End1([End])
|
|
107
|
+
|
|
108
|
+
Auth -->|Authorized| Validate{Pydantic Validation}
|
|
109
|
+
|
|
110
|
+
Validate -->|Invalid| ValError[Return 422 Validation Error]
|
|
111
|
+
ValError --> End1
|
|
112
|
+
|
|
113
|
+
Validate -->|Valid| Route[Router Endpoint Function]
|
|
114
|
+
|
|
115
|
+
Route -->|Call| Svc[Service Layer Function]
|
|
116
|
+
|
|
117
|
+
Svc -->|Validate| BizRule{Business Rules}
|
|
118
|
+
BizRule -->|Violation| BizError[Return 400 Business Error]
|
|
119
|
+
BizError --> End1
|
|
120
|
+
|
|
121
|
+
BizRule -->|Pass| SvcLogic[Business Logic Processing]
|
|
122
|
+
SvcLogic -->|Transform Data| SvcData[Prepare Data]
|
|
123
|
+
|
|
124
|
+
SvcData -->|Call| CRUD[CRUD/Repository Method]
|
|
125
|
+
|
|
126
|
+
CRUD -->|Execute SQL| DB[(Database via SQLAlchemy)]
|
|
127
|
+
DB -->|Return Result| CRUD
|
|
128
|
+
|
|
129
|
+
CRUD -->|Return| SvcResult[Service Process Result]
|
|
130
|
+
SvcResult -->|Return| RouteResult[Router Assemble Response]
|
|
131
|
+
|
|
132
|
+
RouteResult --> Response[Pydantic Response Model]
|
|
133
|
+
Response --> Success[Return 200 Success]
|
|
134
|
+
Success --> End2([End])
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Flow Step Description:**
|
|
138
|
+
|
|
139
|
+
| Step | Operation | Layer | Component | Input | Output | Exception Handling |
|
|
140
|
+
|------|-----------|-------|-----------|-------|--------|-------------------|
|
|
141
|
+
| 1 | Dependency Injection | Router | {Depends} | Request + Token | Current user + DB session | Return 401 |
|
|
142
|
+
| 2 | Pydantic Validation | Router | {Pydantic Schema} | Request body/query | Validated model | Return 422 |
|
|
143
|
+
| 3 | Invoke Service | Router | {Router function} | Validated model | Service result | - |
|
|
144
|
+
| 4 | Business Rule Check | Service | {Service} | Business data | Validation result | Return 400 |
|
|
145
|
+
| 5 | Data Processing | Service | {Service} | Raw data | Processed data | - |
|
|
146
|
+
| 6 | Invoke CRUD | Service | {CRUD/Repository} | Processed data | DB result | - |
|
|
147
|
+
| 7 | SQL Execution | CRUD | {SQLAlchemy Model} | SQL parameters | DB result | Return 500 |
|
|
148
|
+
| 8 | Assemble Response | Router | {Router} | Service result | Pydantic response | Return 200 |
|
|
149
|
+
|
|
150
|
+
**Detailed Call Chain:**
|
|
151
|
+
|
|
152
|
+
| # | Layer | File | Function/Class | Responsibility | Source |
|
|
153
|
+
|---|-------|------|----------------|----------------|--------|
|
|
154
|
+
| 1 | Router | {users.py} | {create_user} | Receive request, validate params, call service | [Source](../../{routerSourcePath}) |
|
|
155
|
+
| 2 | Service | {user_service.py} | {create_user} | Business validation, data processing, call CRUD | [Source](../../{serviceSourcePath}) |
|
|
156
|
+
| 3 | Service | {user_service.py} | {validate_user_email} | Check email uniqueness | [Source](../../{serviceSourcePath}) |
|
|
157
|
+
| 4 | CRUD | {user_crud.py} | {create} | Execute INSERT via SQLAlchemy | [Source](../../{crudSourcePath}) |
|
|
158
|
+
| 5 | Model | {user.py} | {User model} | SQLAlchemy ORM model definition | [Source](../../{modelSourcePath}) |
|
|
159
|
+
|
|
160
|
+
**Database Operations:**
|
|
161
|
+
|
|
162
|
+
| Operation | Table | SQL Type | Description |
|
|
163
|
+
|-----------|-------|----------|-------------|
|
|
164
|
+
| {INSERT} | {users} | {INSERT} | {Insert new user record} |
|
|
165
|
+
| {SELECT} | {users} | {SELECT} | {Check email exists} |
|
|
166
|
+
| {UPDATE} | {users} | {UPDATE} | {Update user status} |
|
|
167
|
+
|
|
168
|
+
**Transaction Boundaries:**
|
|
169
|
+
|
|
170
|
+
| Method | Transaction Scope | Notes |
|
|
171
|
+
|--------|-------------------|-------|
|
|
172
|
+
| {user_service.create_user} | {Single DB session} | {Auto-commit by default} |
|
|
173
|
+
|
|
174
|
+
### 2.2 {Next Endpoint Name} - {HTTP Method} {API Path}
|
|
175
|
+
|
|
176
|
+
{Repeat the same structure for each API endpoint in the router}
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
## 3. Data Field Definition
|
|
181
|
+
|
|
182
|
+
<!-- AI-TAG: DATA_DEFINITION -->
|
|
183
|
+
<!-- AI-NOTE: Data definitions are important for Solution Agent to design APIs and databases -->
|
|
184
|
+
|
|
185
|
+
### 3.1 Database Table Structure
|
|
186
|
+
|
|
187
|
+
<!-- AI-NOTE: Analyze SQLAlchemy Model to extract database table structure -->
|
|
188
|
+
|
|
189
|
+
**Table Name:** {table_name}
|
|
190
|
+
|
|
191
|
+
**Table Description:** {Description of what this table stores}
|
|
192
|
+
|
|
193
|
+
| Field Name | Python Type | DB Type | Length | Nullable | Default | Constraint | Index | Description |
|
|
194
|
+
|------------|-------------|---------|--------|----------|---------|------------|-------|-------------|
|
|
195
|
+
| {id} | {int} | {INTEGER} | - | {No} | {Auto increment} | {PRIMARY KEY} | {PRIMARY} | {Primary key} |
|
|
196
|
+
| {field1} | {str} | {VARCHAR} | {255} | {No} | - | {UNIQUE} | {UNIQUE} | {Unique field} |
|
|
197
|
+
| {field2} | {int} | {INTEGER} | - | {Yes} | {0} | - | - | {Optional field} |
|
|
198
|
+
| {field3} | {datetime} | {TIMESTAMP} | - | {No} | {func.now()} | - | - | {Creation time} |
|
|
199
|
+
| {field4} | {bool/Enum} | {BOOLEAN/ENUM} | - | {No} | {True} | - | {INDEX} | {Status field} |
|
|
200
|
+
|
|
201
|
+
**Indexes:**
|
|
202
|
+
|
|
203
|
+
| Index Name | Index Type | Fields | Purpose |
|
|
204
|
+
|------------|------------|--------|---------|
|
|
205
|
+
| {ix_name} | {Index} | {field1} | {Query optimization} |
|
|
206
|
+
| {ix_status} | {Index} | {field4, created_at} | {Composite index for status query} |
|
|
207
|
+
|
|
208
|
+
**Relationships:**
|
|
209
|
+
|
|
210
|
+
| Related Table | Relationship | Foreign Key | Description |
|
|
211
|
+
|---------------|--------------|-------------|-------------|
|
|
212
|
+
| {related_table} | {One-to-Many} | {ForeignKey("related.id")} | {Relationship description} |
|
|
213
|
+
| {another_table} | {Many-to-One} | {ForeignKey("another.id")} | {Relationship description} |
|
|
214
|
+
|
|
215
|
+
**Source:** [Model](../../{modelSourcePath})
|
|
216
|
+
|
|
217
|
+
### 3.2 Model-Database Mapping
|
|
218
|
+
|
|
219
|
+
| Model Field | DB Column | Type Mapping | Notes |
|
|
220
|
+
|-------------|-----------|--------------|-------|
|
|
221
|
+
| {model.field1} | {column_name} | {str → VARCHAR(255)} | {Mapping notes} |
|
|
222
|
+
| {model.field2} | {column_name} | {int → INTEGER} | {Mapping notes} |
|
|
223
|
+
| {model.created_at} | {created_at} | {datetime → TIMESTAMP} | {Auto-filled by server_default} |
|
|
224
|
+
|
|
225
|
+
### 3.3 Pydantic Schema Definitions
|
|
226
|
+
|
|
227
|
+
**Request Schema:**
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
class {UserCreate}(BaseModel):
|
|
231
|
+
field1: str = Field(..., min_length=1, max_length=50)
|
|
232
|
+
field2: int = Field(..., ge=1)
|
|
233
|
+
|
|
234
|
+
class Config:
|
|
235
|
+
from_attributes = True
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
**Response Schema:**
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
class {UserResponse}(BaseModel):
|
|
242
|
+
id: int
|
|
243
|
+
field1: str
|
|
244
|
+
field2: int
|
|
245
|
+
created_at: datetime
|
|
246
|
+
|
|
247
|
+
class Config:
|
|
248
|
+
from_attributes = True
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
## 4. References
|
|
254
|
+
|
|
255
|
+
<!-- AI-TAG: REFERENCES -->
|
|
256
|
+
<!-- AI-NOTE: List all dependencies and references for this router -->
|
|
257
|
+
|
|
258
|
+
### 4.1 Internal Services
|
|
259
|
+
|
|
260
|
+
| Service Name | Purpose | Source Path |
|
|
261
|
+
|--------------|---------|-------------|
|
|
262
|
+
| {user_service} | {e.g., User business logic} | [Source](../../{serviceSourcePath}) |
|
|
263
|
+
| {auth_service} | {e.g., Authentication validation} | [Source](../../{serviceSourcePath}) |
|
|
264
|
+
|
|
265
|
+
### 4.2 Data Access Layer
|
|
266
|
+
|
|
267
|
+
| CRUD/Repository | Model | Purpose | Source Path |
|
|
268
|
+
|-----------------|-------|---------|-------------|
|
|
269
|
+
| {user_crud} | {User} | {e.g., User CRUD operations} | [Source](../../{crudSourcePath}) |
|
|
270
|
+
| {role_crud} | {Role} | {e.g., Role query} | [Source](../../{crudSourcePath}) |
|
|
271
|
+
|
|
272
|
+
### 4.3 Schemas and Models
|
|
273
|
+
|
|
274
|
+
| Class Name | Type | Purpose | Source Path |
|
|
275
|
+
|------------|------|---------|-------------|
|
|
276
|
+
| {UserCreate} | Request Schema | {e.g., Create user request} | [Source](../../{schemaSourcePath}) |
|
|
277
|
+
| {UserResponse} | Response Schema | {e.g., User detail response} | [Source](../../{schemaSourcePath}) |
|
|
278
|
+
| {User} | SQLAlchemy Model | {e.g., User database model} | [Source](../../{modelSourcePath}) |
|
|
279
|
+
|
|
280
|
+
### 4.4 API Consumers
|
|
281
|
+
|
|
282
|
+
<!-- AI-NOTE: List frontend pages that call this router's APIs -->
|
|
283
|
+
|
|
284
|
+
| Page Name | Function Description | Source Path | Document Path |
|
|
285
|
+
|-----------|---------------------|-------------|---------------|
|
|
286
|
+
| {PageName} | {e.g., User management list page} | [Source](../../{pageSourcePath}) | [Doc](../../{pageDocumentPath}) |
|
|
287
|
+
| {PageName} | {e.g., User form page} | [Source](../../{pageSourcePath}) | [Doc](../../{pageDocumentPath}) |
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## 5. Business Rule Constraints
|
|
292
|
+
|
|
293
|
+
<!-- AI-TAG: BUSINESS_RULES -->
|
|
294
|
+
|
|
295
|
+
### 5.1 Permission Rules
|
|
296
|
+
|
|
297
|
+
| API Endpoint | Permission Requirement | No Permission Response |
|
|
298
|
+
|--------------|----------------------|----------------------|
|
|
299
|
+
| {GET /} | {Require authentication} | Return 401 Unauthorized |
|
|
300
|
+
| {POST /} | {Require admin role} | Return 403 Forbidden |
|
|
301
|
+
| {DELETE /{id}} | {Require admin role} | Return 403 Forbidden |
|
|
302
|
+
|
|
303
|
+
### 5.2 Business Logic Rules
|
|
304
|
+
|
|
305
|
+
1. **{Rule 1}**: {e.g., User email must be unique across system}
|
|
306
|
+
2. **{Rule 2}**: {e.g., Cannot delete user with active orders}
|
|
307
|
+
3. **{Rule 3}**: {e.g., Password must be hashed before storage}
|
|
308
|
+
4. **{Rule 4}**: {e.g., Admin user cannot be deleted}
|
|
309
|
+
|
|
310
|
+
### 5.3 Validation Rules
|
|
311
|
+
|
|
312
|
+
| Validation Scenario | Validation Rule | Error Response | Error Code |
|
|
313
|
+
|--------------------|-----------------|----------------|------------|
|
|
314
|
+
| Pydantic validation | {Field} must match schema | Return 422 Unprocessable Entity | - |
|
|
315
|
+
| Business validation | {Business rule violation} | Return 400 Bad Request | - |
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## 6. Dependency Analysis
|
|
320
|
+
|
|
321
|
+
<!-- AI-TAG: DEPENDENCIES -->
|
|
322
|
+
|
|
323
|
+
### 6.1 Module Dependencies
|
|
324
|
+
|
|
325
|
+
| Dependency Module | Dependency Type | Purpose | Impact Scope |
|
|
326
|
+
|-------------------|-----------------|---------|--------------|
|
|
327
|
+
| {Module A} | Strong | {Purpose description} | {Impact when unavailable} |
|
|
328
|
+
| {Module B} | Weak | {Purpose description} | {Degraded functionality} |
|
|
329
|
+
|
|
330
|
+
### 6.2 Service Dependencies
|
|
331
|
+
|
|
332
|
+
```mermaid
|
|
333
|
+
graph LR
|
|
334
|
+
A[This Router] --> B[Dependency Service 1]
|
|
335
|
+
A --> C[Dependency Service 2]
|
|
336
|
+
B --> D[Database]
|
|
337
|
+
C --> D
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
**Diagram Source**
|
|
341
|
+
- [{Service}.py](../../{serviceSourcePath})
|
|
342
|
+
|
|
343
|
+
### 6.3 External Dependencies
|
|
344
|
+
|
|
345
|
+
| External System | Interface Type | Call Scenario | Degradation Strategy |
|
|
346
|
+
|-----------------|----------------|---------------|---------------------|
|
|
347
|
+
| {Payment Gateway} | REST API | {Payment processing} | {Queue and retry} |
|
|
348
|
+
| {SMS Service} | REST API | {Verification code} | {Skip and log} |
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
## 7. Performance Considerations
|
|
353
|
+
|
|
354
|
+
<!-- AI-TAG: PERFORMANCE -->
|
|
355
|
+
|
|
356
|
+
### 7.1 Performance Bottlenecks
|
|
357
|
+
|
|
358
|
+
| Scenario | Bottleneck Description | Optimization Suggestion | Priority |
|
|
359
|
+
|----------|----------------------|------------------------|----------|
|
|
360
|
+
| {List query} | {Large data volume} | {Add index, pagination} | High |
|
|
361
|
+
| {Batch operation} | {Database lock} | {Use async processing} | Medium |
|
|
362
|
+
|
|
363
|
+
### 7.2 Index Suggestions
|
|
364
|
+
|
|
365
|
+
| Table Name | Index Fields | Index Type | Scenario Description |
|
|
366
|
+
|------------|--------------|------------|---------------------|
|
|
367
|
+
| {table_name} | {field1, field2} | {COMPOSITE INDEX} | {Query optimization} |
|
|
368
|
+
| {table_name} | {field3} | {INDEX} | {Filter condition} |
|
|
369
|
+
|
|
370
|
+
### 7.3 Caching Strategy
|
|
371
|
+
|
|
372
|
+
| Cache Scenario | Cache Strategy | Expiration Time | Invalidation Strategy |
|
|
373
|
+
|----------------|----------------|-----------------|----------------------|
|
|
374
|
+
| {User info} | {Redis} | {30 minutes} | {Write-through} |
|
|
375
|
+
| {Configuration} | {Local cache} | {5 minutes} | {TTL expiration} |
|
|
376
|
+
|
|
377
|
+
---
|
|
378
|
+
|
|
379
|
+
## 8. Troubleshooting Guide
|
|
380
|
+
|
|
381
|
+
<!-- AI-TAG: TROUBLESHOOTING -->
|
|
382
|
+
|
|
383
|
+
### 8.1 Common Issues
|
|
384
|
+
|
|
385
|
+
| Issue Symptom | Possible Cause | Troubleshooting Steps | Solution |
|
|
386
|
+
|---------------|----------------|----------------------|----------|
|
|
387
|
+
| {Query timeout} | {Missing index} | {Check SQL execution plan} | {Add index} |
|
|
388
|
+
| {Data inconsistency} | {Transaction failure} | {Check transaction logs} | {Manual correction} |
|
|
389
|
+
| {Permission denied} | {Role not assigned} | {Check user roles} | {Assign correct role} |
|
|
390
|
+
|
|
391
|
+
### 8.2 Error Code Reference
|
|
392
|
+
|
|
393
|
+
| Error Code | Error Description | Trigger Condition | Handling Suggestion |
|
|
394
|
+
|------------|-------------------|-------------------|---------------------|
|
|
395
|
+
| {400} | {Bad Request} | {Validation failed} | {Check request parameters} |
|
|
396
|
+
| {422} | {Validation Error} | {Pydantic validation failed} | {Check field requirements} |
|
|
397
|
+
| {500} | {Internal Server Error} | {Unhandled exception} | {Check server logs} |
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## 9. Notes and Additional Information
|
|
402
|
+
|
|
403
|
+
<!-- AI-TAG: ADDITIONAL_NOTES -->
|
|
404
|
+
|
|
405
|
+
### 9.1 Compatibility Adaptation
|
|
406
|
+
|
|
407
|
+
- **FastAPI Version**: Compatible with FastAPI 0.100+ and Pydantic v2
|
|
408
|
+
- **Python Version**: Requires Python 3.8+
|
|
409
|
+
- **ASGI Server**: Uvicorn or Hypercorn recommended
|
|
410
|
+
|
|
411
|
+
### 9.2 Pending Confirmations
|
|
412
|
+
|
|
413
|
+
- [ ] **{Pending 1}**: {e.g., Whether to add rate limiting for public endpoints}
|
|
414
|
+
- [ ] **{Pending 2}**: {e.g., Whether to implement soft delete vs hard delete}
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## 10. Appendix
|
|
419
|
+
|
|
420
|
+
### 10.1 Best Practices
|
|
421
|
+
|
|
422
|
+
- {Best practice 1: e.g., Use async database drivers for better performance}
|
|
423
|
+
- {Best practice 2: e.g., Implement proper dependency injection}
|
|
424
|
+
- {Best practice 3: e.g., Add comprehensive API documentation with examples}
|
|
425
|
+
|
|
426
|
+
### 10.2 Configuration Examples
|
|
427
|
+
|
|
428
|
+
```python
|
|
429
|
+
# FastAPI app configuration
|
|
430
|
+
app = FastAPI(
|
|
431
|
+
title="API Title",
|
|
432
|
+
description="API Description",
|
|
433
|
+
version="1.0.0",
|
|
434
|
+
docs_url="/docs",
|
|
435
|
+
redoc_url="/redoc"
|
|
436
|
+
)
|
|
437
|
+
|
|
438
|
+
# Router configuration
|
|
439
|
+
router = APIRouter(
|
|
440
|
+
prefix="/api/v1/users",
|
|
441
|
+
tags=["users"],
|
|
442
|
+
dependencies=[Depends(get_current_user)]
|
|
443
|
+
)
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### 10.3 Related Documents
|
|
447
|
+
|
|
448
|
+
- [API Documentation](link)
|
|
449
|
+
- [Database Design](link)
|
|
450
|
+
- [Module Overview](../{module-name}-overview.md)
|
|
451
|
+
|
|
452
|
+
---
|
|
453
|
+
|
|
454
|
+
**Document Status:** 📝 Draft / 👀 In Review / ✅ Published
|
|
455
|
+
**Last Updated:** {Date}
|
|
456
|
+
**Maintainer:** {Name}
|
|
457
|
+
**Related Module Document:** [Module Overview Document](../{{module-name}}-overview.md)
|
|
458
|
+
|
|
459
|
+
**Section Source**
|
|
460
|
+
- [{Router}.py](../../{routerSourcePath})
|
|
461
|
+
- [{Service}.py](../../{serviceSourcePath})
|
|
462
|
+
- [{Model}.py](../../{modelSourcePath})
|