Automated Graphics – Data Integration

This section covers how the platform offloads all new graphic generation to the central Prep Network Data site. It explains configuration, core integration classes, and example workflows for generating graphics via HTTP calls to a templated API.

🎛 Configuration via Graphic Automations

Each website can configure multiple graphic templates by setting Template IDs for named automations.

| Website Settings Page | Description | | — | — | | Graphic Automations | Browse all Prep Network sites and select one to configure(Settings → Graphic Automations) | | Livewire Component | Renders a table of name – template_id pairs for editinglivewire/graphic-automations/index.blade.php | | Storage | Template IDs saved via anlutro\LaravelSettings\Facades\Setting under
graphic_automations_{website_id}.{name} |

🔌 PnData Integration Class

The App\Integrations\PnData class encapsulates HTTP interactions with the central Prep Network Data API. It handles authorization, request building, and JSON parsing.

// Example usage in an Action
$response = (new PnData)->get($endpoint, $data);
  • Method: get(string $endpoint, array $payload)
  • Returns: Decoded response with ['json']['data'] containing asset URL.

⚙️ Action: Generate College Coach Staff Graphic

The GenerateCollegeCoachStaffGraphic action illustrates a typical integration flow:

namespace App\Actions\Staff;

use anlutro\LaravelSettings\Facades\Setting;
use App\Integrations\PnData;
use App\Models\Event;
use App\Models\Staff;
use Carbon\Carbon;

class GenerateCollegeCoachStaffGraphic
{
    public function execute(Event $event, Staff $staff): string
    {
        $templateID = (int) Setting::get(
            'graphic_automations_'.$event->website_id.'.college_coach_staff'
        );
        if (! $templateID) {
            throw new \Exception('College coach staff graphic template not found.');
        }

        $endpoint = 'templates/'.$templateID.'/generate';
        $data = [
            'location'     => "{$event->address_city}, {$event->address_state}",
            'date'         => Carbon::parse($event->start_date)->format('m.d'),
            'event_logo'   => $event->logo,
            'college_logo' => $staff->college()['logo'],
            'headshot'     => $staff->headshot,
        ];

        // Call central Data API
        $response = (new PnData)->get($endpoint, $data);

        // Return generated graphic URL
        return $response['json']['data'];
    }
}

⚙️ Job: Generate Program Commit Graphic

Similarly, programs use a queued job to generate “commit” graphics:

  • Job: GenerateProgramGraphic
  • Invocation: Bus::chain([...])->dispatch() or synchronous handle().
  • Storage: Generated image stored via S3 and associated to the Program model.
// Program model helper
public function generateCommitGraphic(...)
{
    // Remove old graphic, then
    $job = new GenerateProgramGraphic($this);
    Bus::chain([$job])->dispatch();
    return $this->getCommitGraphic($this->website->currentSeason());
}

🔄 Workflow Sequence

sequenceDiagram
  participant UI as Browser
  participant Ctrl as CollegeController
  participant Act as GenerateCollegeCoachStaffGraphic
  participant PnData as PnData HTTP Client
  participant API as PrepNetwork Data API

  UI-->>Ctrl: GET /colleges/{id}/generate-graphic?value=<id>
  Ctrl-->>Act: execute($event, $staff)
  Act-->>PnData: GET templates/{templateID}/generate + payload
  PnData-->>API: HTTP Request
  API-->>PnData: 200 { data: "<image_url>" }
  PnData-->>Act: parsed response
  Act-->>Ctrl: "<image_url>"
  Ctrl-->>UI: redirect back with success message

Card: Asynchronous vs. Synchronous

{"title":"Dispatch Modes","content":"College RSVPs use synchronous `dispatchSync` for immediate feedback, while program commits run via queued jobs for scalability."}

🔗 Usage Patterns

  • Routes

    • College: GET /colleges/{college}/generate-graphic → CollegeController@generateGraphic
    • Program: POST /regenerate-commit-graphic/{program} → ProgramController@regenerateCommitGraphic
  • Blade/JS Triggers

    • Select2 UI triggers full-page reload for college graphics
    • AJAX/modal workflows available for share/download in coaches’ dashboard.

🔗 Dependencies & Design Decisions

  • anlutro/laravel-settings: persists template IDs per site.
  • Carbon: uniform date formatting for templates.
  • PnData abstracts HTTP layer** to central API.
  • Blade/Livewire UI centralizes configuration in the admin panel.

Future improvements may include validating template existence at save time and richer UI previews of templates.


This integration centralizes graphic generation logic, simplifying PHP code and delegating template rendering to a dedicated Data service.