Skip to content
← Back to portfolio

Project case study · Web system

AI Courses

A live Cloudflare course platform built with Astro, Preact, and Hono. It uses Stripe Checkout, PPP pricing, and D1 for learner progress.

AstroPreactTypeScriptCloudflare WorkersHonoDrizzle ORMStripe
AI Courses

Overview

This live production platform sells and delivers a 21-day AI Challenge. Its web Worker serves the Astro storefront, quiz, checkout, and authenticated learner dashboard, while Preact islands handle the interactive flows. A separate Cloudflare Workers API, built with Hono and connected through a service binding, handles authentication, Stripe checkout, and learner progress.

Content and learner state

The curriculum is Markdown loaded through Astro’s content collection. Lessons are organized into Work, Business, and Life tracks, then resolved by track and day at request time. The course lives in the site’s static content rather than a database courses table.

Cloudflare D1 stores the runtime state through Drizzle ORM: users, purchases, per-track lesson progress, and streaks. Purchase rows drive the access scope for the starter and full-course areas; progress is keyed by user, track, and day.

Checkout and pricing

Stripe Embedded Checkout sessions are created server-side from country-aware pricing, never from an amount supplied by the client. The API has a PPP price table and falls back to USD for unknown countries. Its allowlist-based coupon flow stores product applicability and expiry in the coupon definitions, calculates discounts server-side, and creates or retrieves allowlisted codes as Stripe Coupon objects for checkout.

The webhook verifies Stripe signatures and processes paid Checkout Sessions. A unique (session_id, product) index protects the purchases table, and both the webhook and post-checkout confirmation path use conflict-safe inserts. Retries and duplicate confirmation calls are therefore idempotent. A purchase row, confirmation email, or purchase event is created only for a new purchase.

Engagement and edge controls

Completing a lesson writes progress to D1 and awards 30 XP, plus a 5 XP streak bonus when the resulting streak is at least two days. The API updates current and longest streaks, allows one missed day through a grace rule, and avoids awarding XP twice when a lesson is submitted again. The dashboard reads the stored lesson progress, streak, and total XP to render the 21-day path.

The API also uses Cloudflare KV for IP-scoped rate limiting with expiring counters on email capture, magic-link login, payment creation, and purchase confirmation routes.

Delivery and measurement

Brevo sends the purchase confirmation email and tags the buyer after a new purchase. PostHog receives server-side purchase events keyed to the Checkout Session, along with client-side checkout and lesson-completion events.

Production status

The platform is live in production at aicoursechallenge.com. The Cloudflare deployment configuration includes custom domains for the web app and API, a service binding between the two Workers, and Stripe live mode for checkout.

Have a project in mind?

Tell me what you're working on and where you need help.