| name | backend-feature |
| description | End-to-end workflow for implementing a backend feature in Convy. Use when adding new functionality that spans Domain, Application, Infrastructure, and API layers. Covers entity creation, CQRS handlers, validators, repository implementation, API endpoints, and tests. |
Backend Feature Workflow
When to Use
- Adding a new backend feature (e.g., create household, add list item, invite member)
- Implementing a user story that requires changes across multiple Clean Architecture layers
Prerequisites
- Read
docs/mvp-spec.md for the feature requirements.
- Read
backend/AGENTS.md for architecture rules.
Procedure
Step 1: Domain Layer (backend/src/Convy.Domain/)
- Create or update entities with rich behavior (private setters, guard clauses).
- Define value objects if the feature introduces new concepts.
- Add repository interface in
Domain/Repositories/ if new aggregate.
- Add domain events if the feature triggers cross-aggregate side effects.
Step 2: Application Layer (backend/src/Convy.Application/)
- Create Command (write) or Query (read) record in
Features/{Feature}/Commands/ or Queries/.
- Create Handler implementing
IRequestHandler<TRequest, TResponse>.
- Create FluentValidation Validator for the command.
- Create DTOs in
Features/{Feature}/DTOs/.
- Add mapping logic in the handler (entity ↔ DTO).
Step 3: Infrastructure Layer (backend/src/Convy.Infrastructure/)
- Add EF Core entity configuration in
Persistence/Configurations/.
- Implement repository from the Domain interface.
- Create migration if schema changes:
dotnet ef migrations add <Name> --project src/Convy.Infrastructure --startup-project src/Convy.API.
- Add SignalR event if real-time notification needed.
Step 4: API Layer (backend/src/Convy.API/)
- Create or update a Minimal API endpoint.
- Wire up
IMediator.Send() call.
- Map results to HTTP responses (200/201/400/404/500).
- Require authentication with
RequireAuthorization() unless the endpoint is intentionally public.
Step 5: Tests
- Unit tests for Domain entity behavior (
Convy.Domain.Tests).
- Unit tests for Handler logic with mocked repos (
Convy.Application.Tests).
- Integration tests for repository with real DB (
Convy.Infrastructure.Tests).
- API tests for endpoint routing and responses (
Convy.API.Tests).
Step 6: Verify
dotnet build backend/Convy.slnx
dotnet test backend/Convy.slnx
Checklist