# laravel/reverb architecture

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

- Interactive diagram: https://gitdiagram.com/laravel/reverb
- Repository: https://github.com/laravel/reverb

## Overview

Laravel Reverb provides real-time WebSocket communication for Laravel applications. The core workflow accepts a WebSocket connection, applies Pusher protocol checks and event handling, manages channel subscriptions, and sends messages through connections. It also exposes authenticated Pusher HTTP APIs and optional Redis Pub/Sub for distributed publishing, plus connection/message monitoring through Pulse and background connection maintenance. Evidence is limited to the README and sampled source/index references; unsampled subsystem links are omitted where their callers are not shown.

Main entry points: [`src/Servers/Reverb/Http/Server.php`](https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Server.php) (HTTP server and router), [`src/ReverbServiceProvider.php`](https://github.com/laravel/reverb/blob/main/src/ReverbServiceProvider.php) (Service provider), [`src/Protocols/Pusher/Server.php`](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Server.php) (Pusher WebSocket server), [`src/Protocols/Pusher/Managers/ArrayChannelManager.php`](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Managers/ArrayChannelManager.php) (Channel manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Applications and runtime"]
  node_service["Service provider"]
  node_appconfig["Application configuration"]
  node_application["Application settings<br/>[Application.php]"]
  node_servermanager["Server provider manager"]
end

subgraph group_transport["WebSocket transport"]
  node_serverprovider["Reverb server provider"]
  node_httpserver["HTTP server and router<br/>[Server.php]"]
  node_request["HTTP request<br/>[Request.php]"]
  node_socket["WebSocket connection<br/>[Connection.php]"]
  node_connection["Connection state<br/>[Connection.php]"]
end

subgraph group_protocol["Pusher protocol and channels"]
  node_pusherserver["Pusher WebSocket server<br/>[Server.php]"]
  node_eventhandler["Pusher event handler<br/>[EventHandler.php]"]
  node_clientevent["Client events<br/>[ClientEvent.php]"]
  node_channelmanager["Channel manager"]
  node_channel["Channel subscriptions<br/>[Channel.php]"]
  node_channelconnection["Channel connection data"]
end

subgraph group_api["HTTP and distribution"]
  node_httpcontrollers["Pusher HTTP API<br/>[Controller.php]"]
  node_eventsapi["Event publishing endpoints"]
  node_redis["Redis Pub/Sub"]
end

subgraph group_ops["Monitoring and maintenance"]
  node_pulse["Pulse monitoring<br/>[Connections.php]"]
  node_recorders["Pulse recorders"]
  node_maintenance["Connection maintenance"]
end

node_laravel(("Laravel application"))
node_clients(("WebSocket clients"))
node_publishers(("Application publishers"))
node_redisservice[("Redis service")]

node_laravel -->|"boots"| node_service
node_service -->|"registers"| node_servermanager
node_servermanager -->|"creates"| node_serverprovider
node_service -->|"registers"| node_appconfig
node_appconfig -->|"creates"| node_application
node_clients -.->|"opens socket"| node_httpserver
node_serverprovider -.->|"runs"| node_httpserver
node_httpserver -->|"parses"| node_request
node_httpserver -->|"routes upgrade"| node_socket
node_socket -.->|"wraps"| node_connection
node_connection -.->|"handles messages"| node_pusherserver
node_pusherserver -->|"dispatches protocol events"| node_eventhandler
node_pusherserver -->|"dispatches client events"| node_clientevent
node_pusherserver -->|"checks subscriptions"| node_channelmanager
node_channelmanager -->|"creates and manages"| node_channel
node_channel -->|"tracks subscribers"| node_channelconnection
node_httpserver -.->|"routes requests"| node_httpcontrollers
node_httpcontrollers -->|"resolves application"| node_appconfig
node_httpcontrollers -->|"selects channels"| node_channelmanager
node_publishers -.->|"publishes events"| node_eventsapi
node_eventsapi -.->|"publishes messages"| node_redis
node_redis -.->|"uses Pub/Sub"| node_redisservice
node_service -->|"registers monitoring"| node_pulse
node_pulse -->|"reads metrics"| node_recorders
node_maintenance -->|"prunes subscriptions"| node_channelmanager

click node_service "https://github.com/laravel/reverb/blob/main/src/ReverbServiceProvider.php"
click node_appconfig "https://github.com/laravel/reverb/blob/main/src/ConfigApplicationProvider.php"
click node_application "https://github.com/laravel/reverb/blob/main/src/Application.php"
click node_servermanager "https://github.com/laravel/reverb/blob/main/src/ServerProviderManager.php"
click node_serverprovider "https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/ReverbServerProvider.php"
click node_httpserver "https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Server.php"
click node_request "https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Request.php"
click node_socket "https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Connection.php"
click node_connection "https://github.com/laravel/reverb/blob/main/src/Contracts/Connection.php"
click node_pusherserver "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Server.php"
click node_eventhandler "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/EventHandler.php"
click node_clientevent "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/ClientEvent.php"
click node_channelmanager "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Managers/ArrayChannelManager.php"
click node_channel "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Channels/Channel.php"
click node_channelconnection "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Channels/ChannelConnection.php"
click node_httpcontrollers "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Http/Controllers/Controller.php"
click node_eventsapi "https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Http/Controllers/EventsController.php"
click node_redis "https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Publishing/RedisPubSubProvider.php"
click node_pulse "https://github.com/laravel/reverb/blob/main/src/Pulse/Livewire/Connections.php"
click node_recorders "https://github.com/laravel/reverb/blob/main/src/Pulse/Recorders/ReverbConnections.php"
click node_maintenance "https://github.com/laravel/reverb/blob/main/src/Jobs/PruneStaleConnections.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_service,node_appconfig,node_application,node_servermanager,node_clients toneBlue
class node_serverprovider,node_httpserver,node_request,node_socket,node_connection,node_redisservice toneAmber
class node_pusherserver,node_eventhandler,node_clientevent,node_channelmanager,node_channel,node_channelconnection toneMint
class node_httpcontrollers,node_eventsapi,node_redis toneRose
class node_pulse,node_recorders,node_maintenance,node_laravel,node_publishers toneIndigo
```

## Components

### Applications and runtime

- [Service provider](https://github.com/laravel/reverb/blob/main/src/ReverbServiceProvider.php): `src/ReverbServiceProvider.php`
- [Application configuration](https://github.com/laravel/reverb/blob/main/src/ConfigApplicationProvider.php): `src/ConfigApplicationProvider.php`
- [Application settings](https://github.com/laravel/reverb/blob/main/src/Application.php): `src/Application.php`
- [Server provider manager](https://github.com/laravel/reverb/blob/main/src/ServerProviderManager.php): `src/ServerProviderManager.php`

### WebSocket transport

- [Reverb server provider](https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/ReverbServerProvider.php): `src/Servers/Reverb/ReverbServerProvider.php`
- [HTTP server and router](https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Server.php): `src/Servers/Reverb/Http/Server.php`
- [HTTP request](https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Http/Request.php): `src/Servers/Reverb/Http/Request.php`
- [WebSocket connection](https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Connection.php): `src/Servers/Reverb/Connection.php`
- [Connection state](https://github.com/laravel/reverb/blob/main/src/Contracts/Connection.php): `src/Contracts/Connection.php`

### Pusher protocol and channels

- [Pusher WebSocket server](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Server.php): `src/Protocols/Pusher/Server.php`
- [Pusher event handler](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/EventHandler.php): `src/Protocols/Pusher/EventHandler.php`
- [Client events](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/ClientEvent.php): `src/Protocols/Pusher/ClientEvent.php`
- [Channel manager](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Managers/ArrayChannelManager.php): `src/Protocols/Pusher/Managers/ArrayChannelManager.php`
- [Channel subscriptions](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Channels/Channel.php): `src/Protocols/Pusher/Channels/Channel.php`
- [Channel connection data](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Channels/ChannelConnection.php): `src/Protocols/Pusher/Channels/ChannelConnection.php`

### HTTP and distribution

- [Pusher HTTP API](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Http/Controllers/Controller.php): `src/Protocols/Pusher/Http/Controllers/Controller.php`
- [Event publishing endpoints](https://github.com/laravel/reverb/blob/main/src/Protocols/Pusher/Http/Controllers/EventsController.php): `src/Protocols/Pusher/Http/Controllers/EventsController.php`
- [Redis Pub/Sub](https://github.com/laravel/reverb/blob/main/src/Servers/Reverb/Publishing/RedisPubSubProvider.php): `src/Servers/Reverb/Publishing/RedisPubSubProvider.php`

### Monitoring and maintenance

- [Pulse monitoring](https://github.com/laravel/reverb/blob/main/src/Pulse/Livewire/Connections.php): `src/Pulse/Livewire/Connections.php`
- [Pulse recorders](https://github.com/laravel/reverb/blob/main/src/Pulse/Recorders/ReverbConnections.php): `src/Pulse/Recorders/ReverbConnections.php`
- [Connection maintenance](https://github.com/laravel/reverb/blob/main/src/Jobs/PruneStaleConnections.php): `src/Jobs/PruneStaleConnections.php`

### Other components

- **Laravel application**
- **WebSocket clients**
- **Application publishers**
- **Redis service**

## Connections

- Laravel application → Service provider: boots (evidence: `src/ReverbServiceProvider.php`)
- Service provider → Server provider manager: registers (evidence: `src/ReverbServiceProvider.php`)
- Server provider manager → Reverb server provider: creates (evidence: `src/ServerProviderManager.php`)
- Service provider → Application configuration: registers
- Application configuration → Application settings: creates (evidence: `src/ConfigApplicationProvider.php`)
- WebSocket clients → HTTP server and router: opens socket
- Reverb server provider → HTTP server and router: runs
- HTTP server and router → HTTP request: parses (evidence: `src/Servers/Reverb/Http/Server.php`)
- HTTP server and router → WebSocket connection: routes upgrade
- WebSocket connection → Connection state: wraps
- Connection state → Pusher WebSocket server: handles messages (evidence: `src/Protocols/Pusher/Server.php`)
- Pusher WebSocket server → Pusher event handler: dispatches protocol events (evidence: `src/Protocols/Pusher/Server.php`)
- Pusher WebSocket server → Client events: dispatches client events (evidence: `src/Protocols/Pusher/Server.php`)
- Pusher WebSocket server → Channel manager: checks subscriptions (evidence: `src/Protocols/Pusher/Server.php`)
- Channel manager → Channel subscriptions: creates and manages (evidence: `src/Protocols/Pusher/Managers/ArrayChannelManager.php`)
- Channel subscriptions → Channel connection data: tracks subscribers (evidence: `src/Protocols/Pusher/Channels/Channel.php`)
- HTTP server and router → Pusher HTTP API: routes requests
- Pusher HTTP API → Application configuration: resolves application (evidence: `src/Protocols/Pusher/Http/Controllers/Controller.php`)
- Pusher HTTP API → Channel manager: selects channels (evidence: `src/Protocols/Pusher/Http/Controllers/Controller.php`)
- Application publishers → Event publishing endpoints: publishes events
- Event publishing endpoints → Redis Pub/Sub: publishes messages
- Redis Pub/Sub → Redis service: uses Pub/Sub
- Service provider → Pulse monitoring: registers monitoring (evidence: `src/ReverbServiceProvider.php`)
- Pulse monitoring → Pulse recorders: reads metrics (evidence: `src/Pulse/Livewire/Connections.php`)
- Connection maintenance → Channel manager: prunes subscriptions (evidence: `src/Jobs/PruneStaleConnections.php`)
