# laravelfreelancernl/laravel-index-now architecture

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

- Interactive diagram: https://gitdiagram.com/laravelfreelancernl/laravel-index-now
- Repository: https://github.com/laravelfreelancernl/laravel-index-now

## Overview

##### Project type and purpose
- This is a Laravel “wrapper” package (PHP library) that plugs into any Laravel application.
- Purpose: simplify using the IndexNow API (by Bing/Yandex) from Laravel to notify search engines of page changes, either immediately or via delayed jobs.

##### File structure
- Top-level:
- bin/ (QA scripts)
- config/ (the published index-now.php)
- src/
– Commands/ (artisan command to generate key)
– Facades/ (IndexNow facade)
– IndexNow.php (core service class)
– IndexNowServiceProvider.php (Laravel service provider)
– Jobs/ (IndexNowSubmitJob for delayed submissions)
– Exceptions/ (error types)
- Tests/ (Pest & PHPUnit)
- Composer and tooling configs (phpstan, phpunit, pint, CI workflows)

##### README for additional insights
- Describes configuration options (host, key, delay, environment guard, etc.)
- Two main entry points:
- php artisan index-now:generate-key → writes key file to public dir
- IndexNow::submit(...) or IndexNow::delaySubmission(...) → either direct HTTP call or queue job

##### Detail
- Exception flows (missing key → exception)
- Config values feeding into the service (host, key, delay)
- Don’t just group everything into “Laravel”; separate Console, HTTP, Queue, Filesystem, Config.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Laravel Application and Integration
    LA["Laravel Application"]:::runtime
    SP["IndexNowServiceProvider"]:::runtime
    LA -->|"boot() binds IndexNow"| SP
    SP -->|"registers service"| SVC

    %% User Interaction
    UC["User Code"]:::runtime
    UC -->|"IndexNow::submit() / delaySubmission()"| FAC
    FAC["IndexNow Facade"]:::runtime
    click FAC "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/src/Facades/IndexNow.php"
    FAC -->|"resolves to"| SVC

    %% Configuration and Environment
    CFG["Config Store\n(config/index-now.php)"]:::config
    click CFG "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/config/index-now.php"
    ENV[".env Variables"]:::config
    SVC -->|"reads host, key, delay"| CFG
    SVC -->|"reads API key"| ENV

    %% Immediate Submission Workflow
    subgraph "Immediate Submission Workflow"
        SVC -->|"submit()"| HC
        HC["HTTP Client"]:::infra
        HC -->|"HTTP POST"| API
    end

    %% Delayed Submission Workflow
    subgraph "Delayed Submission Workflow"
        SVC -->|"delaySubmission() dispatch job"| JOB
        JOB["IndexNowSubmitJob"]:::runtime
        click JOB "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/src/Jobs/IndexNowSubmitJob.php"
        JOB -->|"handled by"| QUEUE
        QUEUE["Queue Worker"]:::infra
        QUEUE -->|"process job"| JOB
        JOB -->|"invokes service.submit()"| SVC
        SVC -->|"submit()"| HC2["HTTP Client"]:::infra
        HC2 -->|"HTTP POST"| API
    end

    %% Key Generation Workflow
    subgraph "Key Generation Workflow"
        CMD["GenerateKeyCommand"]:::config
        click CMD "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/src/Commands/GenerateKeyCommand.php"
        FS["Filesystem\n(public directory)"]:::infra
        CMD -->|"writes key file"| FS
    end

    %% Exceptions
    missingKey["Key File Directory Missing Exception"]:::error
    click missingKey "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/src/Exceptions/KeyFileDirectoryMissing.php"
    tooMany["Too Many URLs Exception"]:::error
    click tooMany "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/src/Exceptions/TooManyUrlsException.php"
    SVC -.->|"missing key/file"| missingKey
    SVC -.->|"> max URLs"| tooMany
    JOB -.->|"errors"| missingKey

    %% External API
    API["IndexNow API Endpoint"]:::external

    %% QA Scripts
    QA["QA Scripts (bin/qa.sh)"]:::config
    click QA "https://github.com/laravelfreelancernl/laravel-index-now/blob/next/bin/qa.sh"

    %% Styles
    classDef runtime fill:#c8e6c9,stroke:#2e7d32,color:#000
    classDef infra fill:#bbdefb,stroke:#1976d2,color:#000
    classDef external fill:#fff9c4,stroke:#fbc02d,color:#000
    classDef config fill:#e0e0e0,stroke:#424242,color:#000
    classDef error fill:#ffcdd2,stroke:#c62828,color:#000
```
