Architecture Analysis
Phexium uses Deptrac to enforce Clean Architecture principles by analyzing dependencies between layers. Configuration is in deptrac.yaml.
Running Analysis
A successful output shows no violations:
----------- -----------------------------------
Reason app/demo
----------- -----------------------------------
Allowed 1205
Warnings 0
Errors 0
----------- -----------------------------------
Layer Hierarchy
Dependencies flow inward following Clean Architecture:
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.yamlchanges carefully
See Also
- Clean Architecture - Layer principles enforced by Deptrac
- Repository Interfaces - Common violation example