Перейти к основному содержимому

Namespace И Naming Conventions

Назначение

Документ фиксирует namespace и naming conventions для feature-slice backend структуры.

Application Namespace

Pin.<Service>.Application.<FeatureGroup>.<Feature>

Правила:

  • FeatureGroup — plural noun или business capability: Users, Roles, Withdrawals, PaymentProviders.
  • Feature — use case в imperative/read style: CreateUser, GetUserRoles, ApproveWithdrawal.
  • Handler, validator, result находятся в namespace feature.
  • Shared group models лежат в Pin.<Service>.Application.<FeatureGroup>.Models.
  • Cross-group models лежат в Pin.<Service>.Application.Shared.Models.

Domain Namespace

Pin.<Service>.Domain.<Aggregate>

Примеры:

  • Pin.Accounting.Domain.WithdrawalRequests
  • Pin.GameHost.Domain.GameSessions
  • Pin.PromoPartner.Domain.Partners

Domain namespace строится вокруг aggregate/invariant, а не вокруг API feature.

Infrastructure Namespace

Pin.<Service>.Infrastructure.Persistence.Repositories
Pin.<Service>.Infrastructure.Integrations.<ProviderName>
Pin.<Service>.Infrastructure.Search.<FeatureGroup>
Pin.<Service>.Infrastructure.Redis.<FeatureGroup>

Provider DTO не выходит за Infrastructure.Integrations.<ProviderName>.

API Namespace

Pin.<Service>.Api.Controllers
Pin.<Service>.Api.Models.<FeatureGroup>
Pin.<Service>.Api.Authorization
Pin.<Service>.Api.Middlewares

Request/response DTO в Api.Models создаются только если HTTP contract отличается от application result. Иначе controller маппит application result напрямую в response contract.

Test Namespace

Pin.<Service>.Application.Tests.<FeatureGroup>.<Feature>
Pin.<Service>.Domain.Tests.<Aggregate>
Pin.<Service>.Infrastructure.Tests.<Capability>

Тесты feature не складываются в общую папку Handlers или Commands.

Обратные ссылки

Автоссылки: где используется этот документ.