System architecture and service boundaries – Routing and domains

This section explains how the application’s routing layer defines clear module boundaries and how domain resolution is handled for different environments. Routing is organized by feature area; domains are generated per website and environment.

RouteServiceProvider: Core routing boundaries

Laravel’s RouteServiceProvider centralizes route registration and API rate limiting. It defines how requests traverse middleware and which route files they load .

🔒 API rate limiting

The provider sets a named rate limiter for all API routes:

RateLimiter::for('api', function (Request $request) {
    // Bypass limits for trusted WordPress syncs
    if ($request->header('X-Sync-Source') === 'PN_Wordpress') {
        return Limit::none();
    }
    // Default: 60 requests/minute per user or IP
    return Limit::perMinute(60)
                ->by($request->user()?->id ?: $request->ip());
});
  • Bypass: Requests with X-Sync-Source: PN_Wordpress skip throttling.
  • Default: 60 RPM, keyed by authenticated user ID or client IP.

Route groups and module boundaries

Each feature area lives in its own route file under routes/. All web-facing groups share the web middleware (session, CSRF), while the API group uses the api middleware (stateless, throttle) .

Route group Middleware File Purpose
web web routes/web.php Public site pages, Blade views
api api routes/api.php JSON API endpoints, webhooks
coaches web routes/coaches.php Coach dashboards and team management
event directors web routes/event_directors.php Event director interfaces
SEO web routes/seo.php Redirects and SEO optimizations
contracts web routes/contracts.php Contract signing and management
coupons web routes/coupons.php Coupon creation and validation
events web routes/events.php Event creation, editing, display
invoices web routes/invoices.php Invoice generation and payment tracking
media requests web routes/media_requests.php Handling photographer/media submissions
partners web routes/partners.php Partner onboarding and listings
programs & teams web routes/programs-and-teams.php Program setup and team rosters
reports web routes/reports.php Operational reporting dashboards
settings web routes/settings.php Application configuration UI
staffing web routes/staffing.php Staff assignment and invites
texting web routes/texting.php SMS campaign management (Twilio integration)
users web routes/users.php User management and role assignment
venues web routes/venues.php Venue selection and rate management
sitemap web routes/sitemap.php XML sitemap generation for events
checkout web routes/checkout.php Stripe-powered ticket checkout flow
webhooks web routes/webhooks.php Internal webhook endpoints
coverage web routes/coverage.php Media coverage assignment

Tip: Developers typically navigate these groups first to locate feature-specific routes and controllers.

🌐 Domain resolution per website

Domain logic lives on the Website model, enabling multi-tenant subdomains and local testing .

public function domain(): string
{
    return parse_url($this->url, PHP_URL_HOST);
}

public function eventsDomain(?string $route = null): string
{
    $baseDomain = $this->domain();

    if (app()->environment('local')) {
        $url = parse_url(config('app.url'));
        $domain = 'localhost' . (!empty($url['port']) ? ":{$url['port']}" : '');
    } else {
        $domain = match (app()->environment()) {
            'production' => "events.{$baseDomain}",
            'staging'    => "staging-events.{$baseDomain}",
            default      => "staging-events.{$baseDomain}",
        };
    }

    if ($route) {
        $parsed = parse_url($route);
        return "{$parsed['scheme']}://{$domain}{$parsed['path']}";
    }

    return $domain;
}
  • domain() extracts host from the site’s URL.
  • eventsDomain() returns:
    • localhost[:port] for local dev.
    • events.<baseDomain> for production.
    • staging-events.<baseDomain> otherwise.
  • Accepts an optional route to generate a fully qualified URL.

Enforcing HTTPS

In production, all URLs are forced to HTTPS via the AppServiceProvider:

if ($this->app->environment('production')) {
    \URL::forceScheme('https');
}

This ensures secure traffic on events.prephoops.com and its subdomains .