A production-grade Laravel modular monolith demonstrating Domain-Driven Design, Clean Architecture, Hexagonal Architecture, and Enterprise Patterns. Designed for scalability, maintainability, testability, and developer experience.
- Bounded Contexts β Isolated modules: Users, Workspace, Notifications
- Domain-Driven Design β Rich domain models, value objects, domain events
- Clean/Hexagonal Architecture β Separation of concerns across layers
- Vertical Slice Architecture β Features organized by business capability
- Test-Driven Development β Comprehensive unit, feature, and integration tests
Each module follows the same architectural pattern:
Module/
βββ Application/ # Use cases, services, DTOs, commands
βββ Domain/ # Entities, value objects, domain events, enums, repositories
βββ Infrastructure/ # Persistence (Eloquent), jobs, listeners, caching, policies
βββ Presentation/ # API controllers, routes, resources, requests- Entities & Value Objects β Immutable domain models with business invariants
- Repository Pattern β Interface-based data access with Eloquent implementation
- Domain Events β Event-driven communication within and across modules
- Application Services β Orchestration of use cases with transaction boundaries
- Policies & Gates β Fine-grained authorization
- Jobs & Queues β Asynchronous processing (e.g., notifications, file processing)
- OpenAPI / Swagger β Auto-generated API documentation
- Users β Authentication, authorization, roles & permissions (Spatie)
- Workspace β Projects, tasks, comments, attachments, real-time events
- Notifications β Multi-channel notifications, queued delivery
- Docker & Docker Compose
- Git
git clone https://github.com/farid-labs/modular-architecture-laravel.git
cd modular-architecture-laravel
# Copy environment file
cp .env.example .env
# Start all services
docker compose up -d --build
# Install PHP dependencies
docker compose exec app composer install --optimize-autoloader --no-dev
# Generate application key
docker compose exec app php artisan key:generate
# Run migrations and seed test data
docker compose exec app php artisan migrate:fresh --seed
# (Optional) Generate API documentation
docker compose exec app php artisan l5-swagger:generate
Application will be available at: http://localhost:8080
{
"email": "admin@faridlabs.com",
"password": "password"
}API Base URL: http://localhost:8080/api/v1
Swagger Docs: http://localhost:8080/api/documentation
# Run all tests
docker compose exec app php artisan test
# Run specific module tests
docker compose exec app php artisan test --filter=Workspace
# Run only unit tests
docker compose exec app php artisan test --testsuite=Unit
# Run only feature/API tests
docker compose exec app php artisan test --testsuite=Feature
# Run with code coverage (HTML report in storage/logs/coverage)
docker compose exec app php artisan test --coverage-html storage/logs/coverage- PHPStan β Level 8 static analysis
- Laravel Pint β Code style fixer (PSR-12)
- PHPUnit β Unit & feature testing
- PHP_CodeSniffer β Enforce coding standards
- Larastan β PHPStan integration for Laravel
Run full quality check PHPStan:
docker compose exec app vendor/bin/phpstan analyse -vv- Sanctum API authentication
- Rate limiting on all endpoints
- Policy-based authorization
- Secure password hashing (bcrypt/argon2)
- Input validation & sanitization
- CSRF & XSS protection
- Redis caching (query & response level)
- Eager loading & query optimization
- Async jobs & queued notifications
- Database indexing on foreign keys
- Response compression (Gzip/Brotli)
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open Pull Request Please follow Conventional Commits:
feat: new featurefix: bug fixrefactor: code restructuringtest: adding/updating testsdocs: documentation changeschore: maintenance tasks
MIT License - see LICENSE file for details
Engineering-focused open-source repositories exploring scalable architectures, modern PHP practices, and enterprise patterns.
π Portfolio: https://faridteymouri.vercel.app/
Built with precision and care for long-term maintainability.