# generatorevil/sms-routing architecture

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

- Interactive diagram: https://gitdiagram.com/generatorevil/sms-routing
- Repository: https://github.com/generatorevil/sms-routing

## Overview

This Laravel package routes SMS notifications through country-specific or regional gateway chains, failing over in priority order. The main workflow is notification channel → manager (country resolution, route selection, rate-limit check, and dispatch) → provider gateway → normalized result; successful sends also dispatch an event. The README documents nine providers, multi-account instances, per-gateway OTP templates, and delivery events. Some manager and gateway source is excerpted only, so uncertain internal calls are omitted; provider capabilities and routing behavior are also supported by the README.

Main entry points: [`src/Gateways`](https://github.com/generatorevil/sms-routing/tree/main/src/Gateways) (Provider gateways), [`src/SmsManager.php`](https://github.com/generatorevil/sms-routing/blob/main/src/SmsManager.php) (SMS manager), [`src/Channels/SmsChannel.php`](https://github.com/generatorevil/sms-routing/blob/main/src/Channels/SmsChannel.php) (SMS channel), [`src/DTOs/SmsResultDTO.php`](https://github.com/generatorevil/sms-routing/blob/main/src/DTOs/SmsResultDTO.php) (Send result)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Notification entry"]
  node_channel["SMS channel<br/>[SmsChannel.php]"]
end

subgraph group_routing["Routing and controls"]
  node_manager["SMS manager<br/>[SmsManager.php]"]
  node_config["SMS configuration<br/>[sms.php]"]
  node_country["Country resolver"]
  node_limiter["Rate limiter<br/>[SmsRateLimiter.php]"]
  node_null_limiter["Null limiter"]
end

subgraph group_providers["Provider adapters"]
  node_provider_gateway["Provider gateways"]
  node_abstract_gateway["Gateway base"]
  node_clients["Provider clients"]
  node_smsc_client["SMSC client<br/>[SmscClient.php]"]
  node_botto_client["Botto client<br/>[BottoClient.php]"]
  node_karix_client["Karix client<br/>[KarixClient.php]"]
  node_laaffic_client["Laaffic client<br/>[LaafficClient.php]"]
  node_sigma_client["SigmaSMS client<br/>[SigmaSmsClient.php]"]
  node_smsfly_client["SMSFly client<br/>[SmsFlyClient.php]"]
end

subgraph group_delivery["Results and events"]
  node_result["Send result<br/>[SmsResultDTO.php]"]
  node_event["Delivery event<br/>[SmsSent.php]"]
end

node_app(("Laravel application"))
node_external_providers{{"SMS providers"}}

node_app -->|"sends notification"| node_channel
node_channel -->|"delegates send"| node_manager
node_manager -->|"resolves country"| node_country
node_manager -->|"reads routes"| node_config
node_manager -->|"checks and records"| node_limiter
node_limiter -->|"defaults to"| node_null_limiter
node_manager -->|"dispatches chain"| node_provider_gateway
node_provider_gateway -->|"extends base"| node_abstract_gateway
node_provider_gateway -->|"uses clients"| node_clients
node_provider_gateway -->|"calls send"| node_smsc_client
node_provider_gateway -->|"uses client"| node_botto_client
node_provider_gateway -->|"uses client"| node_karix_client
node_provider_gateway -->|"uses client"| node_laaffic_client
node_provider_gateway -->|"uses client"| node_sigma_client
node_manager -.->|"dispatches SMSFly"| node_smsfly_client
node_provider_gateway -->|"sends SMS"| node_external_providers
node_provider_gateway -->|"returns result"| node_result
node_manager -.->|"returns outcome"| node_result
node_channel -->|"dispatches success event"| node_event
node_event -->|"carries result"| node_result

click node_channel "https://github.com/generatorevil/sms-routing/blob/main/src/Channels/SmsChannel.php"
click node_manager "https://github.com/generatorevil/sms-routing/blob/main/src/SmsManager.php"
click node_config "https://github.com/generatorevil/sms-routing/blob/main/config/sms.php"
click node_country "https://github.com/generatorevil/sms-routing/blob/main/src/PhoneCountryResolver.php"
click node_limiter "https://github.com/generatorevil/sms-routing/blob/main/src/Contracts/SmsRateLimiter.php"
click node_null_limiter "https://github.com/generatorevil/sms-routing/blob/main/src/RateLimit/NullSmsRateLimiter.php"
click node_provider_gateway "https://github.com/generatorevil/sms-routing/tree/main/src/Gateways"
click node_abstract_gateway "https://github.com/generatorevil/sms-routing/blob/main/src/Gateways/AbstractSmsGateway.php"
click node_clients "https://github.com/generatorevil/sms-routing/tree/main/src/Clients"
click node_smsc_client "https://github.com/generatorevil/sms-routing/blob/main/src/Clients/SmscClient.php"
click node_botto_client "https://github.com/generatorevil/sms-routing/blob/main/src/Clients/BottoClient.php"
click node_karix_client "https://github.com/generatorevil/sms-routing/blob/main/src/Clients/KarixClient.php"
click node_laaffic_client "https://github.com/generatorevil/sms-routing/blob/main/src/Clients/LaafficClient.php"
click node_sigma_client "https://github.com/generatorevil/sms-routing/blob/main/src/Clients/SigmaSmsClient.php"
click node_smsfly_client "https://github.com/generatorevil/sms-routing/blob/main/src/Clients/SmsFlyClient.php"
click node_result "https://github.com/generatorevil/sms-routing/blob/main/src/DTOs/SmsResultDTO.php"
click node_event "https://github.com/generatorevil/sms-routing/blob/main/src/Events/SmsSent.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_channel toneBlue
class node_manager,node_config,node_country,node_limiter,node_null_limiter toneAmber
class node_provider_gateway,node_abstract_gateway,node_clients,node_smsc_client,node_botto_client,node_karix_client,node_laaffic_client,node_sigma_client,node_smsfly_client toneMint
class node_result,node_event toneRose
class node_app,node_external_providers toneIndigo
```

## Components

### Notification entry

- [SMS channel](https://github.com/generatorevil/sms-routing/blob/main/src/Channels/SmsChannel.php): `src/Channels/SmsChannel.php`

### Routing and controls

- [SMS manager](https://github.com/generatorevil/sms-routing/blob/main/src/SmsManager.php): `src/SmsManager.php`
- [SMS configuration](https://github.com/generatorevil/sms-routing/blob/main/config/sms.php): `config/sms.php`
- [Country resolver](https://github.com/generatorevil/sms-routing/blob/main/src/PhoneCountryResolver.php): `src/PhoneCountryResolver.php`
- [Rate limiter](https://github.com/generatorevil/sms-routing/blob/main/src/Contracts/SmsRateLimiter.php): `src/Contracts/SmsRateLimiter.php`
- [Null limiter](https://github.com/generatorevil/sms-routing/blob/main/src/RateLimit/NullSmsRateLimiter.php): `src/RateLimit/NullSmsRateLimiter.php`

### Provider adapters

- [Provider gateways](https://github.com/generatorevil/sms-routing/tree/main/src/Gateways): `src/Gateways`
- [Gateway base](https://github.com/generatorevil/sms-routing/blob/main/src/Gateways/AbstractSmsGateway.php): `src/Gateways/AbstractSmsGateway.php`
- [Provider clients](https://github.com/generatorevil/sms-routing/tree/main/src/Clients): `src/Clients`
- [SMSC client](https://github.com/generatorevil/sms-routing/blob/main/src/Clients/SmscClient.php): `src/Clients/SmscClient.php`
- [Botto client](https://github.com/generatorevil/sms-routing/blob/main/src/Clients/BottoClient.php): `src/Clients/BottoClient.php`
- [Karix client](https://github.com/generatorevil/sms-routing/blob/main/src/Clients/KarixClient.php): `src/Clients/KarixClient.php`
- [Laaffic client](https://github.com/generatorevil/sms-routing/blob/main/src/Clients/LaafficClient.php): `src/Clients/LaafficClient.php`
- [SigmaSMS client](https://github.com/generatorevil/sms-routing/blob/main/src/Clients/SigmaSmsClient.php): `src/Clients/SigmaSmsClient.php`
- [SMSFly client](https://github.com/generatorevil/sms-routing/blob/main/src/Clients/SmsFlyClient.php): `src/Clients/SmsFlyClient.php`

### Results and events

- [Send result](https://github.com/generatorevil/sms-routing/blob/main/src/DTOs/SmsResultDTO.php): `src/DTOs/SmsResultDTO.php`
- [Delivery event](https://github.com/generatorevil/sms-routing/blob/main/src/Events/SmsSent.php): `src/Events/SmsSent.php`

### Other components

- **Laravel application**
- **SMS providers**

## Connections

- Laravel application → SMS channel: sends notification (evidence: `README.md`)
- SMS channel → SMS manager: delegates send (evidence: `src/Channels/SmsChannel.php`)
- SMS manager → Country resolver: resolves country (evidence: `src/SmsManager.php`)
- SMS manager → SMS configuration: reads routes (evidence: `README.md`)
- SMS manager → Rate limiter: checks and records (evidence: `src/SmsManager.php`)
- Rate limiter → Null limiter: defaults to (evidence: `src/SmsRoutingServiceProvider.php`)
- SMS manager → Provider gateways: dispatches chain (evidence: `src/SmsManager.php`)
- Provider gateways → Gateway base: extends base (evidence: `src/Gateways/SmscGateway.php`)
- Provider gateways → Provider clients: uses clients (evidence: `src/Gateways/BottoGateway.php`)
- Provider gateways → SMSC client: calls send (evidence: `src/Gateways/SmscGateway.php`)
- Provider gateways → Botto client: uses client (evidence: `src/Gateways/BottoGateway.php`)
- Provider gateways → Karix client: uses client (evidence: `src/Gateways/KarixGateway.php`)
- Provider gateways → Laaffic client: uses client (evidence: `src/Gateways/LaafficGateway.php`)
- Provider gateways → SigmaSMS client: uses client (evidence: `src/Gateways/SigmasmsGateway.php`)
- SMS manager → SMSFly client: dispatches SMSFly
- Provider gateways → SMS providers: sends SMS (evidence: `README.md`)
- Provider gateways → Send result: returns result (evidence: `src/Gateways/SmscGateway.php`)
- SMS manager → Send result: returns outcome (evidence: `src/SmsManager.php`)
- SMS channel → Delivery event: dispatches success event (evidence: `src/Channels/SmsChannel.php`)
- Delivery event → Send result: carries result (evidence: `src/Events/SmsSent.php`)
