Skip to content

Architecture Analysis

Phexium uses Deptrac to enforce Clean Architecture principles by analyzing dependencies between layers. Configuration is in deptrac.yaml.

Running Analysis

task deptrac:analyse

A successful output shows no violations:

 ----------- -----------------------------------
  Reason      app/demo
 ----------- -----------------------------------
  Allowed     1205
  Warnings    0
  Errors      0
 ----------- -----------------------------------

Layer Hierarchy

Dependencies flow inward following Clean Architecture:

Presentation → Application → Domain
Infrastructure → Application → Domain

Common Violations

Domain Importing Application

// VIOLATION
namespace App\Library\Domain\Entity;
use App\Library\Application\Service\SomeService;  // Forbidden

Fix: Domain should only depend on interfaces (Ports).

Application Importing Infrastructure

// VIOLATION
namespace App\Library\Application\Command;
use App\Library\Infrastructure\SqliteBookRepository;  // Forbidden

Fix: Depend on BookRepositoryInterface from Domain layer.

Best Practices

  • Run before every commit
  • Fix violations immediately
  • Don't add exceptions without team discussion
  • Review deptrac.yaml changes carefully

See Also