DDD

Primary/Driving = Presentation Layer [ui,api,cli]

Secondary/Driven = Infrastructure Layer [Data access, email, message queue]

Hexagonal Arch = Ports and Adapters

ports (interfaces) | adapters (implementations)

image.png

image.png

├── app/
│   ├── ports/              # Interfaces for interacting with the core logic
│   ├── adapters/           # Implementations of ports (e.g., database, API adapters)
│   ├── domain/             # Core business logic (data models / classes)
│   ├── src/                # Additional core functionality

ONION ARCHITECTURE

https://herbertograca.com/2017/09/21/onion-architecture/

├── src/
│   ├── application/services    # Interfaces for interacting with the core logic
│   ├── domain/models           # Core business logic (data models / classes)
│   ├── infra/database          # Implementations of ports (e.g., database, API adapters)
│   ├── presentation/api        # API and UI

image.png

image.png

image.png

image.png

onion-architecture.png

💡 Rule of Thumb