Core Concepts
Architectural foundations of the Phexium framework.
In This Section
- Clean Architecture - Layer separation and dependency rules
- CQRS - Command Query Responsibility Segregation
- Domain-Driven Design - Entities, Value Objects, Aggregates
- Event-Driven Architecture - Domain events and listeners
- Port & Adapter - Plugin system pattern
- SOLID Principles - Object-oriented design guidelines
- Clean Code - KISS, DRY, YAGNI principles
- Copy-Based Distribution - Framework ownership and customization
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.