How mettle/sendportal works
Project type and purpose
• This is a full-stack, self-hosted email-marketing application named SendPortal, built with Laravel (PHP) and Livewire.
• It provides user authentication, multi-workspace management, subscriber/list management, campaign creation, email sending via third-party providers (SES, Postmark, Sendgrid, etc.), and tracking/reporting.
File structure
• Top-level folders:
– app/: Laravel application code (Controllers, Models, Services, Repositories, Console commands, Middleware)
– bootstrap/: framework bootstrapper
– config/: configuration files (database, mail, queue, horizon)
– database/: migrations, factories, seeders
– public/: web server entry point (index.php)
– resources/views: Blade templates and Livewire views (frontend)
– routes/: web, api, console, channels
– storage/: cache, sessions, logs
– tests/: Feature and Unit tests
• Key patterns:
– MVC (Controllers, Models, Views)
– Services + Repositories for business logic
– Console commands for install/upgrade workflows
– Livewire for dynamic, reactive UI components
– Laravel Queues + Horizon for asynchronous email dispatch and tracking
– Multi-workspace isolation with middleware enforcing workspace ownership
README for additional insights
• Confirms Laravel 10+, PHP 8.2+, MySQL/PostgreSQL, and integration with external mail APIs
• Core logic is in a separate package (sendportal-core), but this wrapper provides auth, routing, multi-workspace
a. Main components
– Client (Browser/SPA)
– Web Server (Nginx/Apache)
– Application Server (Laravel + PHP-FPM)
– Frontend Layer (Blade + Livewire)
– HTTP/API Layer (Controllers → Services → Repositories → Models)
– Queue Worker Layer (Laravel Queues + Horizon)
– Database (MySQL/PostgreSQL)
– Cache (Redis)
– External Email Providers (SES, Postmark, Sendgrid, Mailgun, Mailjet)
– SMTP/Webhook endpoints for bounce/complaint tracking
b. Relationships and interactions
1. Client sends HTTP requests to Web Server
2. Web Server forwards to PHP-FPM / Laravel application
3. Laravel routes → Controllers → Requests → Services → Repositories → Database
4. Controllers return Blade/Livewire views or JSON (API)
5. Actions like “Send Campaign” dispatch Jobs to Queue (Redis)
6. Queue Worker (Horizon) processes jobs, calls External Email APIs
7. Event listeners persist tracking data back to Database
8. Scheduled tasks (cron) trigger recurring jobs (campaign scheduling, cleanup)
c. Architectural patterns & design principles
– MVC for web requests
– Service–Repository for business/domain logic separation
– Command Bus for install/upgrade commands
– Middleware to enforce workspace scoping and authentication
– Event-Driven for email tracking and reporting
– Queues for scalability and non-blocking email dispatch
d. Key technologies/frameworks
– Laravel 10+, PHP 8.2
– Livewire for dynamic UI
– Blade templates
– MySQL or PostgreSQL
– Redis for queue & cache
– Laravel Horizon for queue monitoring
– Amazon SES, Postmark, Sendgrid, Mailgun, Mailjet
Capturing essential architectural elements
• Detail every major module:
– Authentication & Authorization
– Workspace management
– Subscriber & List management
– Campaign creation & scheduling
– Email dispatch jobs
– Tracking & reporting events
• How data flows from user input through service layer to external mailer, back through event listeners into reporting UI