# spatie/laravel-honeypot architecture

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

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

## Overview

Laravel Honeypot prevents form spam by rendering hidden fields, then checking submitted values and an encrypted timestamp in middleware. The package also supports Blade directives/components, manual Inertia field data, and Livewire protection. The graph follows the sampled implementation and README; unsampled middleware and Livewire behavior is represented only where the source index or documentation supports the relationship.

Main entry points: [`src/HoneypotServiceProvider.php`](https://github.com/spatie/laravel-honeypot/blob/main/src/HoneypotServiceProvider.php) (Service Provider), [`src/SpamProtection.php`](https://github.com/spatie/laravel-honeypot/blob/main/src/SpamProtection.php) (Spam Checks), [`src/Honeypot.php`](https://github.com/spatie/laravel-honeypot/blob/main/src/Honeypot.php) (Field Settings), [`src/ProtectAgainstSpam.php`](https://github.com/spatie/laravel-honeypot/blob/main/src/ProtectAgainstSpam.php) (Spam Middleware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_setup["Package Setup"]
  node_service_provider["Service Provider"]
  node_configuration["Honeypot Config<br/>[honeypot.php]"]
end

subgraph group_fields["Field Generation"]
  node_honeypot["Field Settings<br/>[Honeypot.php]"]
  node_encrypted_time["Encrypted Timestamp<br/>[EncryptedTime.php]"]
end

subgraph group_protection["Spam Protection"]
  node_middleware["Spam Middleware"]
  node_spam_checks["Spam Checks<br/>[SpamProtection.php]"]
  node_spam_exception["Spam Exception<br/>[SpamException.php]"]
  node_invalid_timestamp["Invalid Timestamp"]
  node_spam_event["Spam Event"]
  node_responder["Spam Responder<br/>[SpamResponder.php]"]
  node_blank_responder["Blank Page Responder"]
end

subgraph group_integrations["Framework Integrations"]
  node_blade_component["Blade Component"]
  node_view_composer["View Composer"]
  node_field_template["Hidden Field Template"]
  node_livewire_data["Livewire Field Data<br/>[HoneypotData.php]"]
  node_livewire_protection["Livewire Protection"]
  node_inertia["Inertia View"]
end

node_form_user(("Form Author"))
node_submission(("Form Submission"))

node_service_provider -->|"binds from"| node_configuration
node_service_provider -->|"binds"| node_honeypot
node_service_provider -->|"binds"| node_responder
node_service_provider -->|"binds"| node_spam_checks
node_service_provider -->|"registers"| node_blade_component
node_service_provider -->|"registers"| node_view_composer
node_form_user -->|"adds fields"| node_blade_component
node_blade_component -->|"uses settings"| node_honeypot
node_blade_component -->|"renders"| node_field_template
node_view_composer -->|"reads settings"| node_honeypot
node_view_composer -->|"provides fields"| node_field_template
node_honeypot -->|"creates timestamp"| node_encrypted_time
node_form_user -->|"passes field data"| node_inertia
node_livewire_data -->|"generates fields"| node_honeypot
node_submission -->|"submits form"| node_middleware
node_middleware -->|"checks request"| node_spam_checks
node_spam_checks -->|"validates timestamp"| node_encrypted_time
node_encrypted_time -->|"throws on invalid"| node_invalid_timestamp
node_spam_checks -->|"throws on spam"| node_spam_exception
node_middleware -->|"dispatches"| node_spam_event
node_middleware -->|"responds to spam"| node_responder
node_blank_responder -->|"implements"| node_responder
node_livewire_protection -->|"uses checks"| node_spam_checks
node_livewire_protection -->|"uses field data"| node_livewire_data

click node_service_provider "https://github.com/spatie/laravel-honeypot/blob/main/src/HoneypotServiceProvider.php"
click node_configuration "https://github.com/spatie/laravel-honeypot/blob/main/config/honeypot.php"
click node_honeypot "https://github.com/spatie/laravel-honeypot/blob/main/src/Honeypot.php"
click node_encrypted_time "https://github.com/spatie/laravel-honeypot/blob/main/src/EncryptedTime.php"
click node_blade_component "https://github.com/spatie/laravel-honeypot/blob/main/src/View/HoneypotComponent.php"
click node_view_composer "https://github.com/spatie/laravel-honeypot/blob/main/src/View/HoneypotViewComposer.php"
click node_field_template "https://github.com/spatie/laravel-honeypot/blob/main/resources/views/honeypotFormFields.blade.php"
click node_livewire_data "https://github.com/spatie/laravel-honeypot/blob/main/src/Http/Livewire/Concerns/HoneypotData.php"
click node_livewire_protection "https://github.com/spatie/laravel-honeypot/blob/main/src/Http/Livewire/Concerns/UsesSpamProtection.php"
click node_middleware "https://github.com/spatie/laravel-honeypot/blob/main/src/ProtectAgainstSpam.php"
click node_spam_checks "https://github.com/spatie/laravel-honeypot/blob/main/src/SpamProtection.php"
click node_spam_exception "https://github.com/spatie/laravel-honeypot/blob/main/src/Exceptions/SpamException.php"
click node_invalid_timestamp "https://github.com/spatie/laravel-honeypot/blob/main/src/Exceptions/InvalidTimestamp.php"
click node_spam_event "https://github.com/spatie/laravel-honeypot/blob/main/src/Events/SpamDetectedEvent.php"
click node_responder "https://github.com/spatie/laravel-honeypot/blob/main/src/SpamResponder/SpamResponder.php"
click node_blank_responder "https://github.com/spatie/laravel-honeypot/blob/main/src/SpamResponder/BlankPageResponder.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_provider,node_configuration toneBlue
class node_honeypot,node_encrypted_time toneAmber
class node_middleware,node_spam_checks,node_spam_exception,node_invalid_timestamp,node_spam_event,node_responder,node_blank_responder toneMint
class node_blade_component,node_view_composer,node_field_template,node_livewire_data,node_livewire_protection,node_inertia toneRose
class node_form_user,node_submission toneIndigo
```

## Components

### Package Setup

- [Service Provider](https://github.com/spatie/laravel-honeypot/blob/main/src/HoneypotServiceProvider.php): `src/HoneypotServiceProvider.php`
- [Honeypot Config](https://github.com/spatie/laravel-honeypot/blob/main/config/honeypot.php): `config/honeypot.php`

### Field Generation

- [Field Settings](https://github.com/spatie/laravel-honeypot/blob/main/src/Honeypot.php): `src/Honeypot.php`
- [Encrypted Timestamp](https://github.com/spatie/laravel-honeypot/blob/main/src/EncryptedTime.php): `src/EncryptedTime.php`

### Spam Protection

- [Spam Middleware](https://github.com/spatie/laravel-honeypot/blob/main/src/ProtectAgainstSpam.php): `src/ProtectAgainstSpam.php`
- [Spam Checks](https://github.com/spatie/laravel-honeypot/blob/main/src/SpamProtection.php): `src/SpamProtection.php`
- [Spam Exception](https://github.com/spatie/laravel-honeypot/blob/main/src/Exceptions/SpamException.php): `src/Exceptions/SpamException.php`
- [Invalid Timestamp](https://github.com/spatie/laravel-honeypot/blob/main/src/Exceptions/InvalidTimestamp.php): `src/Exceptions/InvalidTimestamp.php`
- [Spam Event](https://github.com/spatie/laravel-honeypot/blob/main/src/Events/SpamDetectedEvent.php): `src/Events/SpamDetectedEvent.php`
- [Spam Responder](https://github.com/spatie/laravel-honeypot/blob/main/src/SpamResponder/SpamResponder.php): `src/SpamResponder/SpamResponder.php`
- [Blank Page Responder](https://github.com/spatie/laravel-honeypot/blob/main/src/SpamResponder/BlankPageResponder.php): `src/SpamResponder/BlankPageResponder.php`

### Framework Integrations

- [Blade Component](https://github.com/spatie/laravel-honeypot/blob/main/src/View/HoneypotComponent.php): `src/View/HoneypotComponent.php`
- [View Composer](https://github.com/spatie/laravel-honeypot/blob/main/src/View/HoneypotViewComposer.php): `src/View/HoneypotViewComposer.php`
- [Hidden Field Template](https://github.com/spatie/laravel-honeypot/blob/main/resources/views/honeypotFormFields.blade.php): `resources/views/honeypotFormFields.blade.php`
- [Livewire Field Data](https://github.com/spatie/laravel-honeypot/blob/main/src/Http/Livewire/Concerns/HoneypotData.php): `src/Http/Livewire/Concerns/HoneypotData.php`
- [Livewire Protection](https://github.com/spatie/laravel-honeypot/blob/main/src/Http/Livewire/Concerns/UsesSpamProtection.php): `src/Http/Livewire/Concerns/UsesSpamProtection.php`
- **Inertia View**

### Other components

- **Form Author**
- **Form Submission**

## Connections

- Service Provider → Honeypot Config: binds from (evidence: `src/HoneypotServiceProvider.php`)
- Service Provider → Field Settings: binds (evidence: `src/HoneypotServiceProvider.php`)
- Service Provider → Spam Responder: binds (evidence: `src/HoneypotServiceProvider.php`)
- Service Provider → Spam Checks: binds (evidence: `src/HoneypotServiceProvider.php`)
- Service Provider → Blade Component: registers (evidence: `src/HoneypotServiceProvider.php`)
- Service Provider → View Composer: registers (evidence: `src/HoneypotServiceProvider.php`)
- Form Author → Blade Component: adds fields (evidence: `README.md`)
- Blade Component → Field Settings: uses settings (evidence: `src/View/HoneypotComponent.php`)
- Blade Component → Hidden Field Template: renders (evidence: `src/View/HoneypotComponent.php`)
- View Composer → Field Settings: reads settings (evidence: `src/View/HoneypotViewComposer.php`)
- View Composer → Hidden Field Template: provides fields
- Field Settings → Encrypted Timestamp: creates timestamp (evidence: `src/Honeypot.php`)
- Form Author → Inertia View: passes field data (evidence: `README.md`)
- Livewire Field Data → Field Settings: generates fields (evidence: `src/Http/Livewire/Concerns/HoneypotData.php`)
- Form Submission → Spam Middleware: submits form (evidence: `README.md`)
- Spam Middleware → Spam Checks: checks request (evidence: `src/ProtectAgainstSpam.php`)
- Spam Checks → Encrypted Timestamp: validates timestamp (evidence: `src/SpamProtection.php`)
- Encrypted Timestamp → Invalid Timestamp: throws on invalid (evidence: `src/EncryptedTime.php`)
- Spam Checks → Spam Exception: throws on spam (evidence: `src/SpamProtection.php`)
- Spam Middleware → Spam Event: dispatches (evidence: `src/ProtectAgainstSpam.php`)
- Spam Middleware → Spam Responder: responds to spam (evidence: `src/ProtectAgainstSpam.php`)
- Blank Page Responder → Spam Responder: implements (evidence: `src/SpamResponder/BlankPageResponder.php`)
- Livewire Protection → Spam Checks: uses checks (evidence: `src/Http/Livewire/Concerns/UsesSpamProtection.php`)
- Livewire Protection → Livewire Field Data: uses field data (evidence: `src/Http/Livewire/Concerns/UsesSpamProtection.php`)
