Multi-channel notification service built with Laravel.
The codebase follows a layered architecture with clear separation of concerns.
Service Layer — Business logic lives in NotificationService, not controllers. The ChannelManager uses a manager pattern (similar to Laravel's CacheManager) so adding new channels only requires implementing ChannelInterface.
Filter System — Query filtering uses a composable FiltersAbstract base. Each filter (SearchFilter, StatusFilter, etc.) handles one concern. Filters support fallback behavior when parameters aren't provided.
Queue Handling — Bulk sends go through SendBulkNotificationJob with chunked processing (100/batch) to avoid memory issues. Retry logic built-in: 3 attempts with 60s backoff.
Events — NotificationSent and NotificationFailed events fire after each send attempt. Listeners handle logging, keeping the service focused on delivery.
Request Validation — FormRequests handle validation with a payload() helper for clean data access. Channel validation uses Rule::in() against allowed channels.
API Resources — Responses use SubscriberResource and NotificationResource for consistent formatting. Collections handle pagination meta automatically.
Database — Composite indexes on (subscriber_id, status), (channel, status), and (status, created_at) for common query patterns.
composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan serveBase URL: /api/v1
Subscribers
GET /subscribers— supports?s=,?status=,?channel=,?sort=POST /subscribersGET /subscribers/{id}PUT /subscribers/{id}DELETE /subscribers/{id}(soft delete)
Notifications
GET /notificationsPOST /notifications/sendGET /notifications/{id}GET /notifications/channels
Send Example
{
"subscriber_ids": [1, 2, 3],
"subject": "Hello",
"message": "Content here",
"channel": "mail",
"queue": true
}php artisan test34 tests covering service layer, queue jobs, and API endpoints.
mail— Laravel Maillog— debug/testing