System Architecture

High-Level Components

  • Web Layer: Astro static pages for marketing, docs, pricing, and demo navigation.
  • API Layer: Pages Functions under functions/api/*.
  • Persistence: D1 for products, orders, deliveries, and download tracking.
  • Artifact Storage: R2 bucket for source package assets delivered to paid users.
  • Third-Party Services: PayPal payment APIs and optional Resend email delivery.

Runtime Boundaries

  • Public pages are static and served from dist.
  • Business operations execute in Pages Functions runtime.
  • Sensitive values remain in runtime bindings/environment variables.
  • No client-side secret handling for payment capture or artifact access.

Core Request Flows

  1. User initiates checkout via pricing page.
  2. /api/checkout creates payment order and writes pending order record in D1.
  3. After return, /api/paypal/capture confirms payment and creates delivery token.
  4. Optional delivery email is sent with secure download URL.
  5. /api/download validates token, reads package from R2, and updates download counters.