Laravel Modular Monolith
A professional architectural boilerplate for building scalable Enterprise Systems using Domain-Driven Design (DDD), Hexagonal Architecture, and Clean Architecture.
HTTP Request
│
▼
[Controller] (Presentation Layer)
│
│ (DTO)
▼
[UseCase] (Application Layer) ────┬──────> [Domain Event]
│ │
│ (Direct Call) │ (Async Side Effect)
│ │
▼ ▼
[Domain Service] [Listener]
(Reader/Writer) │
│ │
▼ ▼
[Entity & Factory] [Adapter] ──> [External Module]
(Rich Model) │
│ │
▼ │
[Repository] ───────────────────────────┘
│
▼
[Database]
Core Architectural Concepts
High Cohesion
All code related to a specific business task (e.g., "Reservation") resides in one place (Domain). No scattering of logic across generic folders.
Low Coupling
Modules are unaware of each other's internals and communicate only through stable contracts (Ports). Direct database joins between modules are forbidden.
Rich Domain Model
Business logic is encapsulated in Entities and Domain Services, not in Anemic Models or massive Controllers.
Strict Isolation
Each module has its own internal structure (DTOs, Actions, Repositories) and exposes only a clean Public API.
Project Structure
I moved away from the standard Laravel structure (app/Http, app/Models) in favor of domain grouping.
app/
├── Core/ # Shared Kernel: Base classes, System components
│ ├── Database/Eloquent/Entity.php # Base class for all models (UUID support)
│ ├── Exceptions/ # Marker Exception Interfaces
│ └── Http/ # Shared Request/Response classes
│
└── Domains/ # Isolated business modules
├── Common/ # Shared components for domains
│
├── Auth/ # Authentication Module
│ ├── Contracts/ # Ports (Interfaces) for other modules
│ └── ...
│
├── User/ # Users Module
│ ├── Adapters/ # Port implementations
│ └── ...
│
├── Reservation/ # Reservation Module
│ ├── DTOs/ # Data Transfer Objects
│ ├── Entities/ # Rich Domain Models
│ ├── Events/ # Domain Events
│ ├── Factories/ # Factories
│ ├── Http/ # Presentation (Controllers, Resources)
│ ├── Listeners/ # Event Listeners
│ ├── Repositories/ # Strict Repositories
│ ├── UseCases/ # Orchestrators
│ └── routes.php # Routes