Skip to main content

Purpose

Creates and manages Browserbase browser sessions for live website visualization on the marketing site. Shows visitors a real-time browser view of their website being β€œscanned”.

Architecture

Two-Phase Flow

  1. Pre-warm - Create session without URL (fast, session ready)
  2. Navigate - Send URL to existing session (navigation happens in background)
This allows the frontend to show the browser embed immediately while navigation loads.

Internal Services

ServicePurpose
_create_browserbase_sessionCreates session via Browserbase API
_navigate_in_backgroundPlaywright navigation + scroll animation
_client_keyIP-based client identification

Code Location

src/website/browser_session/
└── routes.py    # All logic in single file

Session Caching

Sessions are cached per client IP + viewport width for 5 minutes. This prevents creating duplicate sessions for the same visitor.

Scroll Animation

After navigation, the background task performs automated scrolling:
  1. Wait 2 seconds
  2. Smooth scroll down 1.5 viewport heights
  3. Wait 5 seconds
  4. Scroll down another viewport height
This creates a β€œscanning” visual effect.

Rate Limiting

EndpointLimit
Create session60/minute
End session10/minute