| name | backend-ddd-vertical-slice |
| description | Implement backend features with vertical slices and pragmatic Domain-Driven Design in .NET. Use when adding or refactoring API endpoints, commands/queries, domain rules, repositories, integrations, or tests for business-critical modules such as budgets, transactions, households, subscriptions, and provider sync flows. |
Backend Ddd Vertical Slice
Overview
Build backend features as independent slices with clear boundaries.
Model rich domain logic only where business rules are non-trivial.
Workflow
- Identify the target module and business capability.
- Create or update the vertical slice folders:
Domain, Application, Infrastructure, Presentation.
- Put invariants and business rules in domain entities/value objects.
- Keep command/query handlers orchestration-focused.
- Keep endpoint handlers thin and contract-driven.
- Add integration boundaries for persistence and external systems.
- Add tests at domain, application, integration, and endpoint levels.
- Verify OpenAPI and idempotency implications before completion.
Decision Rules
- Use rich domain models for core business rules.
- Use simple DTO/projection queries for read-heavy endpoints.
- Keep domain independent of web, DB, and provider SDK concerns.
- Keep each handler focused on one use case.
- Prefer explicit domain errors over generic exceptions.
- Keep cross-module coupling via interfaces and contracts only.
Required Output Elements
- Slice architecture summary.
- Domain model and invariants summary.
- API contract changes and OpenAPI impact.
- Persistence/integration boundaries changed.
- Test evidence by layer.
- Risk and rollout notes.
Verification Checklist
- Domain layer has no framework dependencies.
- Endpoint code contains no business rule logic.
- Command/query handlers are thin orchestration.
- Webhook/provider flows are idempotent and observable.
- OpenAPI is updated for contract changes.
- Critical paths have tests across required layers.
Reference Files
- Backend conventions and templates:
references/backend-ddd-vertical-slice-checklist.md
Load this checklist before implementing backend features.