Foreign models and third-party APIs are translated at the boundary

arch-002

Intent

Do not let foreign concepts, vendor SDK shapes, or third-party call choreography leak into local business logic.

Applicability

Applies when the diff adds or changes integration code to another service, bounded context, vendor SDK, or foreign protocol.

What to inspect

Client wrappers, translators, adapters, DTOs, and whether local application/domain code consumes foreign models directly.

Pass criteria

The boundary translates foreign data and APIs into local concepts before business logic consumes them.

Fail criteria

The diff passes foreign DTOs, SDK types, or raw external structures directly into local business logic.

Do not flag

Explicit shared-kernel arrangements that are clearly documented and thin transport objects confined to the adapter.

Confidence guidance

HIGH when the local core directly imports or accepts foreign types. MEDIUM when translation is partial. LOW when the bounded-context boundary is only implied.

Remediation

Add an owned adapter or translator and keep foreign concepts at the edge.

Pass example

Author author = collaboratorTranslator.fromUserInRole(response);
forum.startDiscussion(author, subject);

Fail example

UserInRoleResponse user = identityClient.getUserInRole(...);
forum.startDiscussion(user, subject);

Sources

  • Building Evolutionary Architectures book
  • Effective Kotlin book
  • Implementing Domain-Driven Design — Vaughn Vernon book
  • Refactoring — Martin Fowler book