dhurandhar 1.0.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/.dhurandhar-session-start.md +242 -0
- package/LICENSE +21 -0
- package/README.md +416 -0
- package/docs/ARCHITECTURE_V2.md +249 -0
- package/docs/DECISION_REGISTRY.md +357 -0
- package/docs/IMPLEMENTATION_PERSONAS.md +406 -0
- package/docs/PLUGGABLE_STRATEGIES.md +439 -0
- package/docs/SYSTEM_OBSERVER.md +433 -0
- package/docs/TEST_FIRST_AGILE.md +359 -0
- package/docs/architecture.md +279 -0
- package/docs/engineering-first-philosophy.md +263 -0
- package/docs/getting-started.md +218 -0
- package/docs/module-development.md +323 -0
- package/docs/strategy-example.md +299 -0
- package/docs/test-first-example.md +392 -0
- package/package.json +79 -0
- package/src/core/README.md +92 -0
- package/src/core/agent-instructions/backend-developer.md +412 -0
- package/src/core/agent-instructions/devops-engineer.md +372 -0
- package/src/core/agent-instructions/dhurandhar-council.md +547 -0
- package/src/core/agent-instructions/edge-case-hunter.md +322 -0
- package/src/core/agent-instructions/frontend-developer.md +494 -0
- package/src/core/agent-instructions/lead-system-architect.md +631 -0
- package/src/core/agent-instructions/system-observer.md +319 -0
- package/src/core/agent-instructions/test-architect.md +284 -0
- package/src/core/module.yaml +54 -0
- package/src/core/schemas/design-module-schema.yaml +995 -0
- package/src/core/schemas/system-design-map-schema.yaml +324 -0
- package/src/modules/example/README.md +130 -0
- package/src/modules/example/module.yaml +252 -0
- package/tools/cli/commands/audit.js +267 -0
- package/tools/cli/commands/config.js +113 -0
- package/tools/cli/commands/context.js +170 -0
- package/tools/cli/commands/decisions.js +398 -0
- package/tools/cli/commands/entity.js +218 -0
- package/tools/cli/commands/epic.js +125 -0
- package/tools/cli/commands/install.js +172 -0
- package/tools/cli/commands/module.js +109 -0
- package/tools/cli/commands/service.js +167 -0
- package/tools/cli/commands/story.js +225 -0
- package/tools/cli/commands/strategy.js +294 -0
- package/tools/cli/commands/test.js +277 -0
- package/tools/cli/commands/validate.js +107 -0
- package/tools/cli/dhurandhar.js +212 -0
- package/tools/lib/config-manager.js +170 -0
- package/tools/lib/filesystem.js +126 -0
- package/tools/lib/module-installer.js +61 -0
- package/tools/lib/module-manager.js +149 -0
- package/tools/lib/sdm-manager.js +982 -0
- package/tools/lib/test-engine.js +255 -0
- package/tools/lib/test-templates/api-client.template.js +100 -0
- package/tools/lib/test-templates/vitest.config.template.js +37 -0
- package/tools/lib/validators/config-validator.js +113 -0
- package/tools/lib/validators/module-validator.js +137 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Dhurandhar Session Start Protocol
|
|
2
|
+
|
|
3
|
+
## System Observer - Primary Rehydration Persona
|
|
4
|
+
|
|
5
|
+
When starting a new session with Dhurandhar, the **System Observer** is ALWAYS invoked first.
|
|
6
|
+
|
|
7
|
+
## Session Start Sequence
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
1. System Observer loads SYSTEM_DESIGN_MAP.yaml
|
|
11
|
+
2. Performs silent background audit
|
|
12
|
+
3. Generates context summary
|
|
13
|
+
4. Checks drift percentage
|
|
14
|
+
5. Provides context to other personas
|
|
15
|
+
6. Reports to user (if drift > 25%)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Automatic Rehydration Report
|
|
19
|
+
|
|
20
|
+
### Format
|
|
21
|
+
|
|
22
|
+
```markdown
|
|
23
|
+
[System Observer] Session Rehydrated
|
|
24
|
+
|
|
25
|
+
Project: [name]
|
|
26
|
+
Architecture: [type]
|
|
27
|
+
Last Updated: [timestamp]
|
|
28
|
+
|
|
29
|
+
Active Strategies:
|
|
30
|
+
Persistence: [model]
|
|
31
|
+
Communication: [pattern]
|
|
32
|
+
Security: [auth_type]
|
|
33
|
+
Resilience: [circuit_breaker status]
|
|
34
|
+
|
|
35
|
+
Architecture Status:
|
|
36
|
+
Services: [X]/[Y] implemented
|
|
37
|
+
Entities: [X]/[Y] implemented
|
|
38
|
+
Stories: [X]/[Y] tested
|
|
39
|
+
Strategy Compliance: [XX]%
|
|
40
|
+
|
|
41
|
+
Drift: [X]%
|
|
42
|
+
[If drift > 25%: ⚠ Significant drift detected. Run: dhurandhar audit --summary]
|
|
43
|
+
|
|
44
|
+
Definition of Done:
|
|
45
|
+
EPIC-001: [XX]% ([X]/[Y] stories complete)
|
|
46
|
+
EPIC-002: [XX]% ([X]/[Y] stories complete)
|
|
47
|
+
|
|
48
|
+
Ready. What's next?
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Example Rehydration (Healthy System)
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
[System Observer] Session Rehydrated
|
|
55
|
+
|
|
56
|
+
Project: ecommerce-platform
|
|
57
|
+
Architecture: microservices
|
|
58
|
+
Last Updated: 2024-01-15T10:30:00Z
|
|
59
|
+
|
|
60
|
+
Active Strategies:
|
|
61
|
+
Persistence: database_per_service
|
|
62
|
+
Communication: asynchronous_events (kafka)
|
|
63
|
+
Security: jwt_centralized
|
|
64
|
+
Resilience: Circuit breaker enabled
|
|
65
|
+
|
|
66
|
+
Architecture Status:
|
|
67
|
+
Services: 5/5 implemented
|
|
68
|
+
Entities: 8/8 implemented
|
|
69
|
+
Stories: 12/12 tested
|
|
70
|
+
Strategy Compliance: 100%
|
|
71
|
+
|
|
72
|
+
Drift: 0%
|
|
73
|
+
|
|
74
|
+
Definition of Done:
|
|
75
|
+
EPIC-001 (User Authentication): 100% (5/5 stories complete)
|
|
76
|
+
EPIC-002 (Order Processing): 100% (7/7 stories complete)
|
|
77
|
+
|
|
78
|
+
Ready. What's next?
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Example Rehydration (Drift Detected)
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
[System Observer] Session Rehydrated
|
|
85
|
+
|
|
86
|
+
Project: my-platform
|
|
87
|
+
Architecture: microservices
|
|
88
|
+
Last Updated: 2024-01-14T15:45:00Z
|
|
89
|
+
|
|
90
|
+
Active Strategies:
|
|
91
|
+
Persistence: database_per_service
|
|
92
|
+
Communication: asynchronous_events (kafka)
|
|
93
|
+
Security: jwt_centralized
|
|
94
|
+
|
|
95
|
+
Architecture Status:
|
|
96
|
+
Services: 3/5 implemented
|
|
97
|
+
Entities: 6/8 implemented
|
|
98
|
+
Stories: 8/12 tested
|
|
99
|
+
Strategy Compliance: 80%
|
|
100
|
+
|
|
101
|
+
Drift: 32%
|
|
102
|
+
|
|
103
|
+
⚠ Significant architectural drift detected
|
|
104
|
+
|
|
105
|
+
Unimplemented:
|
|
106
|
+
- order-service (defined in SDM)
|
|
107
|
+
- payment-service (defined in SDM)
|
|
108
|
+
- STORY-005, STORY-008, STORY-011, STORY-012 (tests not generated)
|
|
109
|
+
|
|
110
|
+
Strategy Violations:
|
|
111
|
+
- user-service: Missing event boundaries (event-driven strategy)
|
|
112
|
+
|
|
113
|
+
Run for details:
|
|
114
|
+
dhurandhar audit --drift
|
|
115
|
+
|
|
116
|
+
Definition of Done:
|
|
117
|
+
EPIC-001 (Authentication): 80% (4/5 stories complete)
|
|
118
|
+
EPIC-002 (Orders): 57% (4/7 stories complete)
|
|
119
|
+
|
|
120
|
+
What's next?
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Silent Mode (drift < 25%)
|
|
124
|
+
|
|
125
|
+
If drift is acceptable, System Observer provides minimal context:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
[System Observer] Session Ready
|
|
129
|
+
|
|
130
|
+
5 services, 8 entities, 12 stories (all tested)
|
|
131
|
+
Strategy Compliance: 95%
|
|
132
|
+
Drift: 8%
|
|
133
|
+
|
|
134
|
+
Context loaded. What's next?
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Integration with AI IDEs
|
|
138
|
+
|
|
139
|
+
### For Cursor/Claude/Augment
|
|
140
|
+
|
|
141
|
+
1. **Place this file** (`.dhurandhar-session-start.md`) in project root
|
|
142
|
+
2. **Agent initialization**: Read this file + `SYSTEM_DESIGN_MAP.yaml`
|
|
143
|
+
3. **System Observer mode**: Perform audit automatically
|
|
144
|
+
4. **Report to user**: Show rehydration status
|
|
145
|
+
5. **Ready state**: Wait for user command
|
|
146
|
+
|
|
147
|
+
### Example AI Agent Prompt
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
You are working on a Dhurandhar-managed project.
|
|
151
|
+
|
|
152
|
+
FIRST: Assume System Observer persona
|
|
153
|
+
1. Read SYSTEM_DESIGN_MAP.yaml
|
|
154
|
+
2. Perform audit (check services, entities, stories exist in code)
|
|
155
|
+
3. Calculate drift percentage
|
|
156
|
+
4. Report rehydration status to user
|
|
157
|
+
|
|
158
|
+
THEN: Switch to appropriate persona based on user command:
|
|
159
|
+
- service/entity/strategy → Lead System Architect
|
|
160
|
+
- epic/story/test → Test Architect
|
|
161
|
+
- audit/context → System Observer
|
|
162
|
+
- edge-cases → Edge Case Hunter
|
|
163
|
+
|
|
164
|
+
Always start with System Observer rehydration.
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Rehydration Data Structure
|
|
168
|
+
|
|
169
|
+
The System Observer provides this context to other personas:
|
|
170
|
+
|
|
171
|
+
```javascript
|
|
172
|
+
{
|
|
173
|
+
project: {
|
|
174
|
+
name: "ecommerce-platform",
|
|
175
|
+
architecture: "microservices",
|
|
176
|
+
lastUpdated: "2024-01-15T10:30:00Z"
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
strategies: {
|
|
180
|
+
persistence: { model: "database_per_service" },
|
|
181
|
+
communication: {
|
|
182
|
+
primary_pattern: "asynchronous_events",
|
|
183
|
+
event_bus: { technology: "kafka" }
|
|
184
|
+
},
|
|
185
|
+
security: { authentication: "jwt_centralized" },
|
|
186
|
+
resilience: { circuit_breaker: true }
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
architecture: {
|
|
190
|
+
services: {
|
|
191
|
+
total: 5,
|
|
192
|
+
implemented: 5,
|
|
193
|
+
list: ["auth-service", "user-service", "order-service", "payment-service", "inventory-service"]
|
|
194
|
+
},
|
|
195
|
+
entities: {
|
|
196
|
+
total: 8,
|
|
197
|
+
implemented: 8,
|
|
198
|
+
list: ["User", "Session", "Order", "OrderItem", "Payment", "Product", "Inventory", "Review"]
|
|
199
|
+
},
|
|
200
|
+
stories: {
|
|
201
|
+
total: 12,
|
|
202
|
+
tested: 12,
|
|
203
|
+
coverage: 100
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
drift: {
|
|
208
|
+
percentage: 0,
|
|
209
|
+
unimplemented: [],
|
|
210
|
+
unmanaged: [],
|
|
211
|
+
violations: []
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
definitionOfDone: {
|
|
215
|
+
epics: [
|
|
216
|
+
{ id: "EPIC-001", name: "User Authentication", progress: 100, stories: "5/5" },
|
|
217
|
+
{ id: "EPIC-002", name: "Order Processing", progress: 100, stories: "7/7" }
|
|
218
|
+
]
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Commands After Rehydration
|
|
224
|
+
|
|
225
|
+
Once rehydrated, System Observer hands off to appropriate personas:
|
|
226
|
+
|
|
227
|
+
| User Command | Persona | Context Used |
|
|
228
|
+
|--------------|---------|--------------|
|
|
229
|
+
| "Add payment service" | Lead System Architect | Uses strategies, existing services |
|
|
230
|
+
| "Create login story" | Test Architect | Uses agile_blueprint, services |
|
|
231
|
+
| "Check drift" | System Observer | Uses audit data from rehydration |
|
|
232
|
+
| "Add edge cases for STORY-003" | Edge Case Hunter | Uses story definition, strategies |
|
|
233
|
+
|
|
234
|
+
## Remember
|
|
235
|
+
|
|
236
|
+
- **System Observer is ALWAYS first** on session start
|
|
237
|
+
- **Silent if drift < 25%** (brief summary only)
|
|
238
|
+
- **Alert if drift >= 25%** (show details, recommend audit)
|
|
239
|
+
- **Provide context to all personas** (strategies, architecture, drift)
|
|
240
|
+
- **Definition of Done** is immediately available (no recalculation needed)
|
|
241
|
+
|
|
242
|
+
This ensures every session starts with a truthful view of the system state.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Dhurandhar Project
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
# Dhurandhar
|
|
2
|
+
|
|
3
|
+
**Engineering-First + Test-First + Strategy-Driven + Decision-Stocked Framework** - Bmad-level maturity with zero cognitive fatigue
|
|
4
|
+
|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
[](https://nodejs.org)
|
|
7
|
+
|
|
8
|
+
## Philosophy
|
|
9
|
+
|
|
10
|
+
Dhurandhar eliminates **architectural drift** and **cognitive fatigue** through:
|
|
11
|
+
|
|
12
|
+
1. **Engineering-First**: Technical specifications over business justifications
|
|
13
|
+
2. **Test-First**: Contract tests before implementation
|
|
14
|
+
3. **Strategy-Driven**: Pluggable architectural patterns with global constraints
|
|
15
|
+
4. **Decision-Stocked** (NEW v2.5): Stock all technical decisions ONCE, apply everywhere automatically
|
|
16
|
+
5. **Drift Detection**: Automatic alignment between intent (SDM) and reality (code)
|
|
17
|
+
6. **Direct Action**: 3-question limit per component, no justification loops
|
|
18
|
+
7. **Persistent Context**: System Design Map (SDM) for cross-session rehydration
|
|
19
|
+
|
|
20
|
+
**Stock decisions once. Set strategies once. All services follow. Tests define contracts. SDM stays in sync. No ceremony.**
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
Dhurandhar integrates four powerful approaches:
|
|
25
|
+
|
|
26
|
+
### Drift Detection Layer (NEW v2.3)
|
|
27
|
+
- **System Observer**: Technical auditor persona (session gatekeeper)
|
|
28
|
+
- **Automatic Drift Detection**: Compare SDM (intent) vs code (reality)
|
|
29
|
+
- **Direct-Action Sync**: Update SDM to match codebase in seconds
|
|
30
|
+
- **Evidence-Based Reports**: Only report verifiable facts
|
|
31
|
+
- **Session Rehydration**: Instant context with drift assessment
|
|
32
|
+
|
|
33
|
+
### Pluggable Strategies Layer (v2.2)
|
|
34
|
+
- **Persistence Strategy**: Database-per-service, Shared DB, Event Sourcing
|
|
35
|
+
- **Communication Pattern**: Event-driven, REST, gRPC, Hybrid
|
|
36
|
+
- **State Management**: Distributed cache, Local cache, Sidecar
|
|
37
|
+
- **Security**: JWT centralized, OAuth2, mTLS, API keys
|
|
38
|
+
- **Resilience**: Circuit breaker, Retry policies, Timeouts
|
|
39
|
+
- **Global Injection**: Set once, apply to all services automatically
|
|
40
|
+
|
|
41
|
+
### Engineering-First Layer (v2.0)
|
|
42
|
+
- **User Types**: Roles, permissions, authentication boundaries
|
|
43
|
+
- **Entities & Relationships**: ERD-like database models
|
|
44
|
+
- **Service Architecture**: Microservices with strategy-enhanced tech stacks
|
|
45
|
+
- **Persistent State**: YAML-based architecture map
|
|
46
|
+
|
|
47
|
+
### Test-First Agile Layer (v2.1)
|
|
48
|
+
- **Epics**: High-level system capabilities
|
|
49
|
+
- **Stories**: User journeys with API contracts
|
|
50
|
+
- **Tasks**: Granular implementation steps with test coverage tracking
|
|
51
|
+
- **Contract Tests**: Generated before implementation, strategy-aware
|
|
52
|
+
|
|
53
|
+
## Key Features
|
|
54
|
+
|
|
55
|
+
- **Technical Decision Registry** (NEW v2.5): Bmad-inspired "stock of decisions"
|
|
56
|
+
- Stock naming conventions, design patterns, error standards, observability ONCE
|
|
57
|
+
- Auto-apply to ALL code (never re-litigate basic conventions)
|
|
58
|
+
- Eliminate 98% of repeated technical debates
|
|
59
|
+
- Enforced as immutable constraints by implementation personas
|
|
60
|
+
- **7-Persona Dhurandhar Council** (v2.4): Complete development lifecycle coverage
|
|
61
|
+
- **Audit Layer**: System Observer (drift detection, session gatekeeper)
|
|
62
|
+
- **Design Layer**: Lead System Architect (PRIMARY DECISION AUTHORITY)
|
|
63
|
+
- **Contract Layer**: Test Architect + Edge Case Hunter (tests, security)
|
|
64
|
+
- **Implementation Layer**: DevOps Engineer + Backend Developer + Frontend Developer
|
|
65
|
+
- **Implementation Personas** (v2.4): Tool-agnostic infrastructure, backend, and frontend specialists
|
|
66
|
+
- **Parallel Execution**: DevOps, Backend, Frontend work simultaneously from SDM
|
|
67
|
+
- **Architectural Drift Detection** (v2.3): Automatic alignment between SDM and codebase
|
|
68
|
+
- **Direct-Action Sync**: Update SDM to match code in seconds
|
|
69
|
+
- **Pluggable Architectural Strategies** (v2.2): Set global patterns (7 categories)
|
|
70
|
+
- **System Design Map (SDM)**: Persistent `SYSTEM_DESIGN_MAP.yaml` at project root
|
|
71
|
+
- **Strategy Auto-Injection**: Services inherit architectural constraints automatically
|
|
72
|
+
- **Contract-First Testing** (v2.1): Tests generated from API interaction boundaries
|
|
73
|
+
- **Context Rehydration**: AI agents reload decisions + strategies + drift + tests instantly
|
|
74
|
+
- **Direct-Action Pivots**: Change strategies without justification loops
|
|
75
|
+
- **Definition of Done**: Track test coverage and implementation status
|
|
76
|
+
- **Anti-Ceremony**: No business justifications, max 3 technical questions
|
|
77
|
+
|
|
78
|
+
## Installation
|
|
79
|
+
|
|
80
|
+
### Quick Install (NPX - Recommended)
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx dhurandhar install
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
**That's it!** No global installation needed.
|
|
87
|
+
|
|
88
|
+
### Alternative: Global Installation
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install -g dhurandhar
|
|
92
|
+
dhurandhar install
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
See [INSTALLATION.md](INSTALLATION.md) for more options (local dependency, from source, etc.)
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Quick Start (15 Minutes)
|
|
100
|
+
|
|
101
|
+
### Prerequisites
|
|
102
|
+
|
|
103
|
+
- Node.js v20.0.0 or higher
|
|
104
|
+
- npm >= 9.0.0
|
|
105
|
+
|
|
106
|
+
### 1. Install Framework
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Using npx (recommended)
|
|
110
|
+
npx dhurandhar install
|
|
111
|
+
|
|
112
|
+
# OR using global install
|
|
113
|
+
npm install -g dhurandhar
|
|
114
|
+
dhurandhar install
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**3 technical questions only**:
|
|
118
|
+
1. Project identifier (kebab-case)
|
|
119
|
+
2. Architecture type (microservices/monolith/serverless)
|
|
120
|
+
3. Primary language (Go/TypeScript/Python/Rust/Java)
|
|
121
|
+
|
|
122
|
+
### 2. Set Architectural Strategies (NEW - 5 minutes)
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Persistence: Database-per-Service
|
|
126
|
+
dhurandhar strategy --set persistence
|
|
127
|
+
|
|
128
|
+
# Communication: Event-Driven (Kafka)
|
|
129
|
+
dhurandhar strategy --set communication
|
|
130
|
+
|
|
131
|
+
# Security: JWT Centralized
|
|
132
|
+
dhurandhar strategy --set security
|
|
133
|
+
|
|
134
|
+
# Resilience: Circuit Breaker
|
|
135
|
+
dhurandhar strategy --set resilience
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
**Result**: All future services will automatically inherit these constraints.
|
|
139
|
+
|
|
140
|
+
### 3. Engineering-First: Define Architecture (Strategy Auto-Injection)
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
# Add service - strategies automatically applied!
|
|
144
|
+
dhurandhar service add "auth: JWT authentication"
|
|
145
|
+
|
|
146
|
+
# Result:
|
|
147
|
+
# ✓ auth-service added: Go/Echo/PostgreSQL
|
|
148
|
+
# - Dedicated database: auth_db (db-per-service strategy)
|
|
149
|
+
# - Events: produces[user.authenticated] (event-driven strategy)
|
|
150
|
+
# - Auth: Self (jwt-centralized strategy)
|
|
151
|
+
# - Resilience: Circuit breaker enabled
|
|
152
|
+
|
|
153
|
+
# Add entities
|
|
154
|
+
dhurandhar entity add User
|
|
155
|
+
dhurandhar entity add Session
|
|
156
|
+
|
|
157
|
+
# Relate entities
|
|
158
|
+
dhurandhar entity --relate # Session → User
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Note**: Service automatically got dedicated DB, event boundaries, and circuit breaker from strategies!
|
|
162
|
+
|
|
163
|
+
### 3. Test-First Agile: Define Requirements
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
# Add Epic (system capability)
|
|
167
|
+
dhurandhar epic add "User Authentication & Authorization"
|
|
168
|
+
|
|
169
|
+
# Add Story (user journey with API contract)
|
|
170
|
+
dhurandhar story add "Email/Password Login" --epic EPIC-001
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Test Architect asks 3 technical questions**:
|
|
174
|
+
1. Service? → auth-service
|
|
175
|
+
2. Endpoint? → /api/v1/auth/login
|
|
176
|
+
3. Method? → POST
|
|
177
|
+
|
|
178
|
+
### 4. Generate Contract Tests
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
dhurandhar test --generate
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Output**:
|
|
185
|
+
- `tests/contracts/story-001-standard.test.js` (happy path)
|
|
186
|
+
- `tests/contracts/story-001-errors.test.js` (error states)
|
|
187
|
+
- `tests/edge-cases/story-001-edge.test.js` (edge cases)
|
|
188
|
+
|
|
189
|
+
### 5. Run Tests (Before Implementation)
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npm install -D vitest
|
|
193
|
+
npm test
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Expected**: All tests fail (no implementation yet). This is correct!
|
|
197
|
+
|
|
198
|
+
### 6. Implement Services
|
|
199
|
+
|
|
200
|
+
Implement `auth-service` to pass the contract tests.
|
|
201
|
+
|
|
202
|
+
### 7. Run Tests (After Implementation)
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npm test
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Expected**: All tests pass ✅
|
|
209
|
+
|
|
210
|
+
### 8. Validate Coverage
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
dhurandhar test --validate
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
**Output**:
|
|
217
|
+
```
|
|
218
|
+
Coverage Report:
|
|
219
|
+
Total Stories: 1
|
|
220
|
+
Test Coverage: 100% (1/1)
|
|
221
|
+
Implementation: 100% (1/1)
|
|
222
|
+
|
|
223
|
+
✓ Full coverage!
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Complete Workflow
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# 1. Initialize
|
|
230
|
+
dhurandhar install
|
|
231
|
+
|
|
232
|
+
# 2. Define Architecture (Engineering-First)
|
|
233
|
+
dhurandhar service add "auth: JWT auth"
|
|
234
|
+
dhurandhar entity add User
|
|
235
|
+
|
|
236
|
+
# 3. Define Requirements (Test-First Agile)
|
|
237
|
+
dhurandhar epic add "User Authentication"
|
|
238
|
+
dhurandhar story add "Login" --epic EPIC-001
|
|
239
|
+
|
|
240
|
+
# 4. Generate Contract Tests
|
|
241
|
+
dhurandhar test --generate
|
|
242
|
+
|
|
243
|
+
# 5. Run tests → fail (expected)
|
|
244
|
+
npm test
|
|
245
|
+
|
|
246
|
+
# 6. Implement service to pass tests
|
|
247
|
+
# (Implementation guided by contract tests)
|
|
248
|
+
|
|
249
|
+
# 7. Run tests → pass
|
|
250
|
+
npm test
|
|
251
|
+
|
|
252
|
+
# 8. Validate
|
|
253
|
+
dhurandhar test --validate
|
|
254
|
+
|
|
255
|
+
# All state persists to SYSTEM_DESIGN_MAP.yaml
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## System Design Map (SDM)
|
|
259
|
+
|
|
260
|
+
The SDM is a YAML file at your project root: **`SYSTEM_DESIGN_MAP.yaml`**
|
|
261
|
+
|
|
262
|
+
### Purpose
|
|
263
|
+
|
|
264
|
+
- **Persistent Architecture State**: Survives across sessions
|
|
265
|
+
- **Context Rehydration**: AI agents/developers read this first
|
|
266
|
+
- **Single Source of Truth**: All architectural decisions in one place
|
|
267
|
+
- **No Rediscovery**: Never repeat context gathering
|
|
268
|
+
|
|
269
|
+
### Structure
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
metadata:
|
|
273
|
+
project_name: my-system
|
|
274
|
+
architecture_type: microservices
|
|
275
|
+
|
|
276
|
+
tech_stack:
|
|
277
|
+
languages: [Go, TypeScript]
|
|
278
|
+
frameworks: [Echo, React]
|
|
279
|
+
databases: [PostgreSQL, Redis]
|
|
280
|
+
|
|
281
|
+
user_types:
|
|
282
|
+
- role: admin
|
|
283
|
+
permissions: [read:*, write:*]
|
|
284
|
+
authentication: jwt
|
|
285
|
+
|
|
286
|
+
entities:
|
|
287
|
+
- name: User
|
|
288
|
+
attributes:
|
|
289
|
+
- name: id
|
|
290
|
+
type: uuid
|
|
291
|
+
constraints: [primary_key]
|
|
292
|
+
relationships:
|
|
293
|
+
- type: one_to_many
|
|
294
|
+
target: Post
|
|
295
|
+
|
|
296
|
+
services:
|
|
297
|
+
- name: auth-service
|
|
298
|
+
scope: "JWT authentication"
|
|
299
|
+
tech_stack:
|
|
300
|
+
language: Go
|
|
301
|
+
framework: Echo
|
|
302
|
+
database: PostgreSQL
|
|
303
|
+
api:
|
|
304
|
+
type: rest
|
|
305
|
+
base_path: /api/v1/auth
|
|
306
|
+
port: 8080
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Project Structure
|
|
310
|
+
|
|
311
|
+
```
|
|
312
|
+
your-project/
|
|
313
|
+
├── SYSTEM_DESIGN_MAP.yaml # ← THE MOST IMPORTANT FILE
|
|
314
|
+
├── .dhurandhar/
|
|
315
|
+
│ ├── config.yaml
|
|
316
|
+
│ └── modules/
|
|
317
|
+
├── src/ # Your code
|
|
318
|
+
└── ...
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Creating a Design Module
|
|
322
|
+
|
|
323
|
+
Create a new module by defining `module.yaml`:
|
|
324
|
+
|
|
325
|
+
```yaml
|
|
326
|
+
code: my-design
|
|
327
|
+
name: "My System Design"
|
|
328
|
+
version: "1.0.0"
|
|
329
|
+
description: "A custom system design"
|
|
330
|
+
|
|
331
|
+
dependencies:
|
|
332
|
+
- core
|
|
333
|
+
|
|
334
|
+
design_components:
|
|
335
|
+
- name: frontend
|
|
336
|
+
type: application
|
|
337
|
+
properties:
|
|
338
|
+
framework: React
|
|
339
|
+
|
|
340
|
+
- name: backend
|
|
341
|
+
type: service
|
|
342
|
+
properties:
|
|
343
|
+
framework: Node.js
|
|
344
|
+
|
|
345
|
+
relationships:
|
|
346
|
+
- from: frontend
|
|
347
|
+
to: backend
|
|
348
|
+
type: http_client
|
|
349
|
+
|
|
350
|
+
build_processes:
|
|
351
|
+
- name: setup
|
|
352
|
+
steps:
|
|
353
|
+
- Install dependencies
|
|
354
|
+
- Configure environment
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
## Documentation
|
|
358
|
+
|
|
359
|
+
- [Getting Started Guide](docs/getting-started.md)
|
|
360
|
+
- [Module Development](docs/module-development.md)
|
|
361
|
+
- [CLI Reference](docs/cli-reference.md)
|
|
362
|
+
- [Configuration Guide](docs/configuration.md)
|
|
363
|
+
- [API Documentation](docs/api.md)
|
|
364
|
+
|
|
365
|
+
## Development
|
|
366
|
+
|
|
367
|
+
### Running Tests
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
# Run unit tests
|
|
371
|
+
npm test
|
|
372
|
+
|
|
373
|
+
# Run integration tests
|
|
374
|
+
npm run test:integration
|
|
375
|
+
|
|
376
|
+
# Run all tests
|
|
377
|
+
npm run test:all
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Code Quality
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# Lint code
|
|
384
|
+
npm run lint
|
|
385
|
+
|
|
386
|
+
# Fix linting issues
|
|
387
|
+
npm run lint:fix
|
|
388
|
+
|
|
389
|
+
# Format code
|
|
390
|
+
npm run format:fix
|
|
391
|
+
|
|
392
|
+
# Check formatting
|
|
393
|
+
npm run format:check
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Validation
|
|
397
|
+
|
|
398
|
+
```bash
|
|
399
|
+
# Validate configuration
|
|
400
|
+
npm run validate:config
|
|
401
|
+
|
|
402
|
+
# Validate modules
|
|
403
|
+
npm run validate:modules
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
## Contributing
|
|
407
|
+
|
|
408
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
409
|
+
|
|
410
|
+
## License
|
|
411
|
+
|
|
412
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
413
|
+
|
|
414
|
+
## Credits
|
|
415
|
+
|
|
416
|
+
Inspired by best practices from Bmad-Method and modern system design frameworks.
|