Template Для Новой Feature
Назначение
Документ описывает, какие файлы создать при добавлении нового use case. Цель — чтобы API doc, CQRS implementation, tests, event docs и observability не расходились.
Структура Application
Pin.<Service>.Application/
<FeatureGroup>/
<Feature>/
<Feature>Command.cs
<Feature>CommandHandler.cs
<Feature>CommandResult.cs
<Feature>CommandValidator.cs
или для query:
Pin.<Service>.Application/
<FeatureGroup>/
<Feature>/
<Feature>Query.cs
<Feature>QueryHandler.cs
<Feature>QueryResult.cs
<Feature>QueryValidator.cs
Создаются только нужные файлы. Не добавлять пустые command/query пары.
Checklist Для API Feature
- Создать или обновить API method doc в
docs/06-services/<service>/api/.../<method>.md. - Указать actor, permission, route, request/response model, CQRS mapping.
- Создать command/query, handler, result, validator.
- Создать feature-specific policy/specification/mapping рядом с feature, если нужно.
- Добавить или обновить entity/event/model docs.
- Добавить tests:
- validator tests;
- handler tests;
- API tests для auth/validation/error mapping;
- integration tests, если есть persistence/messaging/cache/provider.
- Обновить service README index.
- Добавить observability: logs, metrics, trace names.
Checklist Для Mutation
- transaction boundary;
- idempotency key;
- optimistic concurrency;
- audit record;
- MassTransit outbox publish/send;
- cache invalidation;
- state transition table;
- reconciliation behavior для external side effects.
Checklist Для Query
- source of truth или projection;
- freshness SLA;
- tenant/brand/user/partner filters;
- paging/sorting;
- masking;
- cache key и TTL, если query cacheable;
- privacy suppression, если данные агрегированные.
Naming
| Тип | Пример |
|---|---|
| FeatureGroup | Users, Roles, Bookings, Payouts, Rankings |
| Feature | GetUserRoles, CreateBooking, ApprovePayoutOrder, SearchProjects |
| Command | CreateUserCommand |
| Query | GetUserRolesQuery |
| Result | CreateUserCommandResult, GetUserRolesQueryResult |
| Validator | CreateUserCommandValidator |
| Handler | CreateUserCommandHandler |
Definition Of Done
Feature готова, если документация, implementation, tests, observability, audit и events совпадают. Если code меняет behavior, docs обновляются в той же задаче.
Обратные ссылки
Автоссылки: где используется этот документ.
- adr (1): ADR-0012: Application Feature Slices
- backend-shared-standards-index.md (1): Backend Shared Standards Index