Automated Graphics - Attendee Commit
When an attendee registers for a showcase event, Prep Network automatically generates a personalized graphic (for Twitter and Instagram) featuring the attendee’s information and event details. These graphics are:
- Uploaded to Amazon S3 under
event-images/social-graphics/. - Emailed to the attendee for easy sharing.
- Queued for Prep Network’s social media channels.
Workflow Overview
- Registration / Update
- After an attendee is created or updated, the application invokes the graphic generation command and queues an email.
- Graphic Generation
- The console command
app:generate-graphicpulls attendee and event data, renders text onto a template, then streams the image to S3.
- The console command
- Email Delivery
App\Mail\AttendeeGraphiccomposes an email usingemails/attendee-graphic.blade.php, providing download links.
- Social Sharing
- Prep Network’s scheduled job (
graphics:generate) can bulk-generate for a website’s upcoming showcases.
- Prep Network’s scheduled job (
Key Components
| Component | Location | Responsibility |
|---|---|---|
GenerateGraphic <command> |
app/Console/Commands/GenerateGraphic.php |
Generates platform-specific graphics and uploads to S3. |
| AttendeeController | app/Http/Controllers/AttendeeController.php |
Triggers graphic generation and email dispatch on registration. |
AttendeeGraphic <mailable> |
app/Mail/AttendeeGraphic.php |
Builds and queues the attendee email with links. |
| Email View | resources/views/emails/attendee-graphic.blade.php |
Renders HTML email content with download links. |
1. GenerateGraphic Command
protected $signature = 'app:generate-graphic {attendee_id} {event_id} {template}';
Responsibilities:
- Fetch
AttendeeandEventmodels. - Validate
templateistwitterorinstagramand event is a showcase. - Extract attendee details (name, class/grade, school, state, height).
- Load base image via
Event::socialTemplates(). - Overlay text with dynamic font sizes and colors.
- Stream the final image to S3 at:
event-images/social-graphics/attendee-{id}-{platform}.jpg - Output the public URL for logging.
2. AttendeeController Integration
// After saving or transferring attendee...
foreach (['twitter', 'instagram'] as $platform) {
Artisan::call("app:generate-graphic {$attendee->id} {$attendee->event_id} {$platform}");
}
Mail::send(new AttendeeGraphic($attendee));
Key Methods:
postTransfer()and attendee updates invoke generation and email.showGraphic(Attendee $attendee)renders a modal for coaches to preview.
3. Email Delivery
{{-- resources/views/emails/attendee-graphic.blade.php --}}
<p>Hello {{ $attendee->first_name }},</p>
<p>Your registration graphic for {{ $event->title }} is ready:</p>
<ul>
@if($attendee->getGraphic('twitter'))
<li><a href="{{ $attendee->getGraphic('twitter') }}">Twitter graphic</a></li>
@endif
@if($attendee->getGraphic('instagram'))
<li><a href="{{ $attendee->getGraphic('instagram') }}">Instagram graphic</a></li>
@endif
</ul>
<p>Feel free to share it on your channels!</p>
- Caching ensures attendees aren’t spammed: a one-hour lockout on repeat emails.
- Download links point directly to S3 objects.
4. Sequence Diagram
sequenceDiagram
participant Browser
participant AttendeeController
participant Artisan
participant GenerateGraphic
participant S3
participant Mail
Browser ->> AttendeeController: POST /attendees
AttendeeController ->> Artisan: call app:generate-graphic
Artisan ->> GenerateGraphic: dispatch
GenerateGraphic ->> S3: upload image
GenerateGraphic -->> Artisan: return URL
Artisan -->> AttendeeController: generation complete
AttendeeController ->> Mail: send AttendeeGraphic
Mail ->> Attendee: deliver email
Best Practices & Notes
{
"title": "Idempotent Generation",
"content": "Existing graphics are deleted before regeneration to avoid stale images."
}
- Cleanup:
generate-graphicremoves any previous images for the same event/attendee. - Extensibility: New platforms (e.g., Facebook) can be added by extending
socialTemplates()and handling in the command. - Error Handling: Invalid templates or non-showcase events exit silently.
By integrating these classes and processes, Prep Network ensures each attendee receives a polished, on-brand graphic immediately after registration—driving engagement both in email and on social media.