Feature Module Dependency Inversion Leak
A React Native feature module quietly couples its domain logic to a concrete infrastructure class, breaking the architectural boundary.
Codetypescript
// features/cart/domain/CartService.ts
import { StripePaymentApi } from '../../payment/infrastructure/StripePaymentApi';
export interface PaymentGateway {
charge(amount: number): Promise<void>;
}
export class CartService {
private readonly payment: PaymentGateway;
// Domain service accepts an abstraction so it can be tested/swapped
constructor(payment: PaymentGateway = new StripePaymentApi()) {
this.payment = payment;
}
async checkout(total: number): Promise<void> {
if (total <= 0) throw new Error('Invalid total');
await this.payment.charge(total);
}
}This domain service is meant to depend only on abstractions. What breaks the layered/modular architecture here?