# khanalbishnu333/multi-tenant-notification-system architecture

> Architecture diagram of the GitHub repository khanalbishnu333/multi-tenant-notification-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khanalbishnu333/multi-tenant-notification-system
- Repository: https://github.com/khanalbishnu333/multi-tenant-notification-system

## Overview

This Laravel application accepts tenant-scoped notification requests, persists notification and recipient state, records lifecycle events, then queues delivery for immediate or scheduled processing. The worker expands tenant-wide broadcasts or delivers to targeted recipients through a channel strategy, updating statuses and emitting outcome events. The API also exposes filtered history, cached summaries, timelines, and recipient status. The graph follows shown controller, service, repository, and job calls; channel implementations and some supporting wiring are represented from the README and SOURCE INDEX, which does not expose every connection.

Main entry points: [`app/Http/Controllers/Api/NotificationController.php`](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Controllers/Api/NotificationController.php) (Notification API), [`app/Jobs/ProcessNotificationJob.php`](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Jobs/ProcessNotificationJob.php) (Delivery job), [`app/Services/NotificationService.php`](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/NotificationService.php) (Notification service), [`app/Repositories/NotificationRepository.php`](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Repositories/NotificationRepository.php) (Notification repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and orchestration"]
  node_controller["Notification API"]
  node_request["Request validation"]
  node_dto["Notification DTO"]
  node_service["Notification service"]
  node_limiter["Rate limiter"]
  node_middleware["Throttle middleware"]
  node_resource["API resources"]
  node_eventresource["Timeline resource"]
  node_recipientresource["Recipient resource"]
end

subgraph group_delivery["Queued delivery"]
  node_job["Delivery job"]
  node_manager["Channel manager<br/>[ChannelManager.php]"]
  node_email["Email channel<br/>[EmailChannel.php]"]
  node_sms["SMS channel<br/>[SmsChannel.php]"]
  node_push["Push channel<br/>[PushChannel.php]"]
  node_sent["Sent event"]
  node_failed["Failed event"]
end

subgraph group_records["Notification records"]
  node_repo["Notification repository"]
  node_notification[("Notification records<br/>[Notification.php]")]
  node_recipients[("Recipient records")]
  node_eventservice["Event service"]
  node_events[("Audit events")]
end

subgraph group_tenancy["Tenant access"]
  node_user[("Tenant users<br/>[User.php]")]
  node_tenant[("Tenant<br/>[Tenant.php]")]
end

node_client(("API client"))

node_client -->|"calls API"| node_controller
node_controller -->|"validates with"| node_request
node_controller -->|"resolves UUIDs"| node_user
node_controller -->|"builds"| node_dto
node_controller -->|"delegates"| node_service
node_controller -->|"formats responses"| node_resource
node_controller -->|"formats timeline"| node_eventresource
node_controller -->|"formats recipients"| node_recipientresource
node_service -->|"persists and queries"| node_repo
node_service -->|"records queued event"| node_eventservice
node_service -->|"dispatches"| node_job
node_repo -->|"creates and queries"| node_notification
node_repo -->|"attaches recipients"| node_recipients
node_eventservice -->|"records timeline"| node_events
node_job -->|"updates status"| node_repo
node_job -->|"records delivery events"| node_eventservice
node_job -->|"resolves channel"| node_manager
node_job -->|"loads broadcast users"| node_user
node_job -->|"dispatches on success"| node_sent
node_job -->|"dispatches on failure"| node_failed
node_manager -->|"resolves"| node_email
node_manager -->|"resolves"| node_sms
node_manager -->|"resolves"| node_push
node_job -->|"updates delivery status"| node_recipients
node_user -->|"belongs to"| node_tenant
node_middleware -->|"checks limits"| node_limiter
node_controller -.->|"throttled by"| node_middleware
node_service -->|"reads summaries and history"| node_repo
node_controller -->|"requests timeline"| node_eventservice

click node_controller "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Controllers/Api/NotificationController.php"
click node_request "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Requests/CreateNotificationRequest.php"
click node_dto "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/DTOs/NotificationDTO.php"
click node_service "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/NotificationService.php"
click node_limiter "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/RateLimiterService.php"
click node_middleware "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Middleware/CustomRateLimitMiddleware.php"
click node_job "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Jobs/ProcessNotificationJob.php"
click node_manager "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/ChannelManager.php"
click node_email "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/EmailChannel.php"
click node_sms "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/SmsChannel.php"
click node_push "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/PushChannel.php"
click node_repo "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Repositories/NotificationRepository.php"
click node_notification "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/Notification.php"
click node_recipients "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/NotificationRecipient.php"
click node_eventservice "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/NotificationEventService.php"
click node_events "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/NotificationEvent.php"
click node_sent "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Events/NotificationSent.php"
click node_failed "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Events/NotificationFailed.php"
click node_user "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/User.php"
click node_tenant "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/Tenant.php"
click node_resource "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Resources/NotificationResource.php"
click node_eventresource "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Resources/NotificationEventResource.php"
click node_recipientresource "https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Resources/RecipientStatusResource.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controller,node_request,node_dto,node_service,node_limiter,node_middleware,node_resource,node_eventresource,node_recipientresource,node_client toneBlue
class node_job,node_manager,node_email,node_sms,node_push,node_sent,node_failed toneAmber
class node_repo,node_notification,node_recipients,node_eventservice,node_events toneMint
class node_user,node_tenant toneRose
```

## Components

### API and orchestration

- [Notification API](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Controllers/Api/NotificationController.php): `app/Http/Controllers/Api/NotificationController.php`
- [Request validation](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Requests/CreateNotificationRequest.php): `app/Http/Requests/CreateNotificationRequest.php`
- [Notification DTO](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/DTOs/NotificationDTO.php): `app/DTOs/NotificationDTO.php`
- [Notification service](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/NotificationService.php): `app/Services/NotificationService.php`
- [Rate limiter](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/RateLimiterService.php): `app/Services/RateLimiterService.php`
- [Throttle middleware](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Middleware/CustomRateLimitMiddleware.php): `app/Http/Middleware/CustomRateLimitMiddleware.php`
- [API resources](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Resources/NotificationResource.php): `app/Http/Resources/NotificationResource.php`
- [Timeline resource](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Resources/NotificationEventResource.php): `app/Http/Resources/NotificationEventResource.php`
- [Recipient resource](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Http/Resources/RecipientStatusResource.php): `app/Http/Resources/RecipientStatusResource.php`

### Queued delivery

- [Delivery job](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Jobs/ProcessNotificationJob.php): `app/Jobs/ProcessNotificationJob.php`
- [Channel manager](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/ChannelManager.php): `app/Notifications/Channels/ChannelManager.php`
- [Email channel](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/EmailChannel.php): `app/Notifications/Channels/EmailChannel.php`
- [SMS channel](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/SmsChannel.php): `app/Notifications/Channels/SmsChannel.php`
- [Push channel](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Notifications/Channels/PushChannel.php): `app/Notifications/Channels/PushChannel.php`
- [Sent event](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Events/NotificationSent.php): `app/Events/NotificationSent.php`
- [Failed event](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Events/NotificationFailed.php): `app/Events/NotificationFailed.php`

### Notification records

- [Notification repository](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Repositories/NotificationRepository.php): `app/Repositories/NotificationRepository.php`
- [Notification records](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/Notification.php): `app/Models/Notification.php`
- [Recipient records](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/NotificationRecipient.php): `app/Models/NotificationRecipient.php`
- [Event service](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Services/NotificationEventService.php): `app/Services/NotificationEventService.php`
- [Audit events](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/NotificationEvent.php): `app/Models/NotificationEvent.php`

### Tenant access

- [Tenant users](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/User.php): `app/Models/User.php`
- [Tenant](https://github.com/khanalbishnu333/multi-tenant-notification-system/blob/main/app/Models/Tenant.php): `app/Models/Tenant.php`

### Other components

- **API client**

## Connections

- API client → Notification API: calls API
- Notification API → Request validation: validates with (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification API → Tenant users: resolves UUIDs (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification API → Notification DTO: builds (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification API → Notification service: delegates (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification API → API resources: formats responses (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification API → Timeline resource: formats timeline (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification API → Recipient resource: formats recipients (evidence: `app/Http/Controllers/Api/NotificationController.php`)
- Notification service → Notification repository: persists and queries (evidence: `app/Services/NotificationService.php`)
- Notification service → Event service: records queued event (evidence: `app/Services/NotificationService.php`)
- Notification service → Delivery job: dispatches (evidence: `app/Services/NotificationService.php`)
- Notification repository → Notification records: creates and queries (evidence: `app/Repositories/NotificationRepository.php`)
- Notification repository → Recipient records: attaches recipients (evidence: `app/Repositories/NotificationRepository.php`)
- Event service → Audit events: records timeline (evidence: `app/Services/NotificationEventService.php`)
- Delivery job → Notification repository: updates status (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Delivery job → Event service: records delivery events (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Delivery job → Channel manager: resolves channel (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Delivery job → Tenant users: loads broadcast users (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Delivery job → Sent event: dispatches on success (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Delivery job → Failed event: dispatches on failure (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Channel manager → Email channel: resolves (evidence: `app/Notifications/Channels/ChannelManager.php`)
- Channel manager → SMS channel: resolves (evidence: `app/Notifications/Channels/ChannelManager.php`)
- Channel manager → Push channel: resolves (evidence: `app/Notifications/Channels/ChannelManager.php`)
- Delivery job → Recipient records: updates delivery status (evidence: `app/Jobs/ProcessNotificationJob.php`)
- Tenant users → Tenant: belongs to (evidence: `app/Models/User.php`)
- Throttle middleware → Rate limiter: checks limits (evidence: `app/Http/Middleware/CustomRateLimitMiddleware.php`)
- Notification API → Throttle middleware: throttled by
- Notification service → Notification repository: reads summaries and history (evidence: `app/Services/NotificationService.php`)
- Notification API → Event service: requests timeline (evidence: `app/Http/Controllers/Api/NotificationController.php`)
