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.
Files changed (54) hide show
  1. package/.dhurandhar-session-start.md +242 -0
  2. package/LICENSE +21 -0
  3. package/README.md +416 -0
  4. package/docs/ARCHITECTURE_V2.md +249 -0
  5. package/docs/DECISION_REGISTRY.md +357 -0
  6. package/docs/IMPLEMENTATION_PERSONAS.md +406 -0
  7. package/docs/PLUGGABLE_STRATEGIES.md +439 -0
  8. package/docs/SYSTEM_OBSERVER.md +433 -0
  9. package/docs/TEST_FIRST_AGILE.md +359 -0
  10. package/docs/architecture.md +279 -0
  11. package/docs/engineering-first-philosophy.md +263 -0
  12. package/docs/getting-started.md +218 -0
  13. package/docs/module-development.md +323 -0
  14. package/docs/strategy-example.md +299 -0
  15. package/docs/test-first-example.md +392 -0
  16. package/package.json +79 -0
  17. package/src/core/README.md +92 -0
  18. package/src/core/agent-instructions/backend-developer.md +412 -0
  19. package/src/core/agent-instructions/devops-engineer.md +372 -0
  20. package/src/core/agent-instructions/dhurandhar-council.md +547 -0
  21. package/src/core/agent-instructions/edge-case-hunter.md +322 -0
  22. package/src/core/agent-instructions/frontend-developer.md +494 -0
  23. package/src/core/agent-instructions/lead-system-architect.md +631 -0
  24. package/src/core/agent-instructions/system-observer.md +319 -0
  25. package/src/core/agent-instructions/test-architect.md +284 -0
  26. package/src/core/module.yaml +54 -0
  27. package/src/core/schemas/design-module-schema.yaml +995 -0
  28. package/src/core/schemas/system-design-map-schema.yaml +324 -0
  29. package/src/modules/example/README.md +130 -0
  30. package/src/modules/example/module.yaml +252 -0
  31. package/tools/cli/commands/audit.js +267 -0
  32. package/tools/cli/commands/config.js +113 -0
  33. package/tools/cli/commands/context.js +170 -0
  34. package/tools/cli/commands/decisions.js +398 -0
  35. package/tools/cli/commands/entity.js +218 -0
  36. package/tools/cli/commands/epic.js +125 -0
  37. package/tools/cli/commands/install.js +172 -0
  38. package/tools/cli/commands/module.js +109 -0
  39. package/tools/cli/commands/service.js +167 -0
  40. package/tools/cli/commands/story.js +225 -0
  41. package/tools/cli/commands/strategy.js +294 -0
  42. package/tools/cli/commands/test.js +277 -0
  43. package/tools/cli/commands/validate.js +107 -0
  44. package/tools/cli/dhurandhar.js +212 -0
  45. package/tools/lib/config-manager.js +170 -0
  46. package/tools/lib/filesystem.js +126 -0
  47. package/tools/lib/module-installer.js +61 -0
  48. package/tools/lib/module-manager.js +149 -0
  49. package/tools/lib/sdm-manager.js +982 -0
  50. package/tools/lib/test-engine.js +255 -0
  51. package/tools/lib/test-templates/api-client.template.js +100 -0
  52. package/tools/lib/test-templates/vitest.config.template.js +37 -0
  53. package/tools/lib/validators/config-validator.js +113 -0
  54. package/tools/lib/validators/module-validator.js +137 -0
@@ -0,0 +1,323 @@
1
+ # Module Development Guide
2
+
3
+ Learn how to create custom design modules for Dhurandhar.
4
+
5
+ ## Overview
6
+
7
+ Modules are the building blocks of Dhurandhar designs. Each module encapsulates:
8
+
9
+ - System components (applications, services, datastores)
10
+ - Relationships between components
11
+ - Build and deployment processes
12
+ - Configuration schemas
13
+ - Validation rules
14
+
15
+ ## Module Structure
16
+
17
+ A typical module directory structure:
18
+
19
+ ```
20
+ my-module/
21
+ ├── module.yaml # Module definition (required)
22
+ ├── README.md # Documentation (recommended)
23
+ ├── templates/ # Template files (optional)
24
+ ├── utilities/ # Helper scripts (optional)
25
+ └── schemas/ # Validation schemas (optional)
26
+ ```
27
+
28
+ ## Creating a Module
29
+
30
+ ### Step 1: Define module.yaml
31
+
32
+ Create `src/modules/my-module/module.yaml`:
33
+
34
+ ```yaml
35
+ code: my-module
36
+ name: "My Custom Module"
37
+ version: "1.0.0"
38
+ description: "A brief description of what this module does"
39
+
40
+ # Metadata
41
+ author: "Dhurandhar Contributors"
42
+ license: "MIT"
43
+ tags:
44
+ - custom
45
+ - example
46
+
47
+ # Dependencies (other modules this depends on)
48
+ dependencies:
49
+ - core
50
+
51
+ # Configuration schema
52
+ config_schema:
53
+ my_setting:
54
+ type: string
55
+ default: "default_value"
56
+ description: "Description of this setting"
57
+
58
+ # Design components
59
+ design_components:
60
+ - name: component-1
61
+ type: application
62
+ description: "First component"
63
+ properties:
64
+ framework: "React"
65
+
66
+ - name: component-2
67
+ type: service
68
+ description: "Second component"
69
+ properties:
70
+ framework: "Node.js"
71
+
72
+ # Relationships
73
+ relationships:
74
+ - from: component-1
75
+ to: component-2
76
+ type: http_client
77
+ description: "Component 1 calls Component 2"
78
+
79
+ # Build processes
80
+ build_processes:
81
+ - name: setup
82
+ description: "Initial setup"
83
+ steps:
84
+ - "Install dependencies"
85
+ - "Configure environment"
86
+
87
+ - name: development
88
+ description: "Development workflow"
89
+ steps:
90
+ - "Start services"
91
+ - "Run in dev mode"
92
+
93
+ # Exports
94
+ exports:
95
+ templates:
96
+ - my-template
97
+ utilities:
98
+ - my-utility
99
+ ```
100
+
101
+ ### Step 2: Add Documentation
102
+
103
+ Create `src/modules/my-module/README.md`:
104
+
105
+ ```markdown
106
+ # My Custom Module
107
+
108
+ Brief overview of the module.
109
+
110
+ ## Components
111
+
112
+ Describe each component.
113
+
114
+ ## Usage
115
+
116
+ How to use this module.
117
+
118
+ ## Configuration
119
+
120
+ Configuration options.
121
+
122
+ ## Dependencies
123
+
124
+ List dependencies.
125
+ ```
126
+
127
+ ### Step 3: Install the Module
128
+
129
+ ```bash
130
+ node tools/cli/dhurandhar.js module --add my-module
131
+ ```
132
+
133
+ ## Module Fields Reference
134
+
135
+ ### Required Fields
136
+
137
+ - **code**: Unique module identifier (lowercase, alphanumeric, hyphens)
138
+ - **name**: Human-readable module name
139
+ - **version**: Semantic version (e.g., "1.0.0")
140
+ - **description**: Brief description (10-500 characters)
141
+
142
+ ### Optional Fields
143
+
144
+ - **author**: Module author or organization
145
+ - **license**: License identifier (default: "MIT")
146
+ - **tags**: Array of tags for categorization
147
+ - **dependencies**: Array of required module codes
148
+ - **config_schema**: Configuration schema definition
149
+ - **design_components**: System components
150
+ - **relationships**: Component relationships
151
+ - **build_processes**: Build and deployment workflows
152
+ - **validation**: Validation rules
153
+ - **exports**: Exported templates, utilities, schemas
154
+
155
+ ## Component Types
156
+
157
+ Dhurandhar supports these component types:
158
+
159
+ - **application**: User-facing applications (web, mobile, desktop)
160
+ - **service**: Backend services (APIs, microservices)
161
+ - **datastore**: Databases and data storage
162
+ - **infrastructure**: Infrastructure components (load balancers, caches)
163
+ - **external**: External systems and third-party services
164
+
165
+ Example:
166
+
167
+ ```yaml
168
+ design_components:
169
+ - name: web-app
170
+ type: application
171
+ description: "Web application"
172
+ properties:
173
+ framework: "React"
174
+ language: "TypeScript"
175
+ ```
176
+
177
+ ## Relationships
178
+
179
+ Define how components interact:
180
+
181
+ ```yaml
182
+ relationships:
183
+ - from: component-source
184
+ to: component-target
185
+ type: relationship-type
186
+ description: "How they relate"
187
+ ```
188
+
189
+ Common relationship types:
190
+
191
+ - **http_client**: HTTP/REST API calls
192
+ - **data_access**: Database queries
193
+ - **messaging**: Message queue communication
194
+ - **event_stream**: Event streaming
195
+ - **file_storage**: File system access
196
+
197
+ ## Build Processes
198
+
199
+ Define workflows for different stages:
200
+
201
+ ```yaml
202
+ build_processes:
203
+ - name: setup
204
+ description: "One-time setup"
205
+ steps:
206
+ - "Clone repository"
207
+ - "Install dependencies"
208
+
209
+ - name: development
210
+ description: "Local development"
211
+ steps:
212
+ - "Start dev server"
213
+ - "Watch for changes"
214
+
215
+ - name: test
216
+ description: "Run tests"
217
+ steps:
218
+ - "Unit tests"
219
+ - "Integration tests"
220
+
221
+ - name: production
222
+ description: "Production deployment"
223
+ steps:
224
+ - "Build artifacts"
225
+ - "Deploy to production"
226
+ ```
227
+
228
+ ## Validation Rules
229
+
230
+ Enforce design constraints:
231
+
232
+ ```yaml
233
+ validation:
234
+ required_components:
235
+ - component-1
236
+ - component-2
237
+
238
+ allowed_relationships:
239
+ - type: http_client
240
+ from_types: [application]
241
+ to_types: [service]
242
+ ```
243
+
244
+ ## Best Practices
245
+
246
+ 1. **Clear Naming**: Use descriptive, consistent names
247
+ 2. **Complete Documentation**: Include README with usage examples
248
+ 3. **Version Properly**: Follow semantic versioning
249
+ 4. **Declare Dependencies**: List all module dependencies
250
+ 5. **Validate**: Test your module with strict validation
251
+ 6. **Minimal Exports**: Only export what's necessary
252
+
253
+ ## Testing Your Module
254
+
255
+ ```bash
256
+ # Install your module
257
+ node tools/cli/dhurandhar.js module --add my-module
258
+
259
+ # Validate
260
+ node tools/cli/dhurandhar.js validate --strict
261
+
262
+ # Check module info
263
+ node tools/cli/dhurandhar.js module --info my-module
264
+ ```
265
+
266
+ ## Advanced Features
267
+
268
+ ### Configuration Schema
269
+
270
+ Define typed configuration:
271
+
272
+ ```yaml
273
+ config_schema:
274
+ api_endpoint:
275
+ type: string
276
+ default: "http://localhost:8080"
277
+ description: "API endpoint URL"
278
+
279
+ max_connections:
280
+ type: number
281
+ default: 10
282
+ description: "Maximum connections"
283
+
284
+ enable_ssl:
285
+ type: boolean
286
+ default: true
287
+ description: "Enable SSL"
288
+ ```
289
+
290
+ ### Module Dependencies
291
+
292
+ Modules can depend on other modules:
293
+
294
+ ```yaml
295
+ dependencies:
296
+ - core
297
+ - common-utilities
298
+ ```
299
+
300
+ Dependencies are automatically installed.
301
+
302
+ ## Publishing Modules
303
+
304
+ To share your module:
305
+
306
+ 1. Ensure complete documentation
307
+ 2. Test thoroughly with validation
308
+ 3. Follow semantic versioning
309
+ 4. Include LICENSE file
310
+ 5. Add to module registry (when available)
311
+
312
+ ## Example Modules
313
+
314
+ Study these examples:
315
+
316
+ - **core**: Framework fundamentals
317
+ - **example**: Three-tier web app
318
+
319
+ ## Next Steps
320
+
321
+ - [Configuration Guide](configuration.md)
322
+ - [CLI Reference](cli-reference.md)
323
+ - [Schema Reference](../src/core/schemas/design-module-schema.yaml)
@@ -0,0 +1,299 @@
1
+ # Pluggable Strategies - Complete Example
2
+
3
+ ## Scenario: Building Event-Driven E-Commerce Platform
4
+
5
+ Let's build a complete e-commerce platform using pluggable strategies.
6
+
7
+ ## Step 1: Initialize Framework
8
+
9
+ ```bash
10
+ dhurandhar install
11
+
12
+ ? Project identifier: ecommerce-platform
13
+ ? Architecture type: microservices
14
+ ? Primary language: go
15
+
16
+ ✓ Framework installed
17
+ ```
18
+
19
+ ## Step 2: Set Architectural Strategies (5 Minutes)
20
+
21
+ ### Persistence Strategy: Database-per-Service
22
+
23
+ ```bash
24
+ dhurandhar strategy --set persistence
25
+
26
+ ? Persistence model:
27
+ ❯ Database-per-Service
28
+
29
+ ✓ persistence strategy set
30
+ ```
31
+
32
+ ### Communication Strategy: Event-Driven (Kafka)
33
+
34
+ ```bash
35
+ dhurandhar strategy --set communication
36
+
37
+ ? Primary communication pattern:
38
+ ❯ Asynchronous Events
39
+
40
+ ? Event bus technology:
41
+ ❯ Apache Kafka
42
+
43
+ ✓ communication strategy set
44
+ ```
45
+
46
+ ### State Management: Distributed Redis
47
+
48
+ ```bash
49
+ dhurandhar strategy --set state
50
+
51
+ ? Caching layer:
52
+ ❯ Distributed Redis
53
+
54
+ ✓ state strategy set
55
+ ```
56
+
57
+ ### Security: JWT Centralized
58
+
59
+ ```bash
60
+ dhurandhar strategy --set security
61
+
62
+ ? Authentication strategy:
63
+ ❯ JWT Centralized
64
+
65
+ ✓ security strategy set
66
+ ```
67
+
68
+ ### Resilience: Circuit Breaker Enabled
69
+
70
+ ```bash
71
+ dhurandhar strategy --set resilience
72
+
73
+ ? Enable circuit breaker pattern? Yes
74
+
75
+ ✓ resilience strategy set
76
+ ```
77
+
78
+ ## Step 3: View Active Strategies
79
+
80
+ ```bash
81
+ dhurandhar strategy --show
82
+
83
+ 📐 Active Architectural Strategies
84
+
85
+ Persistence Strategy:
86
+ Model: database_per_service
87
+ Constraints: no_cross_service_queries, eventual_consistency
88
+
89
+ Communication Pattern:
90
+ Primary: asynchronous_events
91
+ Event Bus: kafka
92
+
93
+ State Management:
94
+ Caching: distributed_redis
95
+ Sessions: redis_distributed
96
+
97
+ Security:
98
+ Authentication: jwt_centralized
99
+ Authorization: rbac
100
+
101
+ Resilience:
102
+ Circuit Breaker: enabled
103
+ Retry: exponential_backoff
104
+ Timeout: moderate_30s
105
+ ```
106
+
107
+ ## Step 4: Add Services (Strategy Auto-Injection)
108
+
109
+ ### Service 1: Auth Service
110
+
111
+ ```bash
112
+ dhurandhar service add "auth: JWT authentication and session management"
113
+
114
+ ✓ auth-service added: Go/Echo/PostgreSQL
115
+ - Dedicated database: auth_db (db-per-service strategy)
116
+ - Events: produces[user.authenticated], consumes[]
117
+ - Auth: Self (auth service)
118
+ - Resilience: Circuit breaker enabled
119
+ - Cache: Redis dependency added
120
+ ```
121
+
122
+ ### Service 2: User Service
123
+
124
+ ```bash
125
+ dhurandhar service add "user: User profile CRUD operations"
126
+
127
+ ✓ user-service added: Go/Echo/PostgreSQL
128
+ - Dedicated database: user_db (db-per-service strategy)
129
+ - Events: produces[user.created, user.updated], consumes[user.authenticated]
130
+ - Auth: JWT validation via auth-service
131
+ - Resilience: Circuit breaker enabled
132
+ - Cache: Redis dependency added
133
+ ```
134
+
135
+ ### Service 3: Order Service
136
+
137
+ ```bash
138
+ dhurandhar service add "order: Process customer orders"
139
+
140
+ ✓ order-service added: Go/Echo/PostgreSQL
141
+ - Dedicated database: order_db (db-per-service strategy)
142
+ - Events: produces[order.created, order.completed], consumes[payment.completed, inventory.reserved]
143
+ - Auth: JWT validation via auth-service
144
+ - Resilience: Circuit breaker enabled
145
+ - Cache: Redis dependency added
146
+ ```
147
+
148
+ ### Service 4: Payment Service
149
+
150
+ ```bash
151
+ dhurandhar service add "payment: Process payments via Stripe"
152
+
153
+ ✓ payment-service added: Go/Echo/PostgreSQL
154
+ - Dedicated database: payment_db (db-per-service strategy)
155
+ - Events: produces[payment.completed, payment.failed], consumes[order.created]
156
+ - Auth: JWT validation via auth-service
157
+ - Resilience: Circuit breaker enabled
158
+ - Cache: Redis dependency added
159
+ ```
160
+
161
+ ### Service 5: Inventory Service
162
+
163
+ ```bash
164
+ dhurandhar service add "inventory: Manage product stock"
165
+
166
+ ✓ inventory-service added: Go/Echo/PostgreSQL
167
+ - Dedicated database: inventory_db (db-per-service strategy)
168
+ - Events: produces[inventory.reserved, inventory.released], consumes[order.created]
169
+ - Auth: JWT validation via auth-service
170
+ - Resilience: Circuit breaker enabled
171
+ - Cache: Redis dependency added
172
+ ```
173
+
174
+ ## Step 5: View Complete Architecture
175
+
176
+ ```bash
177
+ dhurandhar context --full
178
+
179
+ 🏗️ System Architecture Context
180
+
181
+ Project Metadata
182
+ Name: ecommerce-platform
183
+ Architecture: microservices
184
+
185
+ Active Architectural Strategies
186
+ Persistence: database_per_service
187
+ Communication: asynchronous_events
188
+ Event Bus: kafka
189
+ Caching: distributed_redis
190
+ Auth: jwt_centralized
191
+ Resilience: Circuit Breaker enabled
192
+
193
+ Services (5)
194
+ auth-service
195
+ JWT authentication and session management
196
+ Stack: Go/Echo/PostgreSQL
197
+ Dedicated DB: auth_db
198
+ Events: produces[user.authenticated]
199
+
200
+ user-service
201
+ User profile CRUD operations
202
+ Stack: Go/Echo/PostgreSQL
203
+ Dedicated DB: user_db
204
+ Events: produces[user.created, user.updated] | consumes[user.authenticated]
205
+
206
+ order-service
207
+ Process customer orders
208
+ Stack: Go/Echo/PostgreSQL
209
+ Dedicated DB: order_db
210
+ Events: produces[order.created, order.completed] | consumes[payment.completed, inventory.reserved]
211
+
212
+ payment-service
213
+ Process payments via Stripe
214
+ Stack: Go/Echo/PostgreSQL
215
+ Dedicated DB: payment_db
216
+ Events: produces[payment.completed, payment.failed] | consumes[order.created]
217
+
218
+ inventory-service
219
+ Manage product stock
220
+ Stack: Go/Echo/PostgreSQL
221
+ Dedicated DB: inventory_db
222
+ Events: produces[inventory.reserved, inventory.released] | consumes[order.created]
223
+ ```
224
+
225
+ ## Step 6: Strategy Pivot Example
226
+
227
+ ### Scenario: Switch from Kafka to RabbitMQ
228
+
229
+ ```bash
230
+ dhurandhar strategy --pivot communication
231
+
232
+ ⚡ Pivot communication Strategy
233
+
234
+ Current strategy:
235
+ {
236
+ "primary_pattern": "asynchronous_events",
237
+ "event_bus": {
238
+ "technology": "kafka"
239
+ }
240
+ }
241
+
242
+ ? This will update all services. Continue? Yes
243
+
244
+ ? Event bus technology:
245
+ Apache Kafka
246
+ ❯ RabbitMQ
247
+ AWS SNS/SQS
248
+ Redis Streams
249
+
250
+ ✓ communication strategy set
251
+
252
+ Realigning 5 services...
253
+ ✓ All services updated to use RabbitMQ
254
+
255
+ Changes:
256
+ - auth-service: Event bus → RabbitMQ
257
+ - user-service: Event bus → RabbitMQ
258
+ - order-service: Event bus → RabbitMQ
259
+ - payment-service: Event bus → RabbitMQ
260
+ - inventory-service: Event bus → RabbitMQ
261
+ ```
262
+
263
+ **Result**: All 5 services updated in seconds. No manual edits needed.
264
+
265
+ ## Benefits Demonstrated
266
+
267
+ ### 1. Time Savings
268
+
269
+ **Without Strategies**:
270
+ - 5 services × 10 questions each = 50 questions
271
+ - Time: 30-60 minutes
272
+
273
+ **With Strategies**:
274
+ - 1 strategy setup (7 categories) = 5 minutes
275
+ - 5 services × 1 question each = 5 questions
276
+ - Time: 10 minutes total
277
+
278
+ **Savings**: 4-6x faster
279
+
280
+ ### 2. Consistency
281
+
282
+ All services follow the same patterns:
283
+ - Database-per-service (no cross-service queries)
284
+ - Event-driven communication (Kafka)
285
+ - JWT authentication (centralized)
286
+ - Circuit breaker enabled
287
+ - Redis caching
288
+
289
+ ### 3. Easy Pivots
290
+
291
+ Changed Kafka → RabbitMQ in seconds, all services updated.
292
+
293
+ ### 4. Zero Cognitive Fatigue
294
+
295
+ No repeated questions about database isolation, event bus, auth, etc.
296
+
297
+ ---
298
+
299
+ **Result**: Complete event-driven e-commerce platform with 5 microservices, defined in 15 minutes with full architectural consistency.