omgkit 2.1.0 → 2.2.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 (56) hide show
  1. package/package.json +1 -1
  2. package/plugin/skills/SKILL_STANDARDS.md +743 -0
  3. package/plugin/skills/databases/mongodb/SKILL.md +797 -28
  4. package/plugin/skills/databases/postgresql/SKILL.md +494 -18
  5. package/plugin/skills/databases/prisma/SKILL.md +776 -30
  6. package/plugin/skills/databases/redis/SKILL.md +885 -25
  7. package/plugin/skills/devops/aws/SKILL.md +686 -28
  8. package/plugin/skills/devops/docker/SKILL.md +466 -18
  9. package/plugin/skills/devops/github-actions/SKILL.md +684 -29
  10. package/plugin/skills/devops/kubernetes/SKILL.md +621 -24
  11. package/plugin/skills/frameworks/django/SKILL.md +920 -20
  12. package/plugin/skills/frameworks/express/SKILL.md +1361 -35
  13. package/plugin/skills/frameworks/fastapi/SKILL.md +1260 -33
  14. package/plugin/skills/frameworks/laravel/SKILL.md +1244 -31
  15. package/plugin/skills/frameworks/nestjs/SKILL.md +1005 -26
  16. package/plugin/skills/frameworks/nextjs/SKILL.md +407 -44
  17. package/plugin/skills/frameworks/rails/SKILL.md +594 -28
  18. package/plugin/skills/frameworks/react/SKILL.md +1006 -32
  19. package/plugin/skills/frameworks/spring/SKILL.md +528 -35
  20. package/plugin/skills/frameworks/vue/SKILL.md +1296 -27
  21. package/plugin/skills/frontend/accessibility/SKILL.md +1108 -34
  22. package/plugin/skills/frontend/frontend-design/SKILL.md +1304 -26
  23. package/plugin/skills/frontend/responsive/SKILL.md +847 -21
  24. package/plugin/skills/frontend/shadcn-ui/SKILL.md +976 -38
  25. package/plugin/skills/frontend/tailwindcss/SKILL.md +831 -35
  26. package/plugin/skills/frontend/threejs/SKILL.md +1298 -29
  27. package/plugin/skills/languages/javascript/SKILL.md +935 -31
  28. package/plugin/skills/languages/python/SKILL.md +489 -25
  29. package/plugin/skills/languages/typescript/SKILL.md +379 -30
  30. package/plugin/skills/methodology/brainstorming/SKILL.md +597 -23
  31. package/plugin/skills/methodology/defense-in-depth/SKILL.md +832 -34
  32. package/plugin/skills/methodology/dispatching-parallel-agents/SKILL.md +665 -31
  33. package/plugin/skills/methodology/executing-plans/SKILL.md +556 -24
  34. package/plugin/skills/methodology/finishing-development-branch/SKILL.md +595 -25
  35. package/plugin/skills/methodology/problem-solving/SKILL.md +429 -61
  36. package/plugin/skills/methodology/receiving-code-review/SKILL.md +536 -24
  37. package/plugin/skills/methodology/requesting-code-review/SKILL.md +632 -21
  38. package/plugin/skills/methodology/root-cause-tracing/SKILL.md +641 -30
  39. package/plugin/skills/methodology/sequential-thinking/SKILL.md +262 -3
  40. package/plugin/skills/methodology/systematic-debugging/SKILL.md +571 -32
  41. package/plugin/skills/methodology/test-driven-development/SKILL.md +779 -24
  42. package/plugin/skills/methodology/testing-anti-patterns/SKILL.md +691 -29
  43. package/plugin/skills/methodology/token-optimization/SKILL.md +598 -29
  44. package/plugin/skills/methodology/verification-before-completion/SKILL.md +543 -22
  45. package/plugin/skills/methodology/writing-plans/SKILL.md +590 -18
  46. package/plugin/skills/omega/omega-architecture/SKILL.md +838 -39
  47. package/plugin/skills/omega/omega-coding/SKILL.md +636 -39
  48. package/plugin/skills/omega/omega-sprint/SKILL.md +855 -48
  49. package/plugin/skills/omega/omega-testing/SKILL.md +940 -41
  50. package/plugin/skills/omega/omega-thinking/SKILL.md +703 -50
  51. package/plugin/skills/security/better-auth/SKILL.md +1065 -28
  52. package/plugin/skills/security/oauth/SKILL.md +968 -31
  53. package/plugin/skills/security/owasp/SKILL.md +894 -33
  54. package/plugin/skills/testing/playwright/SKILL.md +764 -38
  55. package/plugin/skills/testing/pytest/SKILL.md +873 -36
  56. package/plugin/skills/testing/vitest/SKILL.md +980 -35
@@ -1,59 +1,858 @@
1
1
  ---
2
2
  name: omega-architecture
3
- description: Omega system architecture. Use for designing scalable systems.
3
+ description: System architecture design with 7 Omega principles for scalable, resilient, and future-proof systems
4
+ category: omega
5
+ triggers:
6
+ - omega architecture
7
+ - system design
8
+ - scalable architecture
9
+ - distributed systems
10
+ - microservices design
11
+ - platform architecture
12
+ - infrastructure design
4
13
  ---
5
14
 
6
- # Omega Architecture Skill
15
+ # Omega Architecture
7
16
 
8
- ## 7 Omega Principles Applied
17
+ Design **scalable, resilient, and future-proof systems** following the 7 Omega Principles. This skill provides architectural patterns, decision frameworks, and production-ready blueprints for building systems that scale to millions of users.
9
18
 
10
- ### Ω1. Leverage Multiplication
11
- - Build systems, not features
12
- - Automate everything
13
- - Create multipliers
19
+ ## Purpose
14
20
 
15
- ### Ω2. Transcendent Abstraction
16
- - Solve the class, not instance
17
- - Find patterns behind patterns
18
- - Build frameworks
21
+ Build systems that transcend conventional architecture:
19
22
 
20
- ### Ω3. Agentic Decomposition
21
- - Specialist components
22
- - Clear interfaces
23
- - Autonomous operation
23
+ - Apply Omega principles to architectural decisions
24
+ - Design for 1000x scale from day one
25
+ - Create self-healing, autonomous systems
26
+ - Build platforms, not just applications
27
+ - Eliminate single points of failure
28
+ - Achieve zero-marginal-cost scaling
29
+ - Future-proof through abstraction layers
24
30
 
25
- ### Ω5. Zero-Marginal-Cost Scaling
26
- - No per-unit cost
27
- - Horizontal scaling
28
- - Platform thinking
31
+ ## Features
29
32
 
30
- ## Architecture Patterns
33
+ ### 1. The 7 Omega Principles in Architecture
31
34
 
32
- ### Event-Driven
35
+ ```markdown
36
+ ## Omega Architectural Principles
37
+
38
+ ┌─────────────────────────────────────────────────────────────────────────┐
39
+ │ 7 OMEGA ARCHITECTURE PRINCIPLES │
40
+ ├─────────────────────────────────────────────────────────────────────────┤
41
+ │ │
42
+ │ Ω1. LEVERAGE MULTIPLICATION │
43
+ │ → Build systems that amplify effort, not add to it │
44
+ │ → Every component should be a force multiplier │
45
+ │ │
46
+ │ Ω2. TRANSCENDENT ABSTRACTION │
47
+ │ → Solve classes of problems, not individual instances │
48
+ │ → Build frameworks that spawn solutions │
49
+ │ │
50
+ │ Ω3. AGENTIC DECOMPOSITION │
51
+ │ → Autonomous components with clear boundaries │
52
+ │ → Self-managing, self-healing subsystems │
53
+ │ │
54
+ │ Ω4. RECURSIVE IMPROVEMENT │
55
+ │ → Systems that optimize themselves over time │
56
+ │ → Feedback loops that compound improvements │
57
+ │ │
58
+ │ Ω5. ZERO-MARGINAL-COST SCALING │
59
+ │ → No additional cost per user/request at scale │
60
+ │ → Platform economics, not service economics │
61
+ │ │
62
+ │ Ω6. ANTIFRAGILE DESIGN │
63
+ │ → Systems that grow stronger under stress │
64
+ │ → Chaos becomes catalyst for improvement │
65
+ │ │
66
+ │ Ω7. COMPOSABLE PRIMITIVES │
67
+ │ → Lego-block components that combine infinitely │
68
+ │ → New capabilities emerge from composition │
69
+ │ │
70
+ └─────────────────────────────────────────────────────────────────────────┘
33
71
  ```
34
- [Producer] → [Event Bus] → [Consumer]
35
- [Consumer]
36
- → [Consumer]
72
+
73
+ ### 2. Ω1 Leverage Multiplication Architecture
74
+
75
+ ```typescript
76
+ /**
77
+ * Leverage Multiplication: Build systems, not features
78
+ * Every architectural decision should multiply capability
79
+ */
80
+
81
+ // ❌ Linear Architecture (effort grows with features)
82
+ class LinearApproach {
83
+ createUser() { /* specific implementation */ }
84
+ createProduct() { /* specific implementation */ }
85
+ createOrder() { /* specific implementation */ }
86
+ // Each new entity = new implementation = linear growth
87
+ }
88
+
89
+ // ✅ Leverage Architecture (effort stays constant)
90
+ interface Entity {
91
+ id: string;
92
+ type: string;
93
+ data: Record<string, unknown>;
94
+ metadata: EntityMetadata;
95
+ }
96
+
97
+ interface EntityMetadata {
98
+ createdAt: Date;
99
+ updatedAt: Date;
100
+ version: number;
101
+ audit: AuditTrail[];
102
+ }
103
+
104
+ class LeveragedEntitySystem {
105
+ private validators: Map<string, Validator>;
106
+ private hooks: Map<string, Hook[]>;
107
+ private storage: UnifiedStorage;
108
+
109
+ async create<T extends Entity>(type: string, data: T): Promise<T> {
110
+ // One implementation handles ALL entity types
111
+ const validated = await this.validators.get(type)?.validate(data);
112
+ await this.runHooks(type, 'beforeCreate', validated);
113
+ const result = await this.storage.create(type, validated);
114
+ await this.runHooks(type, 'afterCreate', result);
115
+ return result as T;
116
+ }
117
+
118
+ // Adding new entity type = configuration, not code
119
+ registerEntityType(type: string, config: EntityConfig): void {
120
+ this.validators.set(type, createValidator(config.schema));
121
+ this.hooks.set(type, config.hooks);
122
+ }
123
+ }
124
+
125
+ // Now ANY new entity is just configuration:
126
+ entitySystem.registerEntityType('user', {
127
+ schema: userSchema,
128
+ hooks: [auditHook, notificationHook]
129
+ });
130
+
131
+ entitySystem.registerEntityType('product', {
132
+ schema: productSchema,
133
+ hooks: [inventoryHook, searchIndexHook]
134
+ });
135
+ ```
136
+
137
+ ### 3. Ω3 Agentic Decomposition Pattern
138
+
139
+ ```typescript
140
+ /**
141
+ * Agentic Decomposition: Autonomous, self-managing services
142
+ * Each service operates independently with clear contracts
143
+ */
144
+
145
+ // Service Contract Definition
146
+ interface ServiceContract {
147
+ name: string;
148
+ version: string;
149
+ capabilities: string[];
150
+ dependencies: ServiceDependency[];
151
+ healthCheck: () => Promise<HealthStatus>;
152
+ metrics: () => MetricsSnapshot;
153
+ }
154
+
155
+ // Self-Healing Service Base
156
+ abstract class AgenticService implements ServiceContract {
157
+ abstract name: string;
158
+ abstract version: string;
159
+ abstract capabilities: string[];
160
+ dependencies: ServiceDependency[] = [];
161
+
162
+ private circuitBreaker: CircuitBreaker;
163
+ private healthMonitor: HealthMonitor;
164
+ private autoScaler: AutoScaler;
165
+
166
+ constructor() {
167
+ // Self-monitoring
168
+ this.healthMonitor = new HealthMonitor({
169
+ checkInterval: 5000,
170
+ onUnhealthy: () => this.selfHeal()
171
+ });
172
+
173
+ // Self-protecting
174
+ this.circuitBreaker = new CircuitBreaker({
175
+ failureThreshold: 5,
176
+ resetTimeout: 30000,
177
+ onOpen: () => this.notifyDegradation()
178
+ });
179
+
180
+ // Self-scaling
181
+ this.autoScaler = new AutoScaler({
182
+ minInstances: 2,
183
+ maxInstances: 100,
184
+ targetCPU: 70,
185
+ targetMemory: 80
186
+ });
187
+ }
188
+
189
+ protected async executeWithResilience<T>(
190
+ operation: () => Promise<T>,
191
+ fallback?: () => T
192
+ ): Promise<T> {
193
+ return this.circuitBreaker.execute(operation, fallback);
194
+ }
195
+
196
+ private async selfHeal(): Promise<void> {
197
+ console.log(`[${this.name}] Self-healing initiated`);
198
+ await this.clearCaches();
199
+ await this.reconnectDependencies();
200
+ await this.reloadConfiguration();
201
+ }
202
+
203
+ async healthCheck(): Promise<HealthStatus> {
204
+ const dependencyHealth = await Promise.all(
205
+ this.dependencies.map(dep => dep.checkHealth())
206
+ );
207
+
208
+ return {
209
+ service: this.name,
210
+ status: dependencyHealth.every(h => h.healthy) ? 'healthy' : 'degraded',
211
+ dependencies: dependencyHealth,
212
+ metrics: this.metrics()
213
+ };
214
+ }
215
+
216
+ abstract metrics(): MetricsSnapshot;
217
+ protected abstract clearCaches(): Promise<void>;
218
+ protected abstract reconnectDependencies(): Promise<void>;
219
+ protected abstract reloadConfiguration(): Promise<void>;
220
+ }
221
+
222
+ // Example: Autonomous Order Service
223
+ class OrderService extends AgenticService {
224
+ name = 'order-service';
225
+ version = '2.1.0';
226
+ capabilities = ['create-order', 'process-payment', 'track-fulfillment'];
227
+
228
+ async createOrder(request: CreateOrderRequest): Promise<Order> {
229
+ return this.executeWithResilience(
230
+ async () => {
231
+ const validated = await this.validateOrder(request);
232
+ const order = await this.persistOrder(validated);
233
+ await this.emitEvent('order.created', order);
234
+ return order;
235
+ },
236
+ () => this.queueForRetry(request) // Fallback: queue for later
237
+ );
238
+ }
239
+ }
240
+ ```
241
+
242
+ ### 4. Ω5 Zero-Marginal-Cost Architecture
243
+
244
+ ```typescript
245
+ /**
246
+ * Zero-Marginal-Cost Scaling: Platform architecture
247
+ * Cost per user/request approaches zero at scale
248
+ */
249
+
250
+ // Platform Architecture Blueprint
251
+ interface PlatformArchitecture {
252
+ // Compute: Serverless (pay per execution, not capacity)
253
+ compute: ServerlessConfig;
254
+
255
+ // Storage: Object storage with CDN (infinite scale, usage-based)
256
+ storage: EdgeStorageConfig;
257
+
258
+ // Data: Distributed with automatic sharding
259
+ database: DistributedDBConfig;
260
+
261
+ // Caching: Edge caching eliminates repeated computation
262
+ cache: EdgeCacheConfig;
263
+ }
264
+
265
+ const platformConfig: PlatformArchitecture = {
266
+ compute: {
267
+ provider: 'cloudflare-workers',
268
+ // Runs at the edge - 0ms cold start
269
+ // Pay per request, not per hour
270
+ pricing: 'per-invocation',
271
+ limits: {
272
+ cpuTime: '50ms',
273
+ memory: '128MB'
274
+ }
275
+ },
276
+
277
+ storage: {
278
+ provider: 'r2', // S3-compatible, zero egress fees
279
+ cdn: {
280
+ enabled: true,
281
+ ttl: '1y', // Immutable assets cached forever
282
+ purgeOnDeploy: true
283
+ }
284
+ },
285
+
286
+ database: {
287
+ provider: 'planetscale', // MySQL-compatible, auto-sharding
288
+ // Or: cockroachdb, vitess, yugabyte
289
+ sharding: 'automatic',
290
+ replicas: {
291
+ read: 'multi-region',
292
+ write: 'primary-with-failover'
293
+ }
294
+ },
295
+
296
+ cache: {
297
+ layers: [
298
+ { type: 'browser', ttl: '1h' },
299
+ { type: 'cdn-edge', ttl: '24h' },
300
+ { type: 'regional', ttl: '1h' },
301
+ { type: 'origin', ttl: '5m' }
302
+ ]
303
+ }
304
+ };
305
+
306
+ // Implementation: Compute moves to data, not vice versa
307
+ class ZeroMarginalCostAPI {
308
+ // Edge function - runs in 300+ locations worldwide
309
+ async handleRequest(request: Request): Promise<Response> {
310
+ const cacheKey = this.generateCacheKey(request);
311
+
312
+ // Layer 1: Edge cache (0 compute cost)
313
+ const cached = await this.edgeCache.get(cacheKey);
314
+ if (cached) return cached;
315
+
316
+ // Layer 2: Regional compute (minimal latency)
317
+ const result = await this.processAtEdge(request);
318
+
319
+ // Cache for future requests (amortize cost)
320
+ await this.edgeCache.set(cacheKey, result, { ttl: 3600 });
321
+
322
+ return result;
323
+ }
324
+
325
+ private async processAtEdge(request: Request): Promise<Response> {
326
+ // Use read replicas closest to user
327
+ const db = this.getRegionalReplica(request.cf?.colo);
328
+
329
+ // Streaming response - start sending immediately
330
+ const stream = new TransformStream();
331
+ const writer = stream.writable.getWriter();
332
+
333
+ // Process in chunks - constant memory usage
334
+ this.streamResults(db, writer);
335
+
336
+ return new Response(stream.readable);
337
+ }
338
+ }
339
+ ```
340
+
341
+ ### 5. Event-Driven Architecture Pattern
342
+
343
+ ```typescript
344
+ /**
345
+ * Event-Driven: Loose coupling, infinite scalability
346
+ * Services communicate through events, not direct calls
347
+ */
348
+
349
+ // Event Schema with Versioning
350
+ interface DomainEvent<T = unknown> {
351
+ id: string;
352
+ type: string;
353
+ version: number;
354
+ timestamp: Date;
355
+ source: string;
356
+ correlationId: string;
357
+ causationId?: string;
358
+ data: T;
359
+ metadata: EventMetadata;
360
+ }
361
+
362
+ // Event Bus Implementation
363
+ class EventBus {
364
+ private handlers: Map<string, EventHandler[]> = new Map();
365
+ private deadLetterQueue: DeadLetterQueue;
366
+ private eventStore: EventStore;
367
+
368
+ async publish<T>(event: DomainEvent<T>): Promise<void> {
369
+ // 1. Persist event (event sourcing)
370
+ await this.eventStore.append(event);
371
+
372
+ // 2. Dispatch to handlers
373
+ const handlers = this.handlers.get(event.type) || [];
374
+
375
+ await Promise.allSettled(
376
+ handlers.map(handler =>
377
+ this.executeHandler(handler, event)
378
+ )
379
+ );
380
+ }
381
+
382
+ private async executeHandler(
383
+ handler: EventHandler,
384
+ event: DomainEvent
385
+ ): Promise<void> {
386
+ const maxRetries = 3;
387
+ let attempt = 0;
388
+
389
+ while (attempt < maxRetries) {
390
+ try {
391
+ await handler.handle(event);
392
+ return;
393
+ } catch (error) {
394
+ attempt++;
395
+ if (attempt >= maxRetries) {
396
+ await this.deadLetterQueue.add(event, error);
397
+ }
398
+ await this.delay(Math.pow(2, attempt) * 1000);
399
+ }
400
+ }
401
+ }
402
+
403
+ subscribe(eventType: string, handler: EventHandler): Unsubscribe {
404
+ const handlers = this.handlers.get(eventType) || [];
405
+ handlers.push(handler);
406
+ this.handlers.set(eventType, handlers);
407
+
408
+ return () => {
409
+ const index = handlers.indexOf(handler);
410
+ if (index > -1) handlers.splice(index, 1);
411
+ };
412
+ }
413
+ }
414
+
415
+ // Saga Pattern for Distributed Transactions
416
+ class OrderSaga {
417
+ private eventBus: EventBus;
418
+
419
+ constructor(eventBus: EventBus) {
420
+ this.eventBus = eventBus;
421
+
422
+ // React to events
423
+ eventBus.subscribe('order.created', this.handleOrderCreated);
424
+ eventBus.subscribe('payment.completed', this.handlePaymentCompleted);
425
+ eventBus.subscribe('payment.failed', this.handlePaymentFailed);
426
+ eventBus.subscribe('inventory.reserved', this.handleInventoryReserved);
427
+ }
428
+
429
+ handleOrderCreated = async (event: DomainEvent<Order>): Promise<void> => {
430
+ // Start saga - reserve inventory
431
+ await this.eventBus.publish({
432
+ type: 'inventory.reserve',
433
+ data: {
434
+ orderId: event.data.id,
435
+ items: event.data.items
436
+ },
437
+ correlationId: event.correlationId,
438
+ causationId: event.id
439
+ });
440
+ };
441
+
442
+ handlePaymentFailed = async (event: DomainEvent): Promise<void> => {
443
+ // Compensating action - release inventory
444
+ await this.eventBus.publish({
445
+ type: 'inventory.release',
446
+ data: { orderId: event.data.orderId },
447
+ correlationId: event.correlationId,
448
+ causationId: event.id
449
+ });
450
+
451
+ // Update order status
452
+ await this.eventBus.publish({
453
+ type: 'order.cancelled',
454
+ data: {
455
+ orderId: event.data.orderId,
456
+ reason: 'payment_failed'
457
+ },
458
+ correlationId: event.correlationId,
459
+ causationId: event.id
460
+ });
461
+ };
462
+ }
37
463
  ```
38
464
 
39
- ### Microservices
465
+ ### 6. Antifragile System Design
466
+
467
+ ```typescript
468
+ /**
469
+ * Ω6 Antifragile: Systems that grow stronger under stress
470
+ * Embrace failure as a catalyst for improvement
471
+ */
472
+
473
+ // Chaos Engineering Integration
474
+ class AntifragileSystem {
475
+ private chaosEngine: ChaosEngine;
476
+ private adaptiveConfig: AdaptiveConfiguration;
477
+ private learningSystem: LearningSystem;
478
+
479
+ constructor() {
480
+ this.chaosEngine = new ChaosEngine({
481
+ // Inject controlled failures
482
+ experiments: [
483
+ { type: 'latency', probability: 0.01, maxDelay: 500 },
484
+ { type: 'failure', probability: 0.001, services: ['non-critical'] },
485
+ { type: 'resource-pressure', probability: 0.01 }
486
+ ],
487
+ // Automatically disable during incidents
488
+ safetyLimits: {
489
+ errorRate: 0.05,
490
+ p99Latency: 1000
491
+ }
492
+ });
493
+
494
+ this.learningSystem = new LearningSystem();
495
+ }
496
+
497
+ // Adaptive Circuit Breaker - learns optimal thresholds
498
+ private createAdaptiveBreaker(serviceName: string): CircuitBreaker {
499
+ return new AdaptiveCircuitBreaker({
500
+ serviceName,
501
+ // Initial conservative settings
502
+ initialThreshold: 5,
503
+ initialTimeout: 30000,
504
+ // Learn from traffic patterns
505
+ adaptationRate: 0.1,
506
+ onStateChange: (from, to, metrics) => {
507
+ this.learningSystem.recordTransition(serviceName, from, to, metrics);
508
+ }
509
+ });
510
+ }
511
+
512
+ // Automatic fallback escalation
513
+ async executeWithEscalation<T>(
514
+ primary: () => Promise<T>,
515
+ fallbacks: Array<() => Promise<T>>,
516
+ options: ExecutionOptions
517
+ ): Promise<T> {
518
+ // Try primary
519
+ try {
520
+ return await this.withTimeout(primary(), options.timeout);
521
+ } catch (primaryError) {
522
+ // Learn from failure
523
+ this.learningSystem.recordFailure('primary', primaryError);
524
+ }
525
+
526
+ // Escalate through fallbacks
527
+ for (let i = 0; i < fallbacks.length; i++) {
528
+ try {
529
+ const result = await this.withTimeout(
530
+ fallbacks[i](),
531
+ options.timeout * (i + 2) // Progressively longer timeouts
532
+ );
533
+ // Record successful fallback
534
+ this.learningSystem.recordFallbackSuccess(i);
535
+ return result;
536
+ } catch (error) {
537
+ this.learningSystem.recordFailure(`fallback-${i}`, error);
538
+ }
539
+ }
540
+
541
+ throw new AllFallbacksExhaustedError();
542
+ }
543
+
544
+ // Self-improving configuration
545
+ async adaptConfiguration(): Promise<void> {
546
+ const insights = await this.learningSystem.getInsights();
547
+
548
+ for (const insight of insights) {
549
+ switch (insight.type) {
550
+ case 'timeout-too-short':
551
+ await this.adaptiveConfig.increase(insight.key, 1.5);
552
+ break;
553
+ case 'retry-ineffective':
554
+ await this.adaptiveConfig.decrease(`${insight.service}.retries`, 0.5);
555
+ break;
556
+ case 'cache-miss-pattern':
557
+ await this.adaptiveConfig.set(
558
+ `${insight.key}.preload`,
559
+ insight.suggestedKeys
560
+ );
561
+ break;
562
+ }
563
+ }
564
+ }
565
+ }
566
+
567
+ // Bulkhead Pattern - Isolate failures
568
+ class BulkheadExecutor {
569
+ private pools: Map<string, ResourcePool>;
570
+
571
+ constructor(config: BulkheadConfig) {
572
+ // Separate pools for different concerns
573
+ this.pools = new Map([
574
+ ['critical', new ResourcePool({ size: 20, queue: 100 })],
575
+ ['standard', new ResourcePool({ size: 10, queue: 50 })],
576
+ ['background', new ResourcePool({ size: 5, queue: 1000 })]
577
+ ]);
578
+ }
579
+
580
+ async execute<T>(
581
+ priority: 'critical' | 'standard' | 'background',
582
+ task: () => Promise<T>
583
+ ): Promise<T> {
584
+ const pool = this.pools.get(priority)!;
585
+
586
+ // Critical operations never affected by standard/background load
587
+ return pool.acquire(async (resource) => {
588
+ return task();
589
+ });
590
+ }
591
+ }
40
592
  ```
41
- [API Gateway]
42
-
43
- ┌────┼────┐
44
- ▼ ▼ ▼
45
- [A] [B] [C]
593
+
594
+ ### 7. Architecture Decision Framework
595
+
596
+ ```markdown
597
+ ## Omega Architecture Decision Template
598
+
599
+ ### Context
600
+ What problem are we solving?
601
+ What constraints exist?
602
+
603
+ ### Omega Principles Check
604
+ For EVERY architecture decision, verify:
605
+
606
+ | Principle | Question | Assessment |
607
+ |-----------|----------|------------|
608
+ | Ω1 Leverage | Does this multiply our capability? | |
609
+ | Ω2 Abstraction | Are we solving a class of problems? | |
610
+ | Ω3 Agentic | Can this operate autonomously? | |
611
+ | Ω4 Recursive | Will this improve itself over time? | |
612
+ | Ω5 Zero-Marginal | Does cost scale sub-linearly? | |
613
+ | Ω6 Antifragile | Does it grow stronger under stress? | |
614
+ | Ω7 Composable | Can it combine with other components? | |
615
+
616
+ ### Scale Questions
617
+ 1. What happens at 10x current load?
618
+ 2. What happens at 100x?
619
+ 3. What happens at 1000x?
620
+ 4. What's the cost curve at each level?
621
+
622
+ ### Failure Analysis
623
+ 1. What's the blast radius of failure?
624
+ 2. How do we detect it?
625
+ 3. How do we recover?
626
+ 4. How do we prevent recurrence?
627
+
628
+ ### Decision
629
+ [The chosen approach]
630
+
631
+ ### Consequences
632
+ - Benefits:
633
+ - Risks:
634
+ - Technical debt incurred:
46
635
  ```
47
636
 
48
- ### Serverless
637
+ ## Use Cases
638
+
639
+ ### E-commerce Platform Architecture
640
+
641
+ ```typescript
642
+ /**
643
+ * Complete e-commerce platform following Omega principles
644
+ */
645
+
646
+ // Domain Events
647
+ type EcommerceEvent =
648
+ | { type: 'product.created'; data: Product }
649
+ | { type: 'cart.updated'; data: Cart }
650
+ | { type: 'order.placed'; data: Order }
651
+ | { type: 'payment.processed'; data: Payment }
652
+ | { type: 'inventory.updated'; data: InventoryChange }
653
+ | { type: 'shipment.dispatched'; data: Shipment };
654
+
655
+ // Service Boundaries (Agentic Decomposition)
656
+ const serviceArchitecture = {
657
+ // Each service is autonomous with clear boundaries
658
+ catalog: {
659
+ responsibilities: ['product-management', 'search', 'recommendations'],
660
+ data: ['products', 'categories', 'reviews'],
661
+ events: ['product.*'],
662
+ scaling: 'read-heavy, edge-cached'
663
+ },
664
+
665
+ cart: {
666
+ responsibilities: ['cart-management', 'pricing', 'promotions'],
667
+ data: ['carts', 'promotions'],
668
+ events: ['cart.*'],
669
+ scaling: 'session-based, regional'
670
+ },
671
+
672
+ order: {
673
+ responsibilities: ['order-processing', 'fulfillment-coordination'],
674
+ data: ['orders', 'order-items'],
675
+ events: ['order.*'],
676
+ scaling: 'write-heavy, strongly-consistent'
677
+ },
678
+
679
+ payment: {
680
+ responsibilities: ['payment-processing', 'refunds', 'fraud-detection'],
681
+ data: ['transactions', 'payment-methods'],
682
+ events: ['payment.*'],
683
+ scaling: 'PCI-compliant, isolated'
684
+ },
685
+
686
+ inventory: {
687
+ responsibilities: ['stock-management', 'reservations', 'alerts'],
688
+ data: ['inventory', 'warehouses'],
689
+ events: ['inventory.*'],
690
+ scaling: 'real-time, multi-region sync'
691
+ },
692
+
693
+ shipping: {
694
+ responsibilities: ['carrier-integration', 'tracking', 'returns'],
695
+ data: ['shipments', 'carriers'],
696
+ events: ['shipment.*'],
697
+ scaling: 'async, event-driven'
698
+ }
699
+ };
700
+
701
+ // Infrastructure Blueprint
702
+ const infrastructureConfig = `
703
+ # Kubernetes Architecture
704
+
705
+ ┌─────────────────────────────────────────────────────────────────┐
706
+ │ EDGE LAYER │
707
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
708
+ │ │ CDN │ │ CDN │ │ CDN │ │ CDN │ │
709
+ │ │ US-EAST │ │ EU-WEST │ │ AP-SOUTH│ │ AP-NORTH│ │
710
+ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
711
+ └───────┼────────────┼────────────┼────────────┼──────────────────┘
712
+ │ │ │ │
713
+ ┌───────┴────────────┴────────────┴────────────┴──────────────────┐
714
+ │ API GATEWAY (Global) │
715
+ │ ┌──────────────────────────────────────────────────────────┐ │
716
+ │ │ Rate Limiting │ Auth │ Routing │ Load Balancing │ │
717
+ │ └──────────────────────────────────────────────────────────┘ │
718
+ └─────────────────────────────┬───────────────────────────────────┘
719
+
720
+ ┌─────────────────────────────┴───────────────────────────────────┐
721
+ │ SERVICE MESH (Istio) │
722
+ │ │
723
+ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
724
+ │ │ Catalog │ │ Cart │ │ Order │ │ Payment │ │Inventory│ │
725
+ │ │ Service │ │ Service │ │ Service │ │ Service │ │ Service │ │
726
+ │ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
727
+ │ │ │ │ │ │ │
728
+ └───────┼──────────┼──────────┼──────────┼──────────┼────────────┘
729
+ │ │ │ │ │
730
+ ┌───────┴──────────┴──────────┴──────────┴──────────┴────────────┐
731
+ │ EVENT BUS (Kafka) │
732
+ │ ┌──────────────────────────────────────────────────────────┐ │
733
+ │ │ Topics: products│carts│orders│payments│inventory│shipments│ │
734
+ │ └──────────────────────────────────────────────────────────┘ │
735
+ └─────────────────────────────────────────────────────────────────┘
736
+ `;
49
737
  ```
50
- [Request] → [Function] → [Database]
51
- [Queue]
52
- → [Storage]
738
+
739
+ ### SaaS Multi-Tenant Architecture
740
+
741
+ ```typescript
742
+ /**
743
+ * Multi-tenant SaaS following Zero-Marginal-Cost principles
744
+ */
745
+
746
+ // Tenant Isolation Strategies
747
+ type IsolationStrategy =
748
+ | 'shared-database' // Cost-efficient, row-level isolation
749
+ | 'schema-per-tenant' // Balance of isolation and cost
750
+ | 'database-per-tenant'; // Maximum isolation, higher cost
751
+
752
+ interface TenantConfig {
753
+ id: string;
754
+ tier: 'free' | 'pro' | 'enterprise';
755
+ isolation: IsolationStrategy;
756
+ customDomain?: string;
757
+ dataRegion: string;
758
+ }
759
+
760
+ class MultiTenantArchitecture {
761
+ // Tenant-aware query builder
762
+ createQueryContext(tenantId: string): QueryContext {
763
+ return {
764
+ // Automatic tenant filtering on all queries
765
+ defaultFilters: { tenant_id: tenantId },
766
+ // Connection pooling by tenant tier
767
+ pool: this.getPoolForTenant(tenantId),
768
+ // Read replica routing
769
+ readPreference: this.getReadPreference(tenantId)
770
+ };
771
+ }
772
+
773
+ // Dynamic resource allocation by tier
774
+ private getResourceLimits(tier: string): ResourceLimits {
775
+ const limits: Record<string, ResourceLimits> = {
776
+ free: {
777
+ requestsPerMinute: 60,
778
+ storageGB: 1,
779
+ computeUnits: 10,
780
+ features: ['core']
781
+ },
782
+ pro: {
783
+ requestsPerMinute: 600,
784
+ storageGB: 50,
785
+ computeUnits: 100,
786
+ features: ['core', 'advanced', 'integrations']
787
+ },
788
+ enterprise: {
789
+ requestsPerMinute: 6000,
790
+ storageGB: 500,
791
+ computeUnits: 1000,
792
+ features: ['core', 'advanced', 'integrations', 'sso', 'audit']
793
+ }
794
+ };
795
+ return limits[tier];
796
+ }
797
+ }
798
+
799
+ // Feature Flag System (Composable)
800
+ class FeatureFlagSystem {
801
+ async isEnabled(
802
+ flag: string,
803
+ context: { tenant: string; user?: string }
804
+ ): Promise<boolean> {
805
+ // Layered evaluation
806
+ const checks = [
807
+ this.checkGlobalOverride(flag),
808
+ this.checkTenantOverride(flag, context.tenant),
809
+ this.checkUserOverride(flag, context.user),
810
+ this.checkPercentageRollout(flag, context),
811
+ this.checkDefaultValue(flag)
812
+ ];
813
+
814
+ for (const check of checks) {
815
+ const result = await check;
816
+ if (result !== undefined) return result;
817
+ }
818
+
819
+ return false;
820
+ }
821
+ }
53
822
  ```
54
823
 
55
- ## Design Questions
56
- 1. How does this scale to 1000x?
57
- 2. What's the single point of failure?
58
- 3. How do we deploy without downtime?
59
- 4. What's the cost at scale?
824
+ ## Best Practices
825
+
826
+ ### Do's
827
+
828
+ - **Apply all 7 Omega principles** to every architectural decision
829
+ - **Design for 1000x scale** from the beginning
830
+ - **Use event-driven patterns** for loose coupling
831
+ - **Implement circuit breakers** at all service boundaries
832
+ - **Build self-healing capabilities** into every service
833
+ - **Measure and optimize** cost per transaction
834
+ - **Document decisions** using the ADR template
835
+ - **Test failure scenarios** with chaos engineering
836
+ - **Use infrastructure as code** for reproducibility
837
+ - **Implement observability** (logs, metrics, traces) everywhere
838
+
839
+ ### Don'ts
840
+
841
+ - Don't build monoliths that can't be decomposed
842
+ - Don't create tight coupling between services
843
+ - Don't ignore failure modes in design
844
+ - Don't scale vertically when horizontal is possible
845
+ - Don't hardcode configuration
846
+ - Don't skip capacity planning
847
+ - Don't deploy without health checks
848
+ - Don't rely on synchronous calls for non-critical paths
849
+ - Don't ignore data consistency requirements
850
+ - Don't underestimate the cost of distributed systems
851
+
852
+ ## References
853
+
854
+ - [Designing Data-Intensive Applications](https://dataintensive.net/)
855
+ - [Building Microservices](https://www.oreilly.com/library/view/building-microservices-2nd/9781492034018/)
856
+ - [Release It!](https://pragprog.com/titles/mnee2/release-it-second-edition/)
857
+ - [Site Reliability Engineering](https://sre.google/sre-book/table-of-contents/)
858
+ - [Cloud Design Patterns](https://docs.microsoft.com/en-us/azure/architecture/patterns/)