Skip to content

Repository files navigation

Notify API

Multi-channel notification service built with Laravel.

Architecture

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.

Setup

composer install
cp .env.example .env
php artisan key:generate
php artisan migrate
php artisan serve

API

Base URL: /api/v1

Subscribers

  • GET /subscribers — supports ?s=, ?status=, ?channel=, ?sort=
  • POST /subscribers
  • GET /subscribers/{id}
  • PUT /subscribers/{id}
  • DELETE /subscribers/{id} (soft delete)

Notifications

  • GET /notifications
  • POST /notifications/send
  • GET /notifications/{id}
  • GET /notifications/channels

Send Example

{
    "subscriber_ids": [1, 2, 3],
    "subject": "Hello",
    "message": "Content here",
    "channel": "mail",
    "queue": true
}

Tests

php artisan test

34 tests covering service layer, queue jobs, and API endpoints.

Channels

  • mail — Laravel Mail
  • log — debug/testing

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages