izanagi-ai 2.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/AGENTS.md +53 -0
- package/CHANGELOG.md +198 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/ROADMAP.md +131 -0
- package/RULES.md +202 -0
- package/SYSTEM.md +201 -0
- package/agents/INDEX.md +40 -0
- package/agents/architect-agent.json +15 -0
- package/agents/bug-hunter-agent.json +14 -0
- package/agents/database-agent.json +14 -0
- package/agents/devops-agent.json +15 -0
- package/agents/docs-agent.json +15 -0
- package/agents/pm-agent.json +14 -0
- package/agents/professor-agent.json +15 -0
- package/agents/security-agent.json +14 -0
- package/agents/senior-engineer-agent.json +16 -0
- package/agents/techlead-agent.json +15 -0
- package/architecture/clean-architecture.md +98 -0
- package/architecture/cqrs-specialist.md +102 -0
- package/architecture/ddd-specialist.md +97 -0
- package/architecture/event-driven-architect.md +79 -0
- package/architecture/hexagonal-architecture.md +96 -0
- package/architecture/microservices-expert.md +83 -0
- package/architecture/monolith-expert.md +67 -0
- package/architecture/repository-pattern.md +73 -0
- package/architecture/unit-of-work.md +92 -0
- package/backend/README.md +29 -0
- package/bin/nexus.js +8 -0
- package/core/compression-engine.md +194 -0
- package/core/context-engine.md +239 -0
- package/core/decision-engine.md +377 -0
- package/core/evolution-engine.md +169 -0
- package/core/planning-engine.md +201 -0
- package/core/quality-gates.md +233 -0
- package/core/reflection-engine.md +182 -0
- package/core/skill-resolver.json +169 -0
- package/core/token-manager.md +152 -0
- package/database/database-engineer.md +244 -0
- package/database/mysql-specialist.md +61 -0
- package/database/postgresql-specialist.md +70 -0
- package/database/redis-specialist.md +73 -0
- package/database/sql-optimizer.md +95 -0
- package/database/sqlserver-specialist.md +69 -0
- package/devops/ci-cd-specialist.md +101 -0
- package/devops/devops-engineer.md +358 -0
- package/devops/docker-expert.md +105 -0
- package/devops/git-expert.md +76 -0
- package/devops/git-flow-specialist.md +71 -0
- package/devops/kubernetes-specialist.md +84 -0
- package/devops/linux-specialist.md +82 -0
- package/devops/windows-specialist.md +43 -0
- package/dist/cli/commands/compile.d.ts +2 -0
- package/dist/cli/commands/compile.d.ts.map +1 -0
- package/dist/cli/commands/compile.js +44 -0
- package/dist/cli/commands/compile.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/doctor.d.ts.map +1 -0
- package/dist/cli/commands/doctor.js +88 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/init.js +26 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/list.d.ts +2 -0
- package/dist/cli/commands/list.d.ts.map +1 -0
- package/dist/cli/commands/list.js +50 -0
- package/dist/cli/commands/list.js.map +1 -0
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +49 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +72 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/installer.d.ts +5 -0
- package/dist/installer.d.ts.map +1 -0
- package/dist/installer.js +86 -0
- package/dist/installer.js.map +1 -0
- package/dist/postinstall.d.ts +2 -0
- package/dist/postinstall.d.ts.map +1 -0
- package/dist/postinstall.js +8 -0
- package/dist/postinstall.js.map +1 -0
- package/frontend/README.md +19 -0
- package/memory/context-recovery.md +49 -0
- package/memory/conversation-summarizer.md +65 -0
- package/memory/long-term-project-memory.md +58 -0
- package/memory/memory-manager.md +299 -0
- package/memory/session-compression.md +182 -0
- package/memory/smart-recall.md +37 -0
- package/optimization/compact-example.md +87 -0
- package/optimization/cost-optimizer.md +53 -0
- package/optimization/prompt-optimizer.md +194 -0
- package/optimization/token-audit.md +177 -0
- package/optimization/token-reducer.md +202 -0
- package/package.json +67 -0
- package/security/owasp-auditor.md +249 -0
- package/security/pentest-reviewer.md +109 -0
- package/security/security-engineer.md +238 -0
- package/skills/INDEX.md +434 -0
- package/skills/accessibility-reviewer.md +63 -0
- package/skills/agentic-coding.md +56 -0
- package/skills/ai-agent/SKILL.md +107 -0
- package/skills/ai-agent-dev/SKILL.md +117 -0
- package/skills/alternative-solution-generator.md +72 -0
- package/skills/architecture-patterns/SKILL.md +113 -0
- package/skills/breaking-change-detector.md +84 -0
- package/skills/bug-hunter.md +234 -0
- package/skills/bug-prevention.md +75 -0
- package/skills/chaos-engineering/SKILL.md +108 -0
- package/skills/clean-code-validator.md +218 -0
- package/skills/cloud-architect/SKILL.md +78 -0
- package/skills/cloud-infra/SKILL.md +99 -0
- package/skills/code-auditor.md +24 -0
- package/skills/complexity-analyzer.md +102 -0
- package/skills/confidence-estimator.md +53 -0
- package/skills/continuous-improvement.md +46 -0
- package/skills/continuous-learning-engine.md +51 -0
- package/skills/cto-advisor.md +66 -0
- package/skills/data-engineer/SKILL.md +76 -0
- package/skills/data-engineering/SKILL.md +82 -0
- package/skills/debug-specialist.md +215 -0
- package/skills/dependency-analyzer.md +78 -0
- package/skills/design-pattern-advisor.md +78 -0
- package/skills/documentation-writer.md +66 -0
- package/skills/dry-kiss-yagni-validator.md +114 -0
- package/skills/economia-tokens/SKILL.md +40 -0
- package/skills/er-diagram-builder.md +85 -0
- package/skills/feature-flags/SKILL.md +95 -0
- package/skills/frontend/SKILL.md +327 -0
- package/skills/frontend-dev/SKILL.md +178 -0
- package/skills/graphql/SKILL.md +104 -0
- package/skills/hallucination-detection.md +49 -0
- package/skills/handoff-sessao/SKILL.md +32 -0
- package/skills/i18n-l10n/SKILL.md +103 -0
- package/skills/iac-terraform/SKILL.md +98 -0
- package/skills/legacy-migration/SKILL.md +91 -0
- package/skills/logging-expert.md +78 -0
- package/skills/mcp-server-dev.md +33 -0
- package/skills/memoria-projeto/SKILL.md +49 -0
- package/skills/mobile-dev/SKILL.md +82 -0
- package/skills/mobile-engineer/SKILL.md +74 -0
- package/skills/monitoring-specialist.md +59 -0
- package/skills/observability-expert.md +60 -0
- package/skills/performance-optimizer.md +239 -0
- package/skills/principal-engineer.md +55 -0
- package/skills/privacy-engineer/SKILL.md +79 -0
- package/skills/professor-modo/SKILL.md +33 -0
- package/skills/project-manager.md +74 -0
- package/skills/prompt-engineering.md +27 -0
- package/skills/qa/SKILL.md +231 -0
- package/skills/qa-engineer/SKILL.md +222 -0
- package/skills/readme-generator.md +42 -0
- package/skills/refactoring-specialist.md +250 -0
- package/skills/release-planner.md +70 -0
- package/skills/requirement-analyzer.md +65 -0
- package/skills/risk-analyzer.md +73 -0
- package/skills/root-cause-analyzer.md +210 -0
- package/skills/scalability-expert.md +73 -0
- package/skills/security-privacy/SKILL.md +98 -0
- package/skills/self-correction.md +54 -0
- package/skills/self-critique.md +42 -0
- package/skills/senior-code-reviewer.md +193 -0
- package/skills/sequence-diagram-builder.md +56 -0
- package/skills/serverless-edge/SKILL.md +103 -0
- package/skills/software-architect.md +356 -0
- package/skills/solid-validator.md +332 -0
- package/skills/sre-reliability/SKILL.md +115 -0
- package/skills/staff-engineer.md +61 -0
- package/skills/task-planner.md +61 -0
- package/skills/tech-lead.md +59 -0
- package/skills/technical-debt-analyzer.md +81 -0
- package/skills/technical-writer.md +39 -0
- package/skills/tradeoff-analyzer.md +79 -0
- package/skills/uml-generator.md +72 -0
- package/skills/ux-reviewer.md +61 -0
- package/skills/wasm/SKILL.md +133 -0
- package/skills/web-perf-engineer/SKILL.md +75 -0
- package/skills/web-perf-seo/SKILL.md +111 -0
- package/skills/websocket-realtime/SKILL.md +107 -0
- package/teaching/adaptive-teaching.md +37 -0
- package/teaching/code-explainer.md +172 -0
- package/teaching/interactive-teaching.md +41 -0
- package/teaching/learning-tracker.md +63 -0
- package/teaching/mentor-mode.md +200 -0
- package/teaching/professor-mode.md +222 -0
- package/testing/e2e-test-engineer.md +68 -0
- package/testing/integration-test-engineer.md +74 -0
- package/testing/mocking-specialist.md +78 -0
- package/testing/unit-test-engineer.md +209 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Architecture: Clean Architecture
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect, DDD Specialist
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Clean Architecture enforces dependency inversion: domain at the center, application use cases around it, infrastructure and delivery at the outer rings. Nothing in the inner ring depends on anything in the outer rings.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Layer Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
┌──────────────────────────────────────────┐
|
|
19
|
+
│ Delivery (Controllers, API, CLI) │ → depends on Application
|
|
20
|
+
│ ┌────────────────────────────────────┐ │
|
|
21
|
+
│ │ Infrastructure (DB, Queue, Mail) │ │ → depends on Application
|
|
22
|
+
│ │ ┌──────────────────────────────┐ │ │
|
|
23
|
+
│ │ │ Application (Use Cases) │ │ │ → depends on Domain only
|
|
24
|
+
│ │ │ ┌────────────────────────┐ │ │ │
|
|
25
|
+
│ │ │ │ Domain (Entities, │ │ │ │
|
|
26
|
+
│ │ │ │ ValueObjects, │ │ │ │ → zero dependencies
|
|
27
|
+
│ │ │ │ Domain Services) │ │ │ │
|
|
28
|
+
│ │ │ └────────────────────────┘ │ │ │
|
|
29
|
+
│ │ └──────────────────────────────┘ │ │
|
|
30
|
+
│ └────────────────────────────────────┘ │
|
|
31
|
+
└──────────────────────────────────────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Directory Structure
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
src/
|
|
40
|
+
├── Domain/
|
|
41
|
+
│ ├── Entities/
|
|
42
|
+
│ ├── ValueObjects/
|
|
43
|
+
│ ├── Events/
|
|
44
|
+
│ ├── Repositories/ (interfaces)
|
|
45
|
+
│ └── Services/ (domain services)
|
|
46
|
+
│
|
|
47
|
+
├── Application/
|
|
48
|
+
│ ├── UseCases/
|
|
49
|
+
│ ├── DTOs/
|
|
50
|
+
│ ├── Ports/ (input/output interfaces)
|
|
51
|
+
│ └── Exceptions/
|
|
52
|
+
│
|
|
53
|
+
├── Infrastructure/
|
|
54
|
+
│ ├── Persistence/ (repository implementations)
|
|
55
|
+
│ ├── Queue/
|
|
56
|
+
│ ├── Mail/
|
|
57
|
+
│ └── Cache/
|
|
58
|
+
│
|
|
59
|
+
└── Delivery/
|
|
60
|
+
├── Controllers/
|
|
61
|
+
├── Requests/
|
|
62
|
+
└── Responses/
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Dependency Rule
|
|
68
|
+
|
|
69
|
+
```php
|
|
70
|
+
// Domain — zero dependencies
|
|
71
|
+
class Order { ... }
|
|
72
|
+
|
|
73
|
+
// Application — depends on Domain only
|
|
74
|
+
class PlaceOrderUseCase
|
|
75
|
+
{
|
|
76
|
+
public function __construct(
|
|
77
|
+
private OrderRepository $repository, // Interface from Domain
|
|
78
|
+
private EventDispatcher $dispatcher, // Interface from Application Ports
|
|
79
|
+
) {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Infrastructure — implements Domain interfaces
|
|
83
|
+
class PostgresOrderRepository implements OrderRepository { ... }
|
|
84
|
+
|
|
85
|
+
// Delivery — uses Application
|
|
86
|
+
class OrderController
|
|
87
|
+
{
|
|
88
|
+
public function __construct(
|
|
89
|
+
private PlaceOrderUseCase $useCase
|
|
90
|
+
) {}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Changelog
|
|
97
|
+
|
|
98
|
+
### 1.0.0 — Initial release. Layers, directory structure, dependency rule.
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Architecture: CQRS Specialist
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect, Event-Driven Architect
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
CQRS Specialist separates read and write models. Commands change state, queries read state. Read models can be optimized for queries (denormalized, different DB), write models enforce domain invariants.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## When to Use CQRS
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
use:
|
|
19
|
+
- Complex domain with different read/write shapes
|
|
20
|
+
- High read volume (reads scale independently)
|
|
21
|
+
- Event sourcing (events write, projections read)
|
|
22
|
+
- Reporting needs (read models optimized for queries)
|
|
23
|
+
|
|
24
|
+
avoid:
|
|
25
|
+
- Simple CRUD (overhead without benefit)
|
|
26
|
+
- Single database (no need for separate models yet)
|
|
27
|
+
- Small team (complexity tax)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Structure
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Commands:
|
|
36
|
+
POST /orders/place
|
|
37
|
+
Body: { cartId, customerId }
|
|
38
|
+
→ Command: PlaceOrderCommand
|
|
39
|
+
→ Handler: PlaceOrderHandler
|
|
40
|
+
→ Event: OrderPlaced
|
|
41
|
+
|
|
42
|
+
Queries:
|
|
43
|
+
GET /orders/active
|
|
44
|
+
→ Query: GetActiveOrdersQuery
|
|
45
|
+
→ Handler: GetActiveOrdersHandler
|
|
46
|
+
→ Returns: ReadModel (denormalized)
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Implementation
|
|
52
|
+
|
|
53
|
+
```php
|
|
54
|
+
// Command
|
|
55
|
+
class PlaceOrderCommand
|
|
56
|
+
{
|
|
57
|
+
public function __construct(
|
|
58
|
+
public readonly string $cartId,
|
|
59
|
+
public readonly string $customerId,
|
|
60
|
+
) {}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Command Handler (write model)
|
|
64
|
+
class PlaceOrderHandler
|
|
65
|
+
{
|
|
66
|
+
public function __construct(
|
|
67
|
+
private OrderRepository $repository,
|
|
68
|
+
private EventDispatcher $dispatcher,
|
|
69
|
+
) {}
|
|
70
|
+
|
|
71
|
+
public function handle(PlaceOrderCommand $command): void
|
|
72
|
+
{
|
|
73
|
+
$order = Order::place(
|
|
74
|
+
CartId::fromString($command->cartId),
|
|
75
|
+
CustomerId::fromString($command->customerId),
|
|
76
|
+
);
|
|
77
|
+
$this->repository->save($order);
|
|
78
|
+
$this->dispatcher->dispatch(new OrderPlaced($order->getId()));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Query Handler (read model — optimized for queries)
|
|
83
|
+
class GetActiveOrdersHandler
|
|
84
|
+
{
|
|
85
|
+
public function __construct(
|
|
86
|
+
private OrderReadModel $readModel, // Separate from write repo
|
|
87
|
+
) {}
|
|
88
|
+
|
|
89
|
+
public function handle(GetActiveOrdersQuery $query): array
|
|
90
|
+
{
|
|
91
|
+
return $this->readModel->getActiveOrders(
|
|
92
|
+
$query->customerId,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Changelog
|
|
101
|
+
|
|
102
|
+
### 1.0.0 — Initial release. When to use, structure, implementation.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Architecture: DDD Specialist
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
DDD Specialist applies Domain-Driven Design: ubiquitous language, bounded contexts, aggregates, entities, value objects, domain events, and repositories. Ensures the codebase speaks the language of the business.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## DDD Building Blocks
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
entity: has identity (id), mutable, tracked through lifecycle
|
|
19
|
+
- User, Order, Product
|
|
20
|
+
|
|
21
|
+
value_object: immutable, defined by attributes, no identity
|
|
22
|
+
- Address, Money, Email
|
|
23
|
+
|
|
24
|
+
aggregate: cluster of entities/VOs treated as a unit
|
|
25
|
+
- Order (with OrderItems), consistency boundary
|
|
26
|
+
|
|
27
|
+
repository: collection-like interface for aggregates
|
|
28
|
+
- OrderRepository, UserRepository
|
|
29
|
+
|
|
30
|
+
domain_event: something that happened (past tense)
|
|
31
|
+
- OrderPlaced, PaymentReceived
|
|
32
|
+
|
|
33
|
+
domain_service: stateless operation that doesn't fit an entity
|
|
34
|
+
- DiscountCalculator, ShippingCostService
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Ubiquitous Language
|
|
40
|
+
|
|
41
|
+
```yaml
|
|
42
|
+
business_term: "Order"
|
|
43
|
+
code: App\Domain\Order\Order.php
|
|
44
|
+
|
|
45
|
+
business_term: "Place Order"
|
|
46
|
+
code: App\Domain\Order\Commands\PlaceOrder.php
|
|
47
|
+
|
|
48
|
+
business_term: "Order Placed"
|
|
49
|
+
code: App\Domain\Order\Events\OrderPlaced.php
|
|
50
|
+
|
|
51
|
+
business_term: "Order Total"
|
|
52
|
+
code: App\Domain\Order\ValueObjects\OrderTotal.php
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Aggregate Example
|
|
58
|
+
|
|
59
|
+
```php
|
|
60
|
+
class Order extends AggregateRoot
|
|
61
|
+
{
|
|
62
|
+
private function __construct(
|
|
63
|
+
private readonly OrderId $id,
|
|
64
|
+
private readonly Cart $cart,
|
|
65
|
+
private OrderStatus $status,
|
|
66
|
+
private \DateTimeImmutable $placedAt,
|
|
67
|
+
) {}
|
|
68
|
+
|
|
69
|
+
public static function place(Cart $cart, CustomerId $customerId): self
|
|
70
|
+
{
|
|
71
|
+
if ($cart->isEmpty()) {
|
|
72
|
+
throw new CannotPlaceEmptyOrder($cart->getId());
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
$order = new self(
|
|
76
|
+
OrderId::generate(),
|
|
77
|
+
$cart,
|
|
78
|
+
OrderStatus::Pending,
|
|
79
|
+
new \DateTimeImmutable()
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
$order->recordEvent(new OrderPlaced(
|
|
83
|
+
orderId: $order->id,
|
|
84
|
+
customerId: $customerId,
|
|
85
|
+
total: $cart->total(),
|
|
86
|
+
));
|
|
87
|
+
|
|
88
|
+
return $order;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Changelog
|
|
96
|
+
|
|
97
|
+
### 1.0.0 — Initial release. Building blocks, language, aggregate example.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Architecture: Event-Driven Architect
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect, Microservices Expert
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Event-Driven Architect designs systems where services communicate through events. Defines event schemas, idempotency, at-least-once delivery, dead letter queues, and event sourcing when appropriate.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Core Concepts
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
event: a fact that happened in the past (past tense)
|
|
19
|
+
- "user.registered", "order.placed", "payment.received"
|
|
20
|
+
|
|
21
|
+
message_broker:
|
|
22
|
+
- RabbitMQ: reliable, routing flexibility
|
|
23
|
+
- Kafka: high throughput, event sourcing, replay
|
|
24
|
+
- Redis Pub/Sub: lightweight, no persistence
|
|
25
|
+
|
|
26
|
+
patterns:
|
|
27
|
+
event_notification: fire and forget
|
|
28
|
+
event_carried_state: include enough data for consumers
|
|
29
|
+
saga: distributed transaction via events + compensating actions
|
|
30
|
+
event_sourcing: store events as source of truth
|
|
31
|
+
CQRS: separate read model updated by events
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Event Schema
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"id": "evt_abc123",
|
|
41
|
+
"type": "user.registered",
|
|
42
|
+
"version": 1,
|
|
43
|
+
"timestamp": "2026-07-17T12:00:00Z",
|
|
44
|
+
"producer": "user-service",
|
|
45
|
+
"data": {
|
|
46
|
+
"user_id": "usr_456",
|
|
47
|
+
"email": "user@test.com"
|
|
48
|
+
},
|
|
49
|
+
"metadata": {
|
|
50
|
+
"correlation_id": "req_789",
|
|
51
|
+
"cause": "user.registration.submitted"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Idempotency
|
|
59
|
+
|
|
60
|
+
Every event consumer must handle duplicate events:
|
|
61
|
+
|
|
62
|
+
```php
|
|
63
|
+
// Consumer
|
|
64
|
+
public function handle(UserRegistered $event): void
|
|
65
|
+
{
|
|
66
|
+
if ($this->alreadyProcessed($event->id)) {
|
|
67
|
+
return; // Idempotent — already handled
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
$this->sendWelcomeEmail($event->email);
|
|
71
|
+
$this->markProcessed($event->id);
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Changelog
|
|
78
|
+
|
|
79
|
+
### 1.0.0 — Initial release. Events, brokers, patterns, idempotency.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Architecture: Hexagonal Architecture (Ports & Adapters)
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Hexagonal Architecture (Ports & Adapters) isolates the core application from external concerns through ports (interfaces) and adapters (implementations). The core has no dependency on frameworks, databases, or delivery mechanisms.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Structure
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
┌─────────────┐
|
|
19
|
+
│ Adapter │ (Inbound: Controller, CLI, Queue Consumer)
|
|
20
|
+
│ (Delivery) │
|
|
21
|
+
└──────┬──────┘
|
|
22
|
+
│ Port (inbound interface)
|
|
23
|
+
┌──────▼──────┐
|
|
24
|
+
│ CORE │ (Application + Domain)
|
|
25
|
+
│ (no deps) │
|
|
26
|
+
└──────┬──────┘
|
|
27
|
+
│ Port (outbound interface)
|
|
28
|
+
┌──────▼──────┐
|
|
29
|
+
│ Adapter │ (Outbound: PostgreSQL, Redis, Mail, HTTP)
|
|
30
|
+
│ (Infra) │
|
|
31
|
+
└─────────────┘
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Ports & Adapters
|
|
37
|
+
|
|
38
|
+
```php
|
|
39
|
+
// Port (outbound interface)
|
|
40
|
+
interface OrderRepository
|
|
41
|
+
{
|
|
42
|
+
public function save(Order $order): void;
|
|
43
|
+
public function findById(OrderId $id): ?Order;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Adapter (outbound implementation)
|
|
47
|
+
class PostgresOrderRepository implements OrderRepository
|
|
48
|
+
{
|
|
49
|
+
public function __construct(private Connection $db) {}
|
|
50
|
+
|
|
51
|
+
public function save(Order $order): void
|
|
52
|
+
{
|
|
53
|
+
$this->db->insert('orders', [
|
|
54
|
+
'id' => $order->getId()->toString(),
|
|
55
|
+
'total' => $order->getTotal()->toCents(),
|
|
56
|
+
'status' => $order->getStatus()->value,
|
|
57
|
+
]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public function findById(OrderId $id): ?Order
|
|
61
|
+
{
|
|
62
|
+
$row = $this->db->fetch('SELECT * FROM orders WHERE id = ?', [$id->toString()]);
|
|
63
|
+
return $row ? $this->hydrate($row) : null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Key Benefit
|
|
71
|
+
|
|
72
|
+
Swap infrastructure without touching core:
|
|
73
|
+
|
|
74
|
+
```php
|
|
75
|
+
// Test adapter (instead of PostgresOrderRepository)
|
|
76
|
+
class InMemoryOrderRepository implements OrderRepository
|
|
77
|
+
{
|
|
78
|
+
private array $orders = [];
|
|
79
|
+
|
|
80
|
+
public function save(Order $order): void
|
|
81
|
+
{
|
|
82
|
+
$this->orders[$order->getId()->toString()] = $order;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public function findById(OrderId $id): ?Order
|
|
86
|
+
{
|
|
87
|
+
return $this->orders[$id->toString()] ?? null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Changelog
|
|
95
|
+
|
|
96
|
+
### 1.0.0 — Initial release. Ports & Adapters, example, testability.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Architecture: Microservices Expert
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect, DevOps Engineer, API Designer
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Microservices Expert designs systems of independently deployable services communicating via APIs or events. Identifies bounded contexts (DDD), defines service contracts, and handles interservice communication, data consistency, and observability.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## When to Use
|
|
16
|
+
|
|
17
|
+
```yaml
|
|
18
|
+
use_microservices:
|
|
19
|
+
- Multiple teams working independently
|
|
20
|
+
- Different scaling requirements per domain
|
|
21
|
+
- Polyglot persistence (different DBs per service)
|
|
22
|
+
- Independent deployment cycles needed
|
|
23
|
+
|
|
24
|
+
prefer_monolith:
|
|
25
|
+
- Single team < 5 developers
|
|
26
|
+
- Simple CRUD application
|
|
27
|
+
- Early-stage product (MVP)
|
|
28
|
+
- No clear bounded context boundaries yet
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## Key Patterns
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
communication:
|
|
37
|
+
sync: REST/gRPC for queries, command responses
|
|
38
|
+
async: Events (RabbitMQ/Kafka) for commands, notifications
|
|
39
|
+
|
|
40
|
+
data:
|
|
41
|
+
database_per_service: each service owns its data
|
|
42
|
+
saga: distributed transaction (choreography or orchestration)
|
|
43
|
+
CQRS: separate read/write models per service
|
|
44
|
+
|
|
45
|
+
deployment:
|
|
46
|
+
containerized: Docker + Kubernetes
|
|
47
|
+
per_service_pipeline: each service has its own CI/CD
|
|
48
|
+
blue_green: zero-downtime deployments
|
|
49
|
+
|
|
50
|
+
observability:
|
|
51
|
+
logging: structured JSON, correlation ID per request
|
|
52
|
+
metrics: RED metrics (Rate, Errors, Duration) per service
|
|
53
|
+
tracing: distributed tracing (OpenTelemetry + Jaeger)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Service Template
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
service:
|
|
62
|
+
name: "user-service"
|
|
63
|
+
language: "PHP / Laravel"
|
|
64
|
+
database: "postgresql:16"
|
|
65
|
+
communication: "REST (internal) + Events (RabbitMQ)"
|
|
66
|
+
|
|
67
|
+
endpoints:
|
|
68
|
+
- "POST /api/v1/users"
|
|
69
|
+
- "GET /api/v1/users/{id}"
|
|
70
|
+
|
|
71
|
+
events_publishes:
|
|
72
|
+
- "user.created"
|
|
73
|
+
- "user.updated"
|
|
74
|
+
|
|
75
|
+
events_subscribes:
|
|
76
|
+
- "order.completed → update user stats"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Changelog
|
|
82
|
+
|
|
83
|
+
### 1.0.0 — Initial release. Patterns, when to use/avoid, template.
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# Architecture: Monolith Expert
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: Medium
|
|
4
|
+
> Dependencies: Software Architect
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Monolith Expert defends the monolith as a valid, often superior architecture for most projects. Designs modular monoliths with clear bounded contexts, strict module boundaries, and a migration path toward microservices only when justified.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Advantages
|
|
16
|
+
|
|
17
|
+
- Simple deployment (1 artifact).
|
|
18
|
+
- No network latency between modules.
|
|
19
|
+
- Atomic transactions across domains.
|
|
20
|
+
- Easy debugging and testing.
|
|
21
|
+
- Lower operational complexity.
|
|
22
|
+
- Faster development velocity (early stage).
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Modular Monolith Structure
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
app/
|
|
30
|
+
├── Modules/
|
|
31
|
+
│ ├── User/
|
|
32
|
+
│ │ ├── Controllers/
|
|
33
|
+
│ │ ├── Services/
|
|
34
|
+
│ │ ├── Repositories/
|
|
35
|
+
│ │ ├── Events/
|
|
36
|
+
│ │ └── Models/
|
|
37
|
+
│ ├── Payment/
|
|
38
|
+
│ │ └── ...
|
|
39
|
+
│ └── Order/
|
|
40
|
+
│ └── ...
|
|
41
|
+
├── Shared/
|
|
42
|
+
│ ├── Kernel.php
|
|
43
|
+
│ └── Helpers/
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Migration Path
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
Monolith → Modular Monolith → (if needed) → Microservices
|
|
52
|
+
|
|
53
|
+
Rules:
|
|
54
|
+
1. Never start with microservices
|
|
55
|
+
2. Extract bounded contexts into modules first
|
|
56
|
+
3. Define strict interfaces between modules
|
|
57
|
+
4. Only extract to separate service when:
|
|
58
|
+
- Module needs independent scaling
|
|
59
|
+
- Module needs a different tech stack
|
|
60
|
+
- Team needs independent deploys
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Changelog
|
|
66
|
+
|
|
67
|
+
### 1.0.0 — Initial release. Modular monolith, migration path.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Architecture: Repository Pattern
|
|
2
|
+
|
|
3
|
+
> Version 1.0.0 | Priority: High
|
|
4
|
+
> Dependencies: Software Architect, DDD Specialist
|
|
5
|
+
> Compatibility: ">=1.0.0"
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Identity
|
|
10
|
+
|
|
11
|
+
Repository Pattern mediates between domain and data mapping layers, acting like an in-memory collection of aggregate roots. It provides a clean separation between business logic and data access.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Contract
|
|
16
|
+
|
|
17
|
+
```php
|
|
18
|
+
interface UserRepository
|
|
19
|
+
{
|
|
20
|
+
public function findById(UserId $id): ?User;
|
|
21
|
+
public function findByEmail(string $email): ?User;
|
|
22
|
+
public function save(User $user): void;
|
|
23
|
+
public function delete(UserId $id): void;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Implementation
|
|
28
|
+
|
|
29
|
+
```php
|
|
30
|
+
class PostgresUserRepository implements UserRepository
|
|
31
|
+
{
|
|
32
|
+
public function __construct(private Connection $db) {}
|
|
33
|
+
|
|
34
|
+
public function findById(UserId $id): ?User
|
|
35
|
+
{
|
|
36
|
+
$row = $this->db->fetch('SELECT * FROM users WHERE id = ?', [$id->toString()]);
|
|
37
|
+
return $row ? $this->hydrate($row) : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public function save(User $user): void
|
|
41
|
+
{
|
|
42
|
+
$this->db->upsert('users', [
|
|
43
|
+
'id' => $user->getId()->toString(),
|
|
44
|
+
'name' => $user->getName(),
|
|
45
|
+
'email' => $user->getEmail(),
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private function hydrate(array $row): User
|
|
50
|
+
{
|
|
51
|
+
return new User(
|
|
52
|
+
UserId::fromString($row['id']),
|
|
53
|
+
$row['name'],
|
|
54
|
+
$row['email'],
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Rules
|
|
63
|
+
|
|
64
|
+
- Repository per aggregate root (not per table).
|
|
65
|
+
- One `save()` method handles both insert and update.
|
|
66
|
+
- Repositories return domain objects, not arrays.
|
|
67
|
+
- Repositories hide the data source (SQL, API, file).
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Changelog
|
|
72
|
+
|
|
73
|
+
### 1.0.0 — Initial release. Contract, implementation, rules.
|