Skip to content

Core Concepts

Architectural foundations of the Phexium framework.

In This Section

Architecture Layers

Phexium implements Clean Architecture with four layers:

Layer Responsibility Dependencies
Domain Business rules, entities, value objects None
Application Use cases, commands, queries, handlers Domain
Infrastructure Persistence, external services Domain, Application
Presentation HTTP, templates, API responses Application

Dependencies point inward: outer layers depend on inner layers, never the reverse.

Key Patterns

CQRS separates write operations (Commands) from read operations (Queries). Commands modify state, queries retrieve data.

Port & Adapter abstracts infrastructure behind interfaces. The application depends on Ports (interfaces); Adapters (implementations) are injected via DI container.

Domain Events capture facts that occurred in the domain. Handlers publish events after state changes; listeners react to events for side effects.