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,39 @@
1
+ ---
2
+ name: ai-spector
3
+ description: "Cursor-first docs: user runs slash commands; agent runs CLI; on CLI failure stop and help fix — no manual bypass."
4
+ ---
5
+
6
+ # AI Spector Skill
7
+
8
+ **Workflow:** `.cursor/commands/_workflow.md` — user only runs `npx ai-spector init` once, then slash commands.
9
+
10
+ ## CLI failure rule (non-negotiable)
11
+
12
+ When `ai-spector` exits non-zero or required `--json` is missing/invalid:
13
+
14
+ 1. **Stop** — no generate, no bulk `docs/srs/**` reads, no hand-editing the whole graph.
15
+ 2. **Report** using the format in `.cursor/commands/_cli-failures.md` (verbatim CLI output + plain fix steps).
16
+ 3. **Fix** the root cause, then **re-run the same CLI** and continue the slash command.
17
+
18
+ Never ignore CLI errors and “work around” with index files, manual BFS, or inventing graph content. See `_cli-failures.md` for forbidden fallbacks.
19
+
20
+ ## Slash commands (user)
21
+
22
+ | Command | Agent runs CLI |
23
+ |---------|----------------|
24
+ | `/analyze` | `analyze` → Graphify → `graph merge --from-knowledge` → `graph validate` |
25
+ | `/validate-graph` | `graph validate` |
26
+ | `/visualize-graph` | `graph visualize --open` |
27
+ | `/generate-srs` | `graph validate` + `graph query <seed> --json` per target |
28
+ | `/graph-impact` | `graph impact <id> --json` |
29
+ | `/generate-basic-design`, `/generate-detail-design` | `graph query` per target |
30
+
31
+ Run CLI from **project workspace root**; prefer `npx ai-spector` if the binary is not on PATH.
32
+
33
+ ## Heart of the system
34
+
35
+ `.ai-spector/graph/traceability.graph.json`
36
+
37
+ Context: **`ai-spector graph query <seedId> --json`** — only after validate passes; use `projectionPaths` from stdout. Details: `_graph.md`.
38
+
39
+ Templates: `node_modules/ai-spector/templates/` (monorepo `example/`: `../templates/`).
@@ -0,0 +1,7 @@
1
+ # Data source
2
+
3
+ Default input folder for AI Spector. Place materials here before running `/analyze`, `/generate-srs`, or `/generate-basic-design`.
4
+
5
+ Examples: product briefs, meeting notes, API exports, ERDs, wireframes, legacy SRS fragments, spreadsheets, or code-adjacent reference docs.
6
+
7
+ Override the default by passing explicit paths to `/analyze`.
@@ -0,0 +1,17 @@
1
+ {
2
+ "version": 1,
3
+ "description": "Impact propagation rules (P1+). P0 stub for future /graph-impact.",
4
+ "edgePropagation": {
5
+ "partOf": { "direction": "out", "depth": "unbounded" },
6
+ "contains": { "direction": "in", "depth": "unbounded" },
7
+ "satisfies": { "direction": "in", "depth": 1 },
8
+ "dependsOn": { "direction": "out", "depth": "unbounded" },
9
+ "definedIn": { "direction": "in", "depth": 1 },
10
+ "listedIn": { "direction": "in", "depth": 1 }
11
+ },
12
+ "buckets": {
13
+ "regenerate": ["section", "document"],
14
+ "review": ["useCase", "feature", "requirement"],
15
+ "downstream": ["document"]
16
+ }
17
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "version": 1,
3
+ "rules": [
4
+ {
5
+ "id": "SCHEMA",
6
+ "severity": "error",
7
+ "description": "Graph must validate against schema.graph.json"
8
+ },
9
+ {
10
+ "id": "REGISTRY-COMPLETE",
11
+ "severity": "error",
12
+ "description": "Every registry document and section must exist in the graph"
13
+ },
14
+ {
15
+ "id": "SECTION-TREE",
16
+ "severity": "error",
17
+ "description": "Each section has exactly one partOf parent"
18
+ },
19
+ {
20
+ "id": "DOC-SECTION-COVERAGE",
21
+ "severity": "error",
22
+ "description": "Each document contains at least one section"
23
+ },
24
+ {
25
+ "id": "DOMAIN-ANCHORED",
26
+ "severity": "error",
27
+ "description": "Domain nodes must link to sections via listedIn, definedIn, or describedIn"
28
+ }
29
+ ]
30
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://ai-spector.local/schemas/schema.extract-patch.json",
4
+ "title": "ExtractPatch",
5
+ "type": "object",
6
+ "required": ["version"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "version": { "type": "integer", "const": 1 },
10
+ "nodes": {
11
+ "type": "array",
12
+ "items": { "$ref": "https://ai-spector.local/graph/schema.graph.json#/$defs/node" }
13
+ },
14
+ "edges": {
15
+ "type": "array",
16
+ "items": { "$ref": "https://ai-spector.local/graph/schema.graph.json#/$defs/edge" }
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,83 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://ai-spector.local/graph/schema.graph.json",
4
+ "title": "TraceabilityGraph",
5
+ "type": "object",
6
+ "required": ["version", "nodes", "edges"],
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "version": { "type": "integer", "minimum": 1 },
10
+ "nodes": {
11
+ "type": "array",
12
+ "items": { "$ref": "#/$defs/node" }
13
+ },
14
+ "edges": {
15
+ "type": "array",
16
+ "items": { "$ref": "#/$defs/edge" }
17
+ }
18
+ },
19
+ "$defs": {
20
+ "nodeType": {
21
+ "type": "string",
22
+ "enum": [
23
+ "document",
24
+ "section",
25
+ "table",
26
+ "diagram",
27
+ "actor",
28
+ "useCase",
29
+ "feature",
30
+ "requirement",
31
+ "dataEntity"
32
+ ]
33
+ },
34
+ "edgeType": {
35
+ "type": "string",
36
+ "enum": [
37
+ "partOf",
38
+ "contains",
39
+ "follows",
40
+ "references",
41
+ "listedIn",
42
+ "definedIn",
43
+ "describedIn",
44
+ "satisfies",
45
+ "dependsOn",
46
+ "requires",
47
+ "tracesTo",
48
+ "derivedFrom",
49
+ "rendersTo"
50
+ ]
51
+ },
52
+ "node": {
53
+ "type": "object",
54
+ "required": ["id", "type"],
55
+ "additionalProperties": true,
56
+ "properties": {
57
+ "id": { "type": "string", "minLength": 1 },
58
+ "type": { "$ref": "#/$defs/nodeType" },
59
+ "template": { "type": "string" },
60
+ "output": { "type": "string" },
61
+ "outputPattern": { "type": "string" },
62
+ "perDomain": { "type": "string", "enum": ["useCase", "feature"] },
63
+ "documentId": { "type": "string" },
64
+ "heading": { "type": "string" },
65
+ "level": { "type": "integer", "minimum": 2, "maximum": 6 },
66
+ "order": { "type": "integer", "minimum": 0 },
67
+ "title": { "type": "string" },
68
+ "slug": { "type": "string" }
69
+ }
70
+ },
71
+ "edge": {
72
+ "type": "object",
73
+ "required": ["type", "from", "to"],
74
+ "additionalProperties": false,
75
+ "properties": {
76
+ "type": { "$ref": "#/$defs/edgeType" },
77
+ "from": { "type": "string", "minLength": 1 },
78
+ "to": { "type": "string", "minLength": 1 },
79
+ "role": { "type": "string" }
80
+ }
81
+ }
82
+ }
83
+ }
@@ -0,0 +1,107 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://ai-spector.local/schemas/schema.knowledge.json",
4
+ "title": "AnalysisKnowledge",
5
+ "type": "object",
6
+ "required": ["knowledgeVersion", "actors", "useCases", "features"],
7
+ "additionalProperties": true,
8
+ "properties": {
9
+ "knowledgeVersion": { "type": "integer", "minimum": 1 },
10
+ "generatedAt": { "type": ["string", "null"] },
11
+ "scope": { "type": "array", "items": { "type": "string" } },
12
+ "actors": {
13
+ "type": "array",
14
+ "items": { "$ref": "#/$defs/actor" }
15
+ },
16
+ "useCases": {
17
+ "type": "array",
18
+ "items": { "$ref": "#/$defs/useCase" }
19
+ },
20
+ "features": {
21
+ "type": "array",
22
+ "items": { "$ref": "#/$defs/feature" }
23
+ },
24
+ "functionalRequirements": {
25
+ "type": "array",
26
+ "items": { "$ref": "#/$defs/requirement" }
27
+ },
28
+ "nfrs": {
29
+ "type": "array",
30
+ "items": { "$ref": "#/$defs/requirement" }
31
+ },
32
+ "entities": {
33
+ "type": "array",
34
+ "items": { "$ref": "#/$defs/entity" }
35
+ },
36
+ "interfaces": { "type": "array" },
37
+ "constraints": { "type": "array" },
38
+ "openQuestions": { "type": "array" }
39
+ },
40
+ "$defs": {
41
+ "actor": {
42
+ "type": "object",
43
+ "required": ["id"],
44
+ "additionalProperties": true,
45
+ "properties": {
46
+ "id": { "type": "string", "minLength": 1 },
47
+ "name": { "type": "string" },
48
+ "title": { "type": "string" },
49
+ "description": { "type": "string" },
50
+ "listedInSection": { "type": "string", "minLength": 1 }
51
+ }
52
+ },
53
+ "useCase": {
54
+ "type": "object",
55
+ "required": ["id", "title"],
56
+ "additionalProperties": true,
57
+ "properties": {
58
+ "id": { "type": "string", "minLength": 1 },
59
+ "title": { "type": "string" },
60
+ "priority": { "type": "string" },
61
+ "description": { "type": "string" },
62
+ "listedInSection": { "type": "string", "minLength": 1 }
63
+ }
64
+ },
65
+ "feature": {
66
+ "type": "object",
67
+ "required": ["id", "title"],
68
+ "additionalProperties": true,
69
+ "properties": {
70
+ "id": { "type": "string", "minLength": 1 },
71
+ "title": { "type": "string" },
72
+ "description": { "type": "string" },
73
+ "listedInSection": { "type": "string", "minLength": 1 },
74
+ "satisfies": {
75
+ "type": "array",
76
+ "items": { "type": "string", "minLength": 1 }
77
+ }
78
+ }
79
+ },
80
+ "requirement": {
81
+ "type": "object",
82
+ "required": ["id", "title"],
83
+ "additionalProperties": true,
84
+ "properties": {
85
+ "id": { "type": "string", "minLength": 1 },
86
+ "title": { "type": "string" },
87
+ "description": { "type": "string" },
88
+ "listedInSection": { "type": "string", "minLength": 1 },
89
+ "tracesTo": {
90
+ "type": "array",
91
+ "items": { "type": "string", "minLength": 1 }
92
+ }
93
+ }
94
+ },
95
+ "entity": {
96
+ "type": "object",
97
+ "required": ["id", "name"],
98
+ "additionalProperties": true,
99
+ "properties": {
100
+ "id": { "type": "string", "minLength": 1 },
101
+ "name": { "type": "string" },
102
+ "description": { "type": "string" },
103
+ "listedInSection": { "type": "string", "minLength": 1 }
104
+ }
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,177 @@
1
+ # Database Design: <Project Name>
2
+
3
+ > This document explains the database structure and purpose of each table, helping developers, QA, and DBAs understand data relationships and design rationale.
4
+
5
+ **Source Requirements:** SRS Section 5 (Data Requirements)
6
+
7
+ ---
8
+
9
+ ## 1. Overview
10
+
11
+ **Database Management System:** <PostgreSQL/MySQL/Other>
12
+
13
+ **Purpose:**
14
+ > Describe the main purpose of the database and what business flows it supports.
15
+
16
+ **Source Requirements:**
17
+ > Reference SRS sections that informed this design.
18
+ - SRS Section 4: <Functional Requirements>
19
+ - SRS Section 5: <Data Requirements>
20
+ - SRS Section 7: <Quality Attributes>
21
+
22
+ ---
23
+
24
+ ## 2. Entity-Relationship Diagram
25
+
26
+ > Provide a visual representation of tables and their relationships.
27
+
28
+ ```mermaid
29
+ erDiagram
30
+ ENTITY1 ||--o{ ENTITY2 : "relationship"
31
+ ENTITY1 {
32
+ int id PK
33
+ string name
34
+ datetime created_at
35
+ }
36
+ ENTITY2 {
37
+ int id PK
38
+ int entity1_id FK
39
+ string description
40
+ }
41
+ ```
42
+
43
+ ---
44
+
45
+ ## 3. Table List and Roles
46
+
47
+ | Table Name | Purpose | Main Relationships |
48
+ |------------|---------|-------------------|
49
+ | `<table_name>` | <Purpose description> | <Relationship description> |
50
+ | `<table_name>` | <Purpose description> | <Relationship description> |
51
+
52
+ ---
53
+
54
+ ## 4. Detailed Table Descriptions
55
+
56
+ ### 4.1 `<table_name>`
57
+
58
+ **Purpose:**
59
+ > Describe what this table stores and its role in the system.
60
+
61
+ **Primary Key:** `<field_name>` (<data_type>)
62
+
63
+ **Key Fields:**
64
+
65
+ | Field Name | Data Type | Constraints | Description |
66
+ |------------|-----------|-------------|-------------|
67
+ | `<field_name>` | `<type>` | `<UNIQUE/NOT NULL/CHECK>` | <Description> |
68
+ | `<field_name>` | `<type>` | `<constraints>` | <Description> |
69
+
70
+ **Important Design Decisions:**
71
+ - <Decision 1 and rationale>
72
+ - <Decision 2 and rationale>
73
+
74
+ **Foreign Keys:**
75
+ - `<field_name>` → `<referenced_table>.<referenced_field>` (<relationship description>)
76
+
77
+ **Indexes:**
78
+ - `<index_name>` on `<field_name>` (<purpose>)
79
+
80
+ **Business Rules:**
81
+ - <Business rule 1>
82
+ - <Business rule 2>
83
+
84
+ ---
85
+
86
+ ### 4.2 `<table_name>`
87
+
88
+ **Purpose:**
89
+ > Describe what this table stores.
90
+
91
+ **Primary Key:** `<field_name>` (<data_type>)
92
+
93
+ **Key Fields:**
94
+
95
+ | Field Name | Data Type | Constraints | Description |
96
+ |------------|-----------|-------------|-------------|
97
+ | `<field_name>` | `<type>` | `<constraints>` | <Description> |
98
+
99
+ **Foreign Keys:**
100
+ - `<field_name>` → `<referenced_table>.<referenced_field>`
101
+
102
+ **Indexes:**
103
+ - `<index_name>` on `<field_name>`
104
+
105
+ ---
106
+
107
+ ## 5. Relationships Summary
108
+
109
+ > Document all relationships between tables.
110
+
111
+ | From Table | Relationship Type | To Table | Description |
112
+ |------------|-------------------|----------|-------------|
113
+ | `<table1>` | One-to-Many | `<table2>` | <Description> |
114
+ | `<table1>` | Many-to-Many | `<table2>` | <Description> |
115
+
116
+ ---
117
+
118
+ ## 6. Data Integrity Rules
119
+
120
+ **Constraints:**
121
+ - <Constraint 1>
122
+ - <Constraint 2>
123
+
124
+ **Validation Rules:**
125
+ - <Validation rule 1>
126
+ - <Validation rule 2>
127
+
128
+ **Referential Integrity:**
129
+ - <Cascade/restrict/set null behavior>
130
+
131
+ ---
132
+
133
+ ## 7. Performance Considerations
134
+
135
+ **Indexes:**
136
+ > List indexes for query optimization.
137
+
138
+ | Index Name | Table | Fields | Purpose |
139
+ |------------|-------|--------|---------|
140
+ | `<index_name>` | `<table>` | `<fields>` | <Purpose> |
141
+
142
+ **Query Optimization Notes:**
143
+ - <Note 1>
144
+ - <Note 2>
145
+
146
+ ---
147
+
148
+ ## 8. Security Considerations
149
+
150
+ **Access Control:**
151
+ - <Access control requirement 1>
152
+ - <Access control requirement 2>
153
+
154
+ **Data Protection:**
155
+ - <Protection measure 1>
156
+ - <Protection measure 2>
157
+
158
+ ---
159
+
160
+ ## 9. Future Extensions
161
+
162
+ > Document potential future enhancements or changes.
163
+
164
+ - <Extension 1>
165
+ - <Extension 2>
166
+
167
+ ---
168
+
169
+ ## 10. Notes
170
+
171
+ **Migration Strategy:**
172
+ > Reference migration tool or approach (e.g., Flyway, Liquibase).
173
+
174
+ **Testing Considerations:**
175
+ - <Testing note 1>
176
+ - <Testing note 2>
177
+