Skip to content
acc-create-anti-corruption-layer logo

Anti-Corruption Layer Generator

acc-create-anti-corruption-layer

Generates DDD Anti-Corruption Layer for PHP 8.5. Creates translation layer between bounded contexts or external systems. Includes adapters, translators, facades, and unit tests.

SKILL.md

Full skill instructions

Anti-Corruption Layer Generator

Generate DDD-compliant Anti-Corruption Layer (ACL) components for isolating bounded contexts and integrating with external/​legacy systems.

When to Use

ScenarioExample
Legacy system integrationERP, CRM, mainframe
Third-party API integrationPayment gateway, shipping API
Bounded context communicationOrder ↔ Inventory contexts
Database migrationOld schema → new domain model
Microservice integrationExternal service with different model

Anti-Corruption Layer Characteristics

  • Isolation: Protects domain model from external/​foreign concepts
  • Translation: Converts between domain and external models
  • Facade: Provides simplified interface to external systems
  • Adapter: Implements domain ports using external services
  • No Domain Leakage: External concepts never enter domain layer
  • Bidirectional: Can translate both inbound and outbound

ACL Architecture

YOUR BOUNDED CONTEXT
├── DOMAIN LAYER
│   └── Port (Interface) ←────────────┐
│                                      │
├── ANTI-CORRUPTION LAYER             │
│   ├── Adapter (implements Port) ────┘
│   ├── Translator (Domain ↔ External)
│   ├── Facade (External system wrapper)
│   └── External DTOs
│
└── EXTERNAL SYSTEM (Legacy, API, other bounded context)

Generation Process

Step 1: Generate Domain Port

Path: src/​Domain/​{BoundedContext}/​Port/

  1. {ExternalSystem}PortInterface.php — Domain interface for external system

Step 2: Generate External DTOs

Path: src/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​DTO/

  1. {ExternalSystem}{Concept}DTO.php — DTOs matching external format

Step 3: Generate Translator

Path: src/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/

  1. {ExternalSystem}Translator.php — Domain ↔ External conversion

Step 4: Generate Facade

Path: src/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/

  1. {ExternalSystem}Facade.php — Simplified external system interface

Step 5: Generate Adapter

Path: src/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/

  1. {ExternalSystem}Adapter.php — Implements domain port

Step 6: Generate Exceptions

Path: src/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​Exception/

  1. {ExternalSystem}Exception.php — Domain exception
  2. {ExternalSystem}ConnectionException.php — Infrastructure exception

Step 7: Generate Tests

  1. {ExternalSystem}TranslatorTest.php — Translation tests
  2. {ExternalSystem}AdapterTest.php — Adapter integration tests

File Placement

ComponentPath
Domain Portsrc/​Domain/​{BoundedContext}/​Port/​{ExternalSystem}PortInterface.php
External DTOsrc/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​DTO/
Translatorsrc/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​{ExternalSystem}Translator.php
Facadesrc/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​{ExternalSystem}Facade.php
Adaptersrc/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​{ExternalSystem}Adapter.php
Exceptionssrc/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/​Exception/
Teststests/​Unit/​Infrastructure/​{BoundedContext}/​ACL/​{ExternalSystem}/

Naming Conventions

ComponentPatternExample
Port{ExternalSystem}PortInterfacePaymentGatewayPortInterface
DTO{ExternalSystem}{Concept}DTOStripeChargeDTO
Translator{ExternalSystem}TranslatorStripeTranslator
Facade{ExternalSystem}FacadeStripeFacade
Adapter{ExternalSystem}AdapterStripeAdapter
Exception{ExternalSystem}ExceptionStripeException

Quick Template Reference

Domain Port

interface {ExternalSystem}PortInterface
{
    public function {operation}({DomainParameters}): {DomainReturnType};
}

Translator

final readonly class {ExternalSystem}Translator
{
    public function toDomain({ExternalSystem}DTO $dto): {Entity};
    public function toExternal({Entity} $entity): {ExternalSystem}DTO;
}

Adapter

final readonly class {ExternalSystem}Adapter implements {ExternalSystem}PortInterface
{
    public function __construct(
        private {ExternalSystem}Facade $facade,
        private {ExternalSystem}Translator $translator,
    ) {}

    public function {operation}({DomainParameters}): {DomainReturnType}
    {
        $dto = $this->translator->toExternal($entity);
        $result = $this->facade->{externalOperation}($dto);
        return $this->translator->toDomain($result);
    }
}

Usage Example

// Domain port interface
interface PaymentGatewayPortInterface
{
    public function charge(Payment $payment): PaymentId;
    public function refund(PaymentId $paymentId, Money $amount): void;
}

// Adapter implementation
final readonly class StripeAdapter implements PaymentGatewayPortInterface
{
    public function charge(Payment $payment): PaymentId
    {
        $stripeCharge = $this->translator->toStripeCharge($payment);
        $result = $this->facade->createCharge($stripeCharge);
        return $this->translator->toPaymentId($result);
    }
}

Anti-patterns to Avoid

Anti-patternProblemSolution
Domain using external DTOsExternal concepts leak into domainAlways translate at ACL boundary
Translator in domain layerInfrastructure concern in domainKeep translator in infrastructure
Exposing external exceptionsCoupling to external systemWrap in domain exceptions
Direct API calls from domainNo isolationUse port/​adapter pattern
Shared DTOs across ACLsCoupling between integrationsEach ACL has own DTOs
Business logic in translatorWrong responsibilityTranslator only maps data

DI Configuration

# services.yaml
Domain\Payment\Port\PaymentGatewayPortInterface:
    alias: Infrastructure\Payment\ACL\Stripe\StripeAdapter

Infrastructure\Payment\ACL\Stripe\StripeFacade:
    arguments:
        $client: '@stripe.client'

References

For complete PHP templates and examples, see:

  • references/​templates.md — Domain Port, External DTO, Translator, Facade, Adapter, Exception templates
  • references/​examples.md — Stripe Payment Gateway ACL complete example and tests

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
Imagica logo
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View