Phase 2 of feature development - Design architecture, events, commands, and service interactions for the Burraco distributed system. Use after running feature-discovery to create the technical design.
This skill creates the technical design for a feature including events, commands, state machines, and service interactions.
/feature-design <feature-name>
Run /feature-discovery first to understand the feature context.
For each state change, define a domain event:
// Template: Domain Event
data class [FeatureName]Event(
override val messageId: UUID,
override val header: EventHeader,
override val aggregateId: [Aggregate]Identity,
val field1: Type1,
val field2: Type2
) : [Aggregate]Event() {
companion object Factory {
fun create(aggregateId: [Aggregate]Identity, ...): [FeatureName]Event =
[FeatureName]Event(
messageId = UUID.randomUUID(),
header = EventHeader.create("[aggregate]"),
aggregateId = aggregateId,
...
)
}
}
List all events needed:
| Event Name | Aggregate | Published By | Consumed By | Kafka Topic |
|---|---|---|---|---|
| [Event1] | Game | Game | Player | game |
For cross-service communication via Kafka:
// Template: External Event
data class [FeatureName]ExternalEvent(
override val aggregateId: [Aggregate]Identity,
override val messageId: UUID,
val field1: String,
val field2: Int
) : [Aggregate]ExternalEvent() {
companion object {
fun from(event: [FeatureName]Event): [FeatureName]ExternalEvent =
[FeatureName]ExternalEvent(
aggregateId = event.aggregateId,
messageId = event.messageId,
field1 = event.field1.toString(),
field2 = event.field2
)
}
}
For each user action or event handler:
// Template: Command
data class [ActionName]Command(
override val aggregateID: [Aggregate]Identity,
val param1: Type1,
val param2: Type2
) : Command<[Aggregate]>(aggregateID) {
override fun execute(currentAggregate: [Aggregate]?): Result<[Aggregate]> = runCatching {
when (val agg = currentAggregate) {
is [ExpectedState] -> agg.[action](param1, param2)
else -> throw UnsupportedOperationException("Invalid state")
}
}
}
## State Machine Design
### Current States
[List existing states from codebase]
### New States (if any)
- [NewState]: [Description]
### Transitions
[CurrentState] --[Command/Event]--> [NewState]
Guards: [conditions]
Events: [events produced]
āāāāāāāāāā āāāāāāāāāā āāāāāāāāāā āāāāāāāāāā
ā Client ā ā Game ā ā Player ā ā Dealer ā
āāāāā¬āāāāā āāāāā¬āāāāā āāāāā¬āāāāā āāāāā¬āāāāā
ā ā ā ā
ā 1. REST ā ā ā
āāāāāāāāāāāāāā>ā ā ā
ā ā 2. Event ā ā
ā āāāāāāāāāāāāāā>ā ā
ā ā ā ā
ā<āāāāāāāāāāāāā⤠ā ā
ā 3. Response ā ā ā
### Endpoint: [METHOD] /[path]
**Request**
{
"field1": "type",
"field2": 0
}
**Response (200 OK)**
{
"status": "success"
}
**Error Responses**
| Code | Condition |
|------|-----------|
| 400 | Invalid input |
| 409 | Invalid state |
If read models need updates:
fieldName: TypefieldName: Type# Feature Design: [Feature Name]
## 1. Overview
## 2. Events
## 3. Commands
## 4. State Machine
## 5. Event Flow
## 6. REST API
## 7. Projections
## 8. Files to Create/Modify
GameCreated, CardDealt)CreateGame, DealCard)GameDraft, PlayerActive)