← All articles

Architecture · 1 min read · Sample draft

Domain-Driven Design beyond the theory

Making business rules explicit in everyday code.

Start with business rules

A folder structure is not a domain model. Begin with business language, invariants and boundaries.

An aggregate in practice

An order controls which changes are allowed after confirmation. The application service coordinates the operation while the domain owns the rule.

public function confirm(): void
{
    if ($this->items->isEmpty()) {
        throw new DomainException('Order cannot be empty.');
    }
    $this->status = OrderStatus::Confirmed;
}
Architecture explorer · select a layer
↓↓↑ implements ports

Select a layer to explore its responsibilities.

Takeaways

Model invariants explicitly and keep dependencies intentional.