CtrlK
BlogDocsLog inGet started
Tessl Logo

pantheon-ai/design-principles

Strategic architecture, tactical design, and testable code principles (SOLID, Clean Architecture, Design Patterns, Testable Design)

97

Quality

97%

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdclean-architecture/evals/scenario-4/

Resolve a Circular Dependency

Problem Description

A TypeScript monorepo has two modules with a circular import error:

src/modules/payments/payment-service.ts

import { NotificationService } from '../notifications/notification-service';

export class PaymentService {
  private notifier = new NotificationService();

  async processPayment(userId: string, amount: number): Promise<void> {
    // ... process payment
    await this.notifier.sendPaymentConfirmation(userId, amount);
  }
}

src/modules/notifications/notification-service.ts

import { PaymentService } from '../payments/payment-service';

export class NotificationService {
  private paymentService = new PaymentService();

  async sendPaymentConfirmation(userId: string, amount: number): Promise<void> {
    const history = await this.paymentService.getHistory(userId);
    // format and send notification with history
  }
}

The circular import is: PaymentServiceNotificationServicePaymentService.

Produce:

  1. A corrected module structure that eliminates the circular dependency (you can create new files as needed)
  2. A REFACTOR.md explaining the root cause and the approach taken to break the cycle

clean-architecture

evals

instructions.json

summary_infeasible.json

summary.json

SKILL.md

tile.json