@rashidee/co2 1.2.5
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/dist/index.js +25449 -0
- package/drizzle/0000_remarkable_charles_xavier.sql +210 -0
- package/drizzle/0001_wise_wolf_cub.sql +13 -0
- package/drizzle/0002_secret_spyke.sql +16 -0
- package/drizzle/0003_workspace_config_singleton.sql +16 -0
- package/drizzle/0004_terminal_claim_v120.sql +11 -0
- package/drizzle/0005_brainstorm_v124.sql +10 -0
- package/drizzle/0006_project_v140.sql +6 -0
- package/drizzle/0007_prd_wizard_v124.sql +14 -0
- package/drizzle/0008_workflow_artifact_v126.sql +24 -0
- package/drizzle/0009_project_import_v150.sql +7 -0
- package/drizzle/0010_quality_v151.sql +3 -0
- package/drizzle/meta/0000_snapshot.json +1335 -0
- package/drizzle/meta/0001_snapshot.json +1416 -0
- package/drizzle/meta/0002_snapshot.json +1510 -0
- package/drizzle/meta/_journal.json +83 -0
- package/package.json +41 -0
- package/plugin/.claude-plugin/marketplace.json +36 -0
- package/plugin/.claude-plugin/plugin.json +22 -0
- package/plugin/README.md +625 -0
- package/plugin/SKILLS.md +350 -0
- package/plugin/co2.svg +5 -0
- package/plugin/commands/brainstorm-loop.md +129 -0
- package/plugin/skills/conductor-defect/SKILL.md +898 -0
- package/plugin/skills/conductor-feature-develop/SKILL.md +1383 -0
- package/plugin/skills/conductor-feature-develop/references/implementation-domain-template.md +131 -0
- package/plugin/skills/conductor-feature-develop/references/implementation-master-template.md +89 -0
- package/plugin/skills/conductor-feature-develop/references/playwright-setup.md +224 -0
- package/plugin/skills/conductor-feature-prepare/SKILL.md +604 -0
- package/plugin/skills/depgen-k8s/SKILL.md +468 -0
- package/plugin/skills/depgen-k8s/references/dockerfile-laravel.md +197 -0
- package/plugin/skills/depgen-k8s/references/dockerfile-nodejs.md +163 -0
- package/plugin/skills/depgen-k8s/references/dockerfile-spring-boot.md +174 -0
- package/plugin/skills/depgen-k8s/references/k8s-patterns.md +869 -0
- package/plugin/skills/mockgen-shadcn/SKILL.md +1067 -0
- package/plugin/skills/mockgen-shadcn/references/admin-layout-template.md +1467 -0
- package/plugin/skills/mockgen-shadcn/references/mockup-hub-template.md +498 -0
- package/plugin/skills/mockgen-shadcn/references/mockup-index-template.md +216 -0
- package/plugin/skills/mockgen-tailwind/SKILL.md +904 -0
- package/plugin/skills/mockgen-tailwind/references/admin-layout-template.md +720 -0
- package/plugin/skills/mockgen-tailwind/references/mockup-hub-template.md +498 -0
- package/plugin/skills/mockgen-tailwind/references/mockup-index-template.md +190 -0
- package/plugin/skills/modelgen-nosql/SKILL.md +617 -0
- package/plugin/skills/modelgen-nosql/references/model-extraction-methodology.md +497 -0
- package/plugin/skills/modelgen-nosql/references/nosql-design-guide.md +258 -0
- package/plugin/skills/modelgen-relational/SKILL.md +707 -0
- package/plugin/skills/modelgen-relational/references/model-extraction-methodology.md +499 -0
- package/plugin/skills/specgen-flutter-riverpod/SKILL.md +898 -0
- package/plugin/skills/specgen-flutter-riverpod/references/component-patterns.md +971 -0
- package/plugin/skills/specgen-flutter-riverpod/references/notification-patterns.md +457 -0
- package/plugin/skills/specgen-flutter-riverpod/references/routing-patterns.md +362 -0
- package/plugin/skills/specgen-flutter-riverpod/references/security-patterns.md +709 -0
- package/plugin/skills/specgen-flutter-riverpod/references/spec-template.md +1566 -0
- package/plugin/skills/specgen-flutter-riverpod/references/state-patterns.md +518 -0
- package/plugin/skills/specgen-flutter-riverpod/references/storage-patterns.md +370 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/SKILL.md +984 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/batch-patterns.md +359 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/messaging-patterns.md +468 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/modulith-patterns.md +461 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/reporting-patterns.md +803 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/security-patterns.md +501 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/spec-template.md +1268 -0
- package/plugin/skills/specgen-laravel-eloquent-bladehtmx/references/web-patterns.md +301 -0
- package/plugin/skills/specgen-node-cli-web/SKILL.md +561 -0
- package/plugin/skills/specgen-node-cli-web/references/auth-patterns.md +293 -0
- package/plugin/skills/specgen-node-cli-web/references/cli-packaging-patterns.md +250 -0
- package/plugin/skills/specgen-node-cli-web/references/server-patterns.md +247 -0
- package/plugin/skills/specgen-node-cli-web/references/spec-template.md +401 -0
- package/plugin/skills/specgen-node-cli-web/references/testing-patterns.md +174 -0
- package/plugin/skills/specgen-react-mui/SKILL.md +789 -0
- package/plugin/skills/specgen-react-mui/references/component-patterns.md +1077 -0
- package/plugin/skills/specgen-react-mui/references/reporting-patterns.md +1998 -0
- package/plugin/skills/specgen-react-mui/references/routing-patterns.md +461 -0
- package/plugin/skills/specgen-react-mui/references/security-patterns.md +599 -0
- package/plugin/skills/specgen-react-mui/references/spec-template.md +1030 -0
- package/plugin/skills/specgen-react-mui/references/state-patterns.md +327 -0
- package/plugin/skills/specgen-react-tailwind/SKILL.md +859 -0
- package/plugin/skills/specgen-react-tailwind/references/component-patterns.md +1212 -0
- package/plugin/skills/specgen-react-tailwind/references/reporting-patterns.md +1529 -0
- package/plugin/skills/specgen-react-tailwind/references/routing-patterns.md +669 -0
- package/plugin/skills/specgen-react-tailwind/references/security-patterns.md +656 -0
- package/plugin/skills/specgen-react-tailwind/references/spec-template.md +1237 -0
- package/plugin/skills/specgen-react-tailwind/references/state-patterns.md +327 -0
- package/plugin/skills/specgen-sdk-java/SKILL.md +933 -0
- package/plugin/skills/specgen-sdk-java/references/api-extraction-patterns.md +247 -0
- package/plugin/skills/specgen-sdk-java/references/http-client-patterns.md +495 -0
- package/plugin/skills/specgen-sdk-java/references/packaging-patterns.md +366 -0
- package/plugin/skills/specgen-sdk-java/references/spec-template.md +956 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/SKILL.md +1284 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/batch-patterns.md +1224 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/jasper-patterns.md +1638 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/messaging-patterns.md +512 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/modulith-patterns.md +354 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/security-patterns.md +551 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/spec-template.md +2502 -0
- package/plugin/skills/specgen-spring-jpa-jtehtmx/references/web-patterns.md +503 -0
- package/plugin/skills/specgen-spring-jpa-restapi/SKILL.md +990 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/batch-patterns.md +1224 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/messaging-patterns.md +512 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/modulith-patterns.md +279 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/reporting-patterns.md +1536 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/restapi-patterns.md +722 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/security-patterns.md +351 -0
- package/plugin/skills/specgen-spring-jpa-restapi/references/spec-template.md +553 -0
- package/plugin/skills/specgen-ts-cli/SKILL.md +861 -0
- package/plugin/skills/specgen-ts-cli/references/async-patterns.md +1101 -0
- package/plugin/skills/specgen-ts-cli/references/command-patterns.md +383 -0
- package/plugin/skills/specgen-ts-cli/references/config-patterns.md +430 -0
- package/plugin/skills/specgen-ts-cli/references/database-patterns.md +750 -0
- package/plugin/skills/specgen-ts-cli/references/packaging-patterns.md +426 -0
- package/plugin/skills/specgen-ts-cli/references/spec-template.md +1391 -0
- package/plugin/skills/specgen-ts-cli/references/testing-patterns.md +909 -0
- package/plugin/skills/testgen-functional/SKILL.md +1381 -0
- package/plugin/skills/tracegen-matrix/SKILL.md +243 -0
- package/plugin/skills/util-preparek8senv/SKILL.md +422 -0
- package/plugin/skills/util-projectinit/SKILL.md +307 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-loop.md +129 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-protocol.md +144 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-setup-guide.md +153 -0
- package/plugin/skills/util-projectinit/reference/brainstorm-template-appdev.md +87 -0
- package/plugin/skills/util-projectinit/reference/co2-context-generation-guide.md +761 -0
- package/plugin/skills/util-projectsync/SKILL.md +501 -0
- package/plugin/skills/util-updprd/SKILL.md +324 -0
- package/plugin/skills/util-usanalyzer/SKILL.md +307 -0
- package/plugin/skills/util-ustagger/SKILL.md +154 -0
- package/static/assets/abnfDiagram-VRR7QNED-DvPuwyCV.js +1 -0
- package/static/assets/arc-DRKw7sjs.js +1 -0
- package/static/assets/architectureDiagram-ZJ3FMSHR-CaNcxUbC.js +36 -0
- package/static/assets/blockDiagram-677ZJIJ3-Demd4AOK.js +132 -0
- package/static/assets/c4Diagram-LMCZKHZV-PVKUfc2x.js +10 -0
- package/static/assets/channel-C2nVbuwv.js +1 -0
- package/static/assets/chunk-2Q5K7J3B-CExf8ww_.js +1 -0
- package/static/assets/chunk-32BRIVSS-CFPaoONF.js +1 -0
- package/static/assets/chunk-5VM5RSS4-DE2esM67.js +15 -0
- package/static/assets/chunk-EX3LRPZG-SON_YdDG.js +231 -0
- package/static/assets/chunk-JWPE2WC7-Qxah8LNr.js +1 -0
- package/static/assets/chunk-MOJQB5TN-BcWGQV3j.js +88 -0
- package/static/assets/chunk-RYQCIY6F-DkDj-OR5.js +1 -0
- package/static/assets/chunk-V7JOEXUC-BlI1Mrah.js +206 -0
- package/static/assets/chunk-VR4S4FIN-Agf__duj.js +1 -0
- package/static/assets/chunk-XXDRQBXY-B5CfAh85.js +1 -0
- package/static/assets/classDiagram-OUVF2IWQ-DXJIljsR.js +1 -0
- package/static/assets/classDiagram-v2-EOCWNBFH-DXJIljsR.js +1 -0
- package/static/assets/cose-bilkent-JH36ORCC-DO0cQkcy.js +1 -0
- package/static/assets/cynefin-VYW2F7L2-CfOnsnXc.js +178 -0
- package/static/assets/cynefinDiagram-TSTJHNR4-BJ8tULAv.js +62 -0
- package/static/assets/cytoscape.esm-DTSO7Bv0.js +331 -0
- package/static/assets/dagre-VKFMJZFB-DfjwzHqP.js +4 -0
- package/static/assets/defaultLocale-DX6XiGOO.js +1 -0
- package/static/assets/diagram-FQU43EPY-CndSOIIM.js +3 -0
- package/static/assets/diagram-G47NLZAW-Czf5hN0Z.js +24 -0
- package/static/assets/diagram-NH7WQ7WH-COAyojGh.js +24 -0
- package/static/assets/diagram-OA4YK3LP-H8PoiN2m.js +30 -0
- package/static/assets/diagram-WEI45ONY-DzcaVzjp.js +41 -0
- package/static/assets/ebnfDiagram-CCIWWBDH-DPazGYLJ.js +1 -0
- package/static/assets/erDiagram-Q63AITRT-Bo-fubgF.js +85 -0
- package/static/assets/flowDiagram-23GEKE2U-CSvxUDwh.js +156 -0
- package/static/assets/ganttDiagram-NO4QXBWP-DnBveWX6.js +292 -0
- package/static/assets/gitGraphDiagram-IHSO6WYX-B3rVL8c-.js +106 -0
- package/static/assets/graph-C9eacEi8.js +1 -0
- package/static/assets/index-LZSQkLE2.css +41 -0
- package/static/assets/index-y7XDSgMG.js +495 -0
- package/static/assets/infoDiagram-FWYZ7A6U-CvWV9yy2.js +2 -0
- package/static/assets/init-Gi6I4Gst.js +1 -0
- package/static/assets/ishikawaDiagram-FXEZZL3T-DF28a1N6.js +70 -0
- package/static/assets/journeyDiagram-5HDEW3XC-CB6CugYk.js +139 -0
- package/static/assets/kanban-definition-HUTT4EX6-ResSLF6d.js +89 -0
- package/static/assets/katex-C5jXJg4s.js +257 -0
- package/static/assets/layout-DEXfKzaS.js +1 -0
- package/static/assets/linear-CLO--ryk.js +1 -0
- package/static/assets/map-Czzmt4hB.js +1 -0
- package/static/assets/mindmap-definition-LN4V7U3C-BvW3EbxX.js +96 -0
- package/static/assets/ordinal-Cboi1Yqb.js +1 -0
- package/static/assets/pegDiagram-2B236MQR-BHCgqrrM.js +1 -0
- package/static/assets/pieDiagram-ENE6RG2P-DVmCQ5FA.js +39 -0
- package/static/assets/quadrantDiagram-ABIIQ3AL-B3e5KR52.js +7 -0
- package/static/assets/railroadDiagram-RFXS5EU6-Csv5ysLc.js +1 -0
- package/static/assets/requirementDiagram-TGXJPOKE-DOMVzvnB.js +84 -0
- package/static/assets/sankeyDiagram-HTMAVEWB-B1dcTOvy.js +40 -0
- package/static/assets/sequenceDiagram-DBY2YBRQ-BY414yeO.js +162 -0
- package/static/assets/sizeCapture-X5ZJPWSS-CuJfrfBN.js +1 -0
- package/static/assets/stateDiagram-2N3HPSRC-FX4rJkzV.js +1 -0
- package/static/assets/stateDiagram-v2-6OUMAXLB-BVufbO_H.js +1 -0
- package/static/assets/swimlanes-5IMT3BWC-Sfy58mmv.js +2 -0
- package/static/assets/swimlanesDiagram-G3AALYLV-wDCDw08H.js +8 -0
- package/static/assets/timeline-definition-FHXFAJF6-CmV7by8p.js +120 -0
- package/static/assets/vennDiagram-L72KCM5P-FqIyFZFt.js +34 -0
- package/static/assets/wardleyDiagram-EHGQE667-BZ06O45i.js +78 -0
- package/static/assets/xychartDiagram-FW5EYKEG-BOkffR06.js +7 -0
- package/static/index.html +24 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# NoSQL Document Design Reference
|
|
2
|
+
|
|
3
|
+
This reference contains the document-oriented design principles, embed-vs-reference
|
|
4
|
+
decision framework, and output format conventions used by the NoSQL Domain Model Extractor.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Key Concepts: Document Model vs Relational Model
|
|
9
|
+
|
|
10
|
+
Document modeling inverts the relational mindset. Understanding these differences is essential
|
|
11
|
+
for producing correct output.
|
|
12
|
+
|
|
13
|
+
| Concern | Relational (RDBMS) | Document (NoSQL) |
|
|
14
|
+
|---------|--------------------|------------------|
|
|
15
|
+
| Design driver | Data structure and normalization | Access patterns and query shapes |
|
|
16
|
+
| Core unit | Table with rows | Collection with documents |
|
|
17
|
+
| Relationships | Foreign keys + JOINs | Embedding or referencing |
|
|
18
|
+
| 1:1 / 1:Few | Separate table with FK | Embed as nested object |
|
|
19
|
+
| 1:Many (bounded) | Separate table with FK | Embed as array within parent document |
|
|
20
|
+
| 1:Many (unbounded) | Separate table with FK | Separate collection with reference |
|
|
21
|
+
| Many:Many | Join table | Array of references on one or both sides, or bucket pattern |
|
|
22
|
+
| Normalization | 3NF default | Denormalize for read performance |
|
|
23
|
+
| Transactions | Cross-table transactions | Prefer single-document atomicity; cross-collection only when necessary |
|
|
24
|
+
| Schema | Strict, predefined | Flexible, but validation recommended |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## The Embed vs Reference Decision
|
|
29
|
+
|
|
30
|
+
This is the most critical design decision in document modeling. Every relationship must go
|
|
31
|
+
through this decision.
|
|
32
|
+
|
|
33
|
+
**Embed when:**
|
|
34
|
+
- The child data is always accessed with the parent (high read locality)
|
|
35
|
+
- The child has no independent lifecycle (cannot exist without the parent)
|
|
36
|
+
- The child cardinality is bounded and small (typically < 100 items)
|
|
37
|
+
- The child is rarely updated independently of the parent
|
|
38
|
+
- The combined document stays within size limits (typically < 16MB)
|
|
39
|
+
- You need atomic updates across parent and child
|
|
40
|
+
|
|
41
|
+
**Reference when:**
|
|
42
|
+
- The child has an independent lifecycle (created/queried/deleted on its own)
|
|
43
|
+
- The child is shared across multiple parents (many-to-many)
|
|
44
|
+
- The child cardinality is unbounded or very large
|
|
45
|
+
- The child is frequently updated independently
|
|
46
|
+
- The child data is large and would bloat the parent document
|
|
47
|
+
- You need to query the child collection independently
|
|
48
|
+
|
|
49
|
+
**Hybrid (denormalize + reference) when:**
|
|
50
|
+
- You reference a separate collection but embed a summary/snapshot of frequently-read
|
|
51
|
+
fields to avoid cross-collection lookups for common queries
|
|
52
|
+
|
|
53
|
+
### Decision Flowchart
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Is the child always accessed with the parent?
|
|
57
|
+
├── YES
|
|
58
|
+
│ Is the cardinality bounded and small (< 100)?
|
|
59
|
+
│ ├── YES
|
|
60
|
+
│ │ Is the child updated independently and frequently?
|
|
61
|
+
│ │ ├── YES → REFERENCE (separate collection)
|
|
62
|
+
│ │ └── NO → EMBED (nested document or array)
|
|
63
|
+
│ └── NO → REFERENCE (unbounded cardinality)
|
|
64
|
+
└── NO
|
|
65
|
+
Does the child have an independent lifecycle?
|
|
66
|
+
├── YES → REFERENCE (separate collection)
|
|
67
|
+
└── NO
|
|
68
|
+
Is the child shared across multiple parents?
|
|
69
|
+
├── YES → REFERENCE (with optional denormalized summary)
|
|
70
|
+
└── NO → EMBED
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## DDD to Document Model Classification
|
|
76
|
+
|
|
77
|
+
| DDD Classification | Document Model Mapping |
|
|
78
|
+
|--------------------|----------------------|
|
|
79
|
+
| Aggregate Root | **Root Collection** — becomes its own collection. This is the primary document. |
|
|
80
|
+
| Entity (within aggregate) | **Embedded Document** — nested inside the aggregate root's document. Only promote to a separate collection if it has an independent lifecycle or unbounded cardinality. |
|
|
81
|
+
| Value Object | **Embedded Object** — always embedded, never a separate collection. |
|
|
82
|
+
| Enum / Type | **Enum field** — stored as a string field with documented allowed values. |
|
|
83
|
+
| Join Entity (M:N) | **Array of references** — stored as an array of IDs on one or both sides. Only create a separate collection if the join carries significant data (> 3 fields beyond the two FKs). |
|
|
84
|
+
| Domain Event | **Event document** — may warrant its own collection if event sourcing is needed. |
|
|
85
|
+
|
|
86
|
+
**Key rule:** Start by embedding everything inside the aggregate root. Then selectively
|
|
87
|
+
promote to separate collections only when one of the "Reference when" criteria is met.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Access Pattern Analysis Matrix
|
|
92
|
+
|
|
93
|
+
For each collection candidate, determine:
|
|
94
|
+
|
|
95
|
+
| Analysis | Question | Impact |
|
|
96
|
+
|----------|----------|--------|
|
|
97
|
+
| **Read pattern** | Is this data always read together with its parent? | If yes → embed |
|
|
98
|
+
| **Write pattern** | Is this data updated independently of its parent? | If yes → reference |
|
|
99
|
+
| **Cardinality** | How many child items per parent? | Bounded & small → embed; unbounded → reference |
|
|
100
|
+
| **Size** | How large is each child document? | Large → reference to avoid bloating parent |
|
|
101
|
+
| **Query independence** | Do you need to query this data without knowing the parent? | If yes → reference |
|
|
102
|
+
| **Sharing** | Is this data referenced by multiple parents? | If yes → reference |
|
|
103
|
+
| **Update frequency** | How often does the child change relative to the parent? | High independent change → reference |
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Document-Specific Field Conventions
|
|
108
|
+
|
|
109
|
+
| Convention | RDBMS Equivalent | Document Model |
|
|
110
|
+
|------------|------------------|----------------|
|
|
111
|
+
| Primary key | `id` (UUID) | `_id` (ObjectId or UUID, depending on platform) |
|
|
112
|
+
| Foreign key | `department_id` (FK) | `departmentId` (reference) or embedded `department: { ... }` |
|
|
113
|
+
| Audit fields | Per-table columns | Embedded `_audit: { createdAt, createdBy, updatedAt, updatedBy }` or top-level fields |
|
|
114
|
+
| Soft delete | `deleted`, `deletedAt`, `deletedBy` | Same fields, top-level in document |
|
|
115
|
+
| Versioning | `version` (Long) | `_version` (Number) for optimistic concurrency |
|
|
116
|
+
| Timestamps | `Instant` | `ISODate` (ISO 8601 string) |
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## NFR Adaptation for Document Model
|
|
121
|
+
|
|
122
|
+
| NFR | RDBMS Impact | Document Model Impact |
|
|
123
|
+
|-----|-------------|----------------------|
|
|
124
|
+
| Audit Trail | Audit log table | Embedded `_audit` object or separate audit collection (if queried independently) |
|
|
125
|
+
| Soft Delete | `deleted` column | `deleted`, `deletedAt`, `deletedBy` top-level fields |
|
|
126
|
+
| Multi-Tenancy | `tenantId` column + RLS | `tenantId` top-level field + collection-level or document-level access control |
|
|
127
|
+
| Optimistic Locking | `version` column | `_version` field |
|
|
128
|
+
| Full-Text Search | Indexed columns | Text indexes or dedicated search fields; consider search-specific denormalization |
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## Output Format Conventions
|
|
133
|
+
|
|
134
|
+
### Mermaid Class Diagram Conventions
|
|
135
|
+
|
|
136
|
+
- Each root collection is a class with stereotype `<<collection>>`
|
|
137
|
+
- Each embedded document is a class with stereotype `<<embedded>>`
|
|
138
|
+
- Each enum is a class with stereotype `<<enum>>`
|
|
139
|
+
- Composition arrows (`*--`) indicate embedding (child lives inside parent document)
|
|
140
|
+
- Association arrows (`o--`) indicate referencing (separate collection, linked by ID)
|
|
141
|
+
- Array relationships use `"1..*"` or `"0..*"` multiplicity notation
|
|
142
|
+
- Collection names use `lower_snake_case` **with 3-character module prefix** (e.g., `usm_employees`)
|
|
143
|
+
- Embedded document names use `PascalCase` (no prefix, since they're not standalone collections)
|
|
144
|
+
- Field names use `camelCase`
|
|
145
|
+
|
|
146
|
+
### Mermaid Diagram Example
|
|
147
|
+
|
|
148
|
+
```mermaid
|
|
149
|
+
%% Module: User Management | Prefix: USM
|
|
150
|
+
%% Versions included: 1.0, 1.1
|
|
151
|
+
%% Document Model - Collections, Embedded Documents, and References
|
|
152
|
+
|
|
153
|
+
classDiagram
|
|
154
|
+
class usm_employees {
|
|
155
|
+
<<collection>>
|
|
156
|
+
ObjectId _id
|
|
157
|
+
String firstName
|
|
158
|
+
String lastName
|
|
159
|
+
String email
|
|
160
|
+
String phone
|
|
161
|
+
String employeeCode
|
|
162
|
+
EmployeeStatus status
|
|
163
|
+
ISODate statusChangedAt
|
|
164
|
+
String statusChangedBy
|
|
165
|
+
Department department
|
|
166
|
+
Role[] roles
|
|
167
|
+
Audit _audit
|
|
168
|
+
Boolean deleted
|
|
169
|
+
ISODate deletedAt
|
|
170
|
+
Number _version
|
|
171
|
+
}
|
|
172
|
+
class Department {
|
|
173
|
+
<<embedded>>
|
|
174
|
+
ObjectId refId
|
|
175
|
+
String name
|
|
176
|
+
String code
|
|
177
|
+
}
|
|
178
|
+
class Role {
|
|
179
|
+
<<embedded>>
|
|
180
|
+
ObjectId refId
|
|
181
|
+
String name
|
|
182
|
+
String code
|
|
183
|
+
ISODate assignedAt
|
|
184
|
+
String assignedBy
|
|
185
|
+
}
|
|
186
|
+
class Audit {
|
|
187
|
+
<<embedded>>
|
|
188
|
+
ISODate createdAt
|
|
189
|
+
String createdBy
|
|
190
|
+
ISODate updatedAt
|
|
191
|
+
String updatedBy
|
|
192
|
+
}
|
|
193
|
+
class EmployeeStatus {
|
|
194
|
+
<<enum>>
|
|
195
|
+
ACTIVE
|
|
196
|
+
INACTIVE
|
|
197
|
+
}
|
|
198
|
+
class usm_departments {
|
|
199
|
+
<<collection>>
|
|
200
|
+
ObjectId _id
|
|
201
|
+
String name
|
|
202
|
+
String code
|
|
203
|
+
String description
|
|
204
|
+
Audit _audit
|
|
205
|
+
Boolean deleted
|
|
206
|
+
Number _version
|
|
207
|
+
}
|
|
208
|
+
class usm_roles {
|
|
209
|
+
<<collection>>
|
|
210
|
+
ObjectId _id
|
|
211
|
+
String name
|
|
212
|
+
String code
|
|
213
|
+
String description
|
|
214
|
+
Audit _audit
|
|
215
|
+
Boolean deleted
|
|
216
|
+
Number _version
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
usm_employees *-- Department : embeds
|
|
220
|
+
usm_employees *-- "0..*" Role : embeds array
|
|
221
|
+
usm_employees *-- Audit : embeds
|
|
222
|
+
usm_employees *-- EmployeeStatus : status
|
|
223
|
+
usm_employees o-- usm_departments : "department.refId references"
|
|
224
|
+
usm_employees o-- usm_roles : "roles[].refId references"
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### JSON Schema Example Format
|
|
228
|
+
|
|
229
|
+
```json
|
|
230
|
+
{
|
|
231
|
+
"_meta": {
|
|
232
|
+
"module": "Module Name",
|
|
233
|
+
"prefix": "XXX",
|
|
234
|
+
"versions": ["1.0", "1.1"],
|
|
235
|
+
"generatedBy": "modelgen-nosql"
|
|
236
|
+
},
|
|
237
|
+
"collections": {
|
|
238
|
+
"xxx_collection_name": {
|
|
239
|
+
"description": "Purpose of the collection",
|
|
240
|
+
"exampleDocument": {
|
|
241
|
+
"_id": "ObjectId('...')",
|
|
242
|
+
"field": "value"
|
|
243
|
+
},
|
|
244
|
+
"indexes": [
|
|
245
|
+
{ "field": "fieldName", "type": "unique" }
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Each collection entry must include:
|
|
253
|
+
- `description` — purpose of the collection
|
|
254
|
+
- `exampleDocument` — full document with realistic sample values showing all fields,
|
|
255
|
+
embedded documents, and arrays
|
|
256
|
+
- `indexes` — recommended indexes derived from access patterns and query needs
|
|
257
|
+
|
|
258
|
+
Index type values: `unique`, `single`, `compound`, `text`, `ttl`
|