Skip to content
プロジェクト

概要

TanStack Start を使ったオープンソースの SaaS スターターキット。Better Auth、Drizzle + Cloudflare D1、Polar による課金とライセンス管理、Resend によるメール送信、管理コンソールを備え、9 言語に対応。テストカバレッジは 100%。saasyland.com のウェブサイトのコードです。

ビジネス・金融

この数値の測り方

計測したスター増加

24時間
+1
7日間
+2
15日間
+3
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

SaaSy Land

Source code for the SaaSy Land website, customer workspace, and admin console. The application combines a multilingual marketing site, documentation and blog, authentication, newsletter subscriptions, video streaming and courses, and Polar checkout and licence management in one TanStack Start application deployed to Cloudflare Workers.

This repository contains the website application. The SaaSy Land CLI and private generator templates are maintained separately and are not included here. The website source is MIT licensed, so you can start from it for free; the paid CLI writes a new project in the stack you choose, today React with TanStack Start on Cloudflare Workers and the other stacks on the roadmap, with its own tests, coverage gate, CI workflow and AGENTS.md. See licensing for the distinction between the website source and the commercial product.

SaaSy Land landing page: the headline "The SaaS foundation your AI agent can’t break", the install command, and the admin dashboard

The landing page in November 2026. View the full page.

Contents

Features and implementation status

Every admin screen reads real data through permission-checked server functions: from D1, and from Polar for the product catalogue and an order's live payment. A screen whose data has no source yet is not built, and the admin-data/no-literal-data lint rule fails bun run check when admin code declares demo data.

Area Current implementation
Public website Landing page with real products built on SaaSy Land in place of testimonials, linked once their sites are live (PRODUCT_CASES), pricing presentation whose tier cards list what each tier includes today and what is arriving (TIER_FEATURES), with the recommended tier marked, the button under the price on a phone, whole-dollar regional prices and the facts a buyer checks before paying (Merchant of Record, VAT invoice, tax, refund, beta), and the Core price, lifetime updates and refund period under the hero's buttons, with each tier described to search engines as a Product whose Offer carries its price from TIER_PRICES, localized legal pages, responsive layouts, theme support, and reduced-motion presentations. Public pages are prerendered during builds, and every count on the landing page, like every file path and command it cites, comes from the repository at build time (scripts/repository-facts.ts).
Documentation and blog Localized MDX content, navigation, and documentation search through Fumadocs, whose own controls are translated in every language like the rest of the site. On wider screens the docs sit in the same frame as every other page, with a sidebar and a table of contents that line up with the site header and leave the article between them a comfortable line length; the header keeps its width, its place and its bottom line on every page, also while a client navigation changes the page; on a phone the docs keep the site header and one docs bar, and every docs page ends with the site footer. Every build turns the docs and the blog into static indexes per language, and the search into a static index the browser searches, so moving through the docs or the blog and searching the docs never reach the Worker, which holds no docs or blog content; a navigation that does take longer shows the skeleton of its page, beside the docs sidebar when it moves between docs pages. The site header loads its pages, the docs among them, once a page has loaded and the browser is idle, so a click on Docs usually waits for nothing, while a crawler, which never interacts with a page, loads none of them. Published content is maintained in Git. The blog index leads with the featured posts, chosen in one data file, then the latest and the recently updated posts, and lets readers search, filter by topic and sort every post from a finder that stays in reach, a side panel with an index of every post on wide screens and a bar under the header with a filters sheet on phones, loading more in place or through archive pages that search engines and readers without JavaScript can follow; on wide screens every post lists the others beside it, the table of contents of a post or a docs page marks the section being read with a line that follows the scroll, and the landing page shows a featured post and the latest ones. A blog post shows the day it was first published and, once its facts or substance change, the day it was updated, and gives both to its structured data. A blog post can be shared by copying its link, through the system share sheet, or on X, LinkedIn, Bluesky, Hacker News, Reddit or by email, all without a third-party script, and it ends with a box that introduces its author and links the author's page, which lists every post by that author and describes the author to search engines as a Person, and with related posts. Every build writes /sitemap.xml, an index of the site's sitemaps, and /sitemap-pages.xml with hreflang alternates and each blog post's lastmod, an RSS feed of the blog in every language, and a social card for every prerendered page; see Blog and Search and social previews.
Authentication Email/password registration that signs a new account in at once, so a buyer reaches the checkout without visiting the inbox, with the licence key, the Polar customer portal and paid lessons waiting for a confirmed address; GitHub and Google sign-in with a Last used badge; password recovery that keeps the address and the return path; TOTP set up from a QR code, with backup codes to copy, download and replace; and session management that names each device's browser, system and country. Changing or setting a password signs out every other device and emails the account. Passwords have a minimum length and no composition rules, and new ones are checked against known data breaches (Have I Been Pwned). Better Auth's own endpoints enforce the same password, name, email and image rules as the forms, and verification and password-reset emails are limited per recipient.
Customer workspace Protected /app area, /app/license, /app/billing and /app/settings. Accounts without a licence see the landing page's tier cards with regional prices and the course lessons a purchase unlocks (counted from D1), and a tier button opens Polar's checkout straight away over the page, in their language where Polar translates it, in the site's theme and with their email filled in; closing it unpaid leaves them where they were, focus back on the button, and a browser that cannot show it goes to Polar's checkout page, with a back button; the line under the buttons says that Polar asks for the consent to immediate supply on the payment page, when the refund ends and, in a language Polar does not translate, that the payment page opens in English. A tier picked on the landing page carries through sign-up, whose page sums up the order: the tier, its price, the steps to the licence and the refund window. After payment the workspace, without a reload, waits for the licence to activate with the tier just bought, so an upgrade is thanked for the higher tier only once it applies, celebrates (without motion for visitors who prefer less), and lists the steps to a first project: copy the key, activate it and generate a project, each with a copy button, ticked as the licence server records the activation and the first template download. Licence owners see their key and the CLI commands that activate it, generate a project, show and free a machine, each to copy, while the page fetches a key that is still being issued and shows its machine limit the moment it arrives, and a link to upgrade to each higher tier for the difference, which keeps their key and raises its machine limit; until the address is confirmed, the key's place on the card and in the steps names the address the confirmation link went to; a refunded or revoked licence says so without the key or commands and offers a new licence or support. /app/billing lists the account's subscriptions with their price, status and renewal date and its orders with their invoice number, amount, refund and status, downloads the invoice Polar has issued for a paid order, and opens the Polar customer portal, once the address is confirmed, to manage payment methods, invoices and subscriptions; after paying for any other Polar product, the buyer lands there and the page waits until Polar's order arrives. The sidebar links to the courses with the lessons the customer has finished. In /app/settings a customer picks the time zone that every date in the workspace is shown in, changes the email address (confirmed from the old address, then verified at the new one), changes or sets the password, turns two-factor authentication on and off, connects and disconnects GitHub and Google without ever losing the last way to sign in, signs out other devices, and deletes the account after the password and a link emailed to the address, with what is deleted and what is kept, such as an active licence and the payment records, spelled out first.
Billing Authenticated Polar checkout for the Core, Complete, and Agency tiers at whole-dollar regional (PPP) prices sent as the checkout's own price, and upgrades to a higher tier that charge the higher tier's price less what the customer has paid, counted from the D1 copies of their licence orders, and keep the licence key, returning the buyer to the workspace in their language. The buyer consents to immediate supply and acknowledges losing the right of withdrawal once, by ticking Polar's required checkbox on the payment page, which the site leaves empty and Polar will not take a payment without; the buyer's language is stored on the order, and polar:verify checks that checkout localization is on and that tax is location-based. Webhook handling for purchases records the consent from the order's checkout field, emails the buyer a branded purchase confirmation in their language that repeats the consent (or, without it, the statutory right of withdrawal), the refund deadline and its conditions, and how to start: the licence page, the activate and init commands, the CLI guide and, for a tier with course access, the courses, full refunds (a partial refund keeps the licence), and licence-key benefits; a full refund marks the licence refunded and a revoked benefit marks it revoked. One licence per account: checkout is refused while a licence of the same or a higher tier is active, and Polar's checkout endpoint is reachable only through that server-side check. Any other Polar product, one-time or subscription, has a server-side checkout of its own that refuses the licence tiers; both checkouts are built by the same code, open over the page, carry the buyer's language and the affiliate referral, and share a per-client rate limit. Webhooks also copy each Polar order and subscription into D1 at Polar's latest version. A paid licence order whose customer matches no account emails the site's contact address an alert with the order, the buyer and a link to the order in Polar, and the admin dashboard lists every paid licence order that has no licence until it is recovered: link the Polar customer to the account and redeliver the order's webhook events, as the Licences guide describes. The EU withdrawal function (Article 11a of the Consumer Rights Directive) is a public page at /withdrawal, linked as Withdraw from contract here in the footer, the legal pages and the purchase confirmation, and a card on /app/license that fills in the account's details; it stores every withdrawal statement in D1 with the refund terms at that moment, emails the buyer an acknowledgement of receipt with its content, date and time in their language, notifies the site's contact address and lists the statements on the admin's user profile, while refunds stay a decision made in Polar, as the Licences guide describes. Requires configured provider products and credentials.
CLI licence API The API that the saasyland CLI calls under /api/cli/v1 to read a licence, to activate, check and release machines and to download the template bundle of a release. It is built on the @saasyland/stack/api contract, which the CLI imports too: the key is checked against D1, machines are Polar activations identified by an HMAC of the machine ID, activating again from the same machine reuses its slot, bundles come from a private R2 bucket through short-lived signed URLs, requests are rate-limited per IP address and per licence key, and the licence records its first activation and its first template download, so a refund request can be checked against what the CLI received. See the CLI licence API guide.
Newsletter Double opt-in subscription with localized email delivery, limited per recipient. The confirmation and unsubscribe links open a page that acts only when the visitor presses its button. The admin lists and exports the subscribers, writes an issue in every language with a preview and sends it to the confirmed subscribers through Resend in batches that a retry or a repeated click never sends again, each email with its own unsubscribe link and one-click List-Unsubscribe headers. See the Newsletter guide. A signed-in customer turns it on and off in the workspace settings, at once and without a confirmation email for an address the account has confirmed.
Admin dashboard Counters for registered users, products, pending email verifications, learners, videos and newsletter subscribers; revenue per currency from the D1 copies of Polar's orders, refunds subtracted, and new users, each over the last 7 days, 30 days or 12 months in UTC; progress per course; the licences of each tier, active, revoked and refunded; the paid licence orders that have no licence; and the newest users, searched and filtered across every account on the server. Every figure is read from D1 behind an admin permission, and an empty database shows empty states, never sample figures. The sidebar collapses to its icons, each counter links to the page it counts, and ⌘K or Ctrl+K opens a command palette with recent items, quick actions, every page and a permission-checked server search of users, orders, courses and lessons. See the Admin dashboard guide.
Admin users and security A user grid searched and filtered by role, status, verification, 2FA, time zone and dates on the server, and a profile page per user: adding a user, renaming, role changes, password reset, ban/unban with confirmation, deletion, impersonation with a banner to stop it, and revoking a user's sessions. Admins invite people by email with a role and see, search, filter, resend, and revoke the open invitations in a grid. The profile also shows the user's licence: tier, status, machine limit, the machines the key has activated in Polar with their label, system and activation time, purchase time, consent to immediate delivery, first activation, first template download, first paid lesson opened with its title, and whether a refund is still possible; and the account's orders with what it paid after refunds per currency. A Customers tab lists every Polar customer, searched and filtered by verification, order count and dates on the server, with their account, sign-up date, email verification, order count, what they paid after refunds per currency, their last order, and the machines their licence uses against its limit, read from Polar with a short timeout and a notice when Polar cannot be reached. The admin's settings share the customer's security tab (password, TOTP, connected accounts and sessions), and the general tab saves the business profile (name, support email, postal address and a logo scaled in the browser and served from R2) as well as the admin's own time zone and email address.
Admin orders /admin/orders lists the D1 copies of Polar's orders with their account, product, total in the order's currency, refunds, discount, billing country and status, searched and filtered by status, product, discount, billing country and period on the server, and says when no order exists yet; bun run orders:backfill:<environment> copies the discount and billing country of orders mirrored before they were kept. bun run orders:backfill-amounts:<environment> does the same for the subtotal, net amount and refunded tax that the upgrade price adds up, and writes them only with --apply. Each order's page adds Polar's live payment: subtotal, discount and its code, tax, refunds, billing name and country, and the invoice, and keeps the copy with a notice when Polar cannot be reached. See the Orders and customers guide.
Products and categories /admin/products lists every product of the Polar organisation, read from Polar on each visit, with its prices, billing period, licence-key activation limit, status and a link to it in the Polar dashboard, beside its sales and revenue per currency from the D1 copies of the orders; products are created and edited in Polar. The D1 product and category tables keep their schemas and permission-checked use cases, but no screen reads or writes them. See the Products guide.
Courses A public catalogue at /courses with course and lesson pages backed by D1 (course, chapter, lesson, lesson_attachment, and lesson_progress). Each lesson is a free preview, free with an account, or paid (an active Complete or Agency licence); the server functions enforce access and record the first paid lesson a licence opens as the first use of the purchase, and admins can watch every lesson. Courses carry a level, an icon, a cover the admin uploads (cropped to 16:9 in the browser, stored in R2 at three widths and served from /media/covers/ with a year-long immutable cache, with the icon on a teal glow for a course without one), outcomes and prerequisites; chapters a summary; lessons a description, key moments and materials (files in R2 and links), whose downloads are signed only for viewers who may open the lesson. A video lesson without a video is listed as being recorded and does not play until its recording is encoded; a text lesson has no video by design and is read; a published course whose lessons are all being recorded says so and offers no start link. The player resumes where the viewer stopped and saves progress. The admin at /admin/courses is the single place to edit all of it, in every locale, with a lesson editor for the text, key moments, video and materials, where the recording is dropped, uploaded in parts with its progress, encoded and previewed, replaced or deleted; each form has one language control that lists every locale with its translation state and switches all its fields at once, and an all-languages panel fills a field in every locale side by side. It exports courses to a JSON file and imports one after a dry run that lists what will change, matching courses and lessons by slug, so a second import of the same file changes nothing; content/courses/saasy-land-courses.json is the site's curriculum in every locale, ready to import. The catalogue leads with each course's cover; the course page shows the curriculum as an accordion beside a sticky panel with the course's state, its call to action and what it includes; the lesson page puts the player first with the course contents beside it, key moments that seek, a transcript from the captions and the materials. The landing page lists the published courses from D1 at view time, each with its first lessons open, locked or being recorded, and plays a tour of the course pages. Search engines find the catalogue, every published course and every lesson a signed-out visitor may watch in /sitemap-courses.xml, which the Worker writes from D1 with each page's last change as lastmod; the course page describes the course as a Course in structured data and shares its cover as its link preview, and a lesson behind an account or a licence stays out of search results. See the Courses guide.
Videos Each lesson's recording is dropped into its lesson editor and uploaded to a private R2 bucket in parts through the Worker, resuming where it stopped; bun run video:encode:<environment> encodes the uploads to adaptive HLS with FFmpeg on a machine that has it and puts each on its lesson, and bun run video:publish:<environment> encodes a local file. Videos stream through signed, expiring /media/ links with the Workers cache and range requests, one video can play in several lessons, and one no lesson uses can be deleted from the lesson editor. See the Videos guide.
Affiliates Referral links tracked by Affonso, loaded only on visits that carry a referral parameter; checkout passes the referral to Polar as order metadata, so commissions follow Polar's own order and refund records. /affiliates publishes the terms. Until AFFILIATE_PROGRAM in src/data/affiliates.ts opens the programme, no visit loads Affonso's script and the page asks partners to write in instead of linking the partner portal Affonso hosts; once it is open, tracking also needs the AFFONSO_PROGRAM_ID variable, which the production Worker sets. See the Affiliate programme guide.

The admin has no screens for pricing models, refunds, blog posts, the landing page, or roles yet: prices are set in code and in Polar, refunds in Polar, and posts in Git; the roadmap lists them in build order. The built-in application roles are admin and customer; new accounts receive customer.

Technology

Responsibility Implementation
Application and routing React 19, TypeScript, TanStack Start and Router
Toolchain Bun, Vite+, formatting, linting, and type checking configured in vite.config.ts
Hosting and storage Cloudflare Workers, D1 (SQLite), KV, R2, and static assets
Database access Drizzle ORM and checked-in SQLite migrations
Authentication and authorization Better Auth with module-level permissions and server-function middleware
Data and forms TanStack Query, Form, and Table; Zod validation
CLI contract @saasyland/stack: the CLI's questions, rules and flags, which the landing page's configurator asks, the UI library first, disabling with an hourglass each option the templates do not generate yet; @saasyland/stack/cli: its template support, exit codes, variables and credentials store; @saasyland/stack/api: the routes, schemas, errors and rate limits of the CLI licence API
UI Tailwind CSS 4, shadcn-styled components with React Aria and Base UI, Motion, and locally served fonts
Localization and content use-intl, ICU messages, Fumadocs, and MDX
External services Resend for email; Polar for checkout, billing, and licence keys; Affonso for affiliate referrals
Video FFmpeg encoding to HLS (CMAF) on the publisher's machine; Video.js 10 playback
Verification Vite+/Vitest, Testing Library, jsdom, and Playwright with axe-core accessibility scans

package.json and bun.lock define the application toolchain. The separate Remotion project uses its own npm lockfile. Check them for security advisories with bun audit at the root and npm audit inside remotion/; GitHub reads the npm lockfile but not bun.lock, so Dependabot alerts miss the application's transitive packages. CI runs bun run deps:audit, which fails on a high or critical advisory in a production dependency unless a dated, reviewed exception in src/data/dependency-audit.ts allows it, and bun run deps:sbom, which writes the CycloneDX SBOM of the production dependencies and uploads it as the sbom artifact of every run. Each minimatch entry under overrides is a security fix that waits for a parent release, and the dependency conventions name the upstream change that will let it go.

Getting started

Prerequisites

  • Bun 1.4.5, matching packageManager; CI reads the version from it.
  • Node.js 26.13.1 or newer, the version in .nvmrc: nvm use and CI read it, and engines in package.json requires it. 26.13.1 is the November 2026 security release of the Node 26 LTS line. Node is also needed by the SQLite test harness.
  • A Cloudflare account and provider credentials for development against real services. The isolated preview and automated tests below do not require those accounts.

From the repository root:

bun install --frozen-lockfile

The install lifecycle configures Vite+ and generates the class-name tables and Fumadocs content. If you install with --ignore-scripts, run bun run typegen afterward to generate Worker declarations, class-name tables, and content types.

Run an isolated local preview

Use the committed test environment to explore the application with local D1/KV/R2 storage, test accounts, a sample course at /courses, and intercepted provider requests:

bun run db:reset:test
bun run build:test
bun run start:test

Open http://127.0.0.1:3000. Sign in with any account below; each uses the password WorkerTestPassword123! from e2e/data/accounts.ts, and the licensed accounts and their licences come from e2e/data/licenses.ts.

Role Email Workspace
Admin [email protected] /admin
Customer [email protected] /app
Customer with a Core licence [email protected] /app
Customer with a Complete licence [email protected] /app

This serves a built test application; rebuild it to see source changes. It uses dummy values from .env.test, the test environment in wrangler.jsonc, and isolated state under .wrangler/test. Provider interception is intended for local verification, not for validating real OAuth, email delivery, or payments. Keep this test configuration local.

Develop with Cloudflare and provider integrations

The development server supports hot reload at http://localhost:3000. Its DB, CACHE, MEDIA, and BUNDLES bindings are local, under .wrangler/state: development never reads or writes the preview or production data, and it needs no Cloudflare login. Local, preview, and production each have their own D1 database.

  1. Copy the environment template and generate a secret:

    cp .env.example .env.development
    openssl rand -base64 48
    
  2. Set the generated value as AUTH_SECRET in .env.development, then fill in the integration settings. Use POLAR_SERVER=sandbox for development. Optionally set LOCAL_ADMIN_PASSWORD, the password of the local admin; without it the seed uses a default that it prints and the Database guide lists.

  3. Create, migrate, and seed the local database, then start the server:

    bun run db:reset:local
    bun run db:seed:local
    bun run dev
    
  4. Sign in as [email protected] and open /admin/courses. bun run db:studio:local opens the same data in Drizzle Studio.

The seed creates that admin, imports the course curriculum from content/courses/saasy-land-courses.json with the same code as the admin's Import, uploads the covers in content/courses/covers/ to the local bucket, and adds the licences, the order without a licence, and the CLI template bundle of the test seed. Run it again at any time; it changes only what differs.

Email/password signup requires a functioning Resend configuration: a new account is signed in at once, but its licence key and paid lessons wait for the confirmation link, and signing in again requires a confirmed address. GitHub/Google sign-in and checkout require their respective provider configuration. Use the isolated preview when you only need to inspect the UI without those services.

On preview and production, the first admin is created with bun run admin:grant:preview <email> or bun run admin:grant:production <email>; see The first admin.

Configuration and integrations

Environment files

Use .env.development, .env.preview, and .env.production for their corresponding environments. These files are ignored by Git; .env.example lists the configuration keys. .env.test contains committed dummy values for isolated tests.

Server integrations read secrets through env from cloudflare:workers. Do not give private credentials a VITE_ prefix, which makes values available to browser code. Deployment scripts upload only the keys that secrets.required in wrangler.jsonc declares, read from the matching environment file.

Variables Purpose
AUTH_SECRET Long random secret used by Better Auth. Generate a separate value for each deployment environment.
AUTH_GITHUB_CLIENT_ID, AUTH_GITHUB_CLIENT_SECRET GitHub OAuth application credentials.
AUTH_GOOGLE_CLIENT_ID, AUTH_GOOGLE_CLIENT_SECRET Google OAuth application credentials.
RESEND_API_KEY, RESEND_EMAIL_FROM Email API credentials and the sender accepted by your Resend account.
POLAR_SERVER Polar environment: sandbox for development and preview, production for live billing. polar:verify refuses any other pairing.
POLAR_ACCESS_TOKEN, POLAR_ORGANIZATION_ID Polar API access and the organization used for licence keys and orders.
POLAR_WEBHOOK_SECRET Secret used to verify Polar webhook deliveries.
POLAR_PRODUCT_ID_CORE, POLAR_PRODUCT_ID_COMPLETE, POLAR_PRODUCT_ID_AGENCY Product IDs mapped to the three checkout tiers. Use IDs from the selected Polar environment.
CLOUDFLARE_ACCOUNT_ID, CLOUDFLARE_DATABASE_ID, CLOUDFLARE_ACCESS_TOKEN Credentials for Drizzle Studio and introspection over the D1 HTTP API. Application queries use the DB binding instead.
AFFONSO_PROGRAM_ID Optional Worker variable (vars in wrangler.jsonc), set only for the environment that takes real payments. The public Affonso program ID that affiliate referral tracking needs; tracking runs only while AFFILIATE_PROGRAM in src/data/affiliates.ts says the programme is open.

The development, preview, and production environments declare every key above except AFFONSO_PROGRAM_ID in secrets.required, including the Cloudflare credentials used by Drizzle tooling. AFFONSO_PROGRAM_ID is public, so it is a plain Worker variable under vars, not a secret; production sets SaaSy Land's programme ID and test a dummy ID for the browser tests. Supply the required secrets for the selected environment; see wrangler.jsonc for the authoritative list.

Domains and branding

The public URL is configured in source: src/presentation/branding/index.ts defines APP_DOMAIN and derives APP_URL as https://${APP_DOMAIN}, together with the contact addresses, the GitHub organisation and repository URLs and the Instagram profile, which the footer links and the home page's structured data lists. VITE_APP_URL is not read by the application.

When adapting the application to your own domain, update these locations together:

Location What to configure
src/presentation/branding/index.ts Application name, canonical domain, preview host (APP_PREVIEW_DOMAIN), contact addresses, GitHub identity and Instagram profile (APP_INSTAGRAM_URL).
src/modules/_core/constants/api.ts DEPLOYED_HOSTS, the preview and production hosts read from APP_PREVIEW_DOMAIN and APP_DOMAIN, and the one place the code names them by environment.
wrangler.jsonc Worker names, custom-domain routes, D1 databases, KV namespaces, and R2 buckets for each environment.
src/data/license.ts Tier prices (TIER_PRICES), tier features available now or arriving (TIER_FEATURES), and the support reply time and architecture call length the copy prints (TIER_SUPPORT); polar:verify checks Polar prices.
src/data/marketing.ts The consulting rate (CONSULTING_HOURLY_RATE), the real products on the landing page (PRODUCT_CASES), and the course platforms' URLs, build counts and the status of Complete's access to each (REACTPROJECTS_FACTS, ANGULARPROJECTS_FACTS, REACTPROJECTS_ACCESS, ANGULARPROJECTS_ACCESS), and the status of Agency's team seats (TEAM_SEATS_ACCESS).
src/data/newsletter.ts Whether the build log is sent (NEWSLETTER_SENDING), which the footer, the confirmation page and email and the empty course catalogue read, and the badges and column widths of the admin's newsletter grids.
src/presentation/styles/ Theme, typography, fonts, and shared style definitions.

The branding names the preview host, APP_PREVIEW_DOMAIN (preview.<APP_DOMAIN>), and the production host, APP_DOMAIN, and DEPLOYED_HOSTS maps the preview and production environments to them. appHostsForMode reads it for the hosts Better Auth and newsletter links accept in each mode, and the deployment scripts' live check requests it, so change APP_PREVIEW_DOMAIN when your preview host has another name. The custom-domain routes in wrangler.jsonc and the environment URLs in deploy-reusable.yml name the same hosts and must match; src/__test__/wrangler.test.ts fails when the routes differ. Changing an environment file alone does not change the canonical URL. Rebuild after changing branding or deployment configuration.

Provider setup

  • Configure GitHub and Google callback URLs at https://<your-host>/api/auth/callback/github and https://<your-host>/api/auth/callback/google. Use the appropriate development or deployed origin.
  • Configure Resend credentials and the sender address before testing verification, password recovery, newsletter delivery, or purchase confirmations. Templates live in src/presentation/emails/.
  • Set up Polar as the Polar setup guide describes: separate sandbox and production organisations, an organisation token with the listed scopes, one one-time product per tier priced from TIER_PRICES with one licence-key benefit limited by LICENSE_ACTIVATION_LIMITS (license.constants.ts), never expiring and without a usage limit, the required consent checkbox withdrawal_consent on every product with the label in WITHDRAWAL_CONSENT_FIELD (src/lib/polar.ts), and the organisation's default tax behaviour set to location-based; regional prices need no discounts in Polar.
  • Create one Polar webhook per deployed host at https://<your-host>/api/auth/polar/webhooks, in the raw format, signed with POLAR_WEBHOOK_SECRET and subscribed to exactly POLAR_EVENTS from src/integrations/polar/polar.webhooks.ts, the events of every handler in POLAR_EVENT_HANDLERS; today these are the licence's LICENSE_WEBHOOK_EVENTS and the order and subscription events copied into D1 (ORDER_WEBHOOK_EVENTS and SUBSCRIPTION_WEBHOOK_EVENTS). The licence handlers process paid orders and upgrades, full refunds (a partial refund keeps the licence, a refunded upgrade returns the earlier tier), and licence-benefit creation and revocation.
  • Run bun run polar:verify:<environment> after every change in Polar. It reads the Polar keys from .env.<environment>, sends only GET requests, and fails with one line per difference between Polar and the code.

The website associates purchases and issued keys with authenticated customers, exposes activation management and serves the CLI licence API through which the CLI activates machines and downloads the templates of its release. The CLI itself and the templates it generates are maintained separately; customers activate their licence and generate their projects with it as the CLI guide describes, and its release notes and the roadmap say what it does today and what is arriving.

Project structure and conventions

content/
  blog/                          Localized MDX posts
  changelog/                     One changelog entry per pull request and locale, dated from the Git history
  docs/                          Localized MDX documentation and navigation metadata
messages/{locale}/               JSON catalogues split into dotted namespaces
e2e/                             Playwright specs, the journey suite, and the seeded test accounts, video, and course
scripts/                         Content checks, build, deployment and release steps, seeding, video publishing, and tooling
remotion/                        Video authoring source and isolated npm toolchain
src/
  routes/                        TanStack file routes, loaders, guards, and HTTP handlers
  routes.ts                      ROUTES: every path and the paths kept out of prerendering, with no import so every runtime loads it
  router.tsx                     Per-request QueryClient and SSR integration
  server.ts                      Cloudflare Worker entry: request handlers, document rewrites, locale middleware, and security headers
  integrations/{vendor}/         Vendor configuration and adapters ({prefix}.{concern}.ts, e.g. auth.server.ts)
  modules/{table}/               One folder per database table: schema, zod, constants, types, use-cases/*.ts
  modules/_core/                 Error codes, HTTP constants, catalogues, Zod fields and use-case inputs
  presentation/
    assets/motion/               Published landing-page videos and posters, one folder per locale
    branding/                    Application identity and canonical URL
    components/shadcn/           UI primitives (React Aria; Base UI for the drawer)
    components/custom/           Shared components, and a folder for each part of the site: admin/{page}/, app/, auth/, billing/, blog/, courses/, landing-page/, settings/
    emails/                      Email templates (markup and message namespace only)
    social-card.tsx              Social cards rendered at build time with Takumi
    styles/                      Theme, typography, and local font declarations
  providers/                     Application-wide React providers
  data/                          Constants and literal lists shared by several files, and every menu (navigation.ts)
  hooks/                         Shared React hooks
  lib/                           Utilities and server functions that own no table
  platform/testing/              Test Worker, mocks, RPC helpers, and render helpers

Routes coordinate loading and rendering. Business operations live in table modules and export native TanStack createServerFn functions with query or mutation options. Components consume those options; database and provider clients stay behind server boundaries.

A route file only composes its page: it defines the <Name>Page or <Name>Layout component, const NAMESPACE (page routes) or const NAMESPACES (layout routes), a loader that awaits metadata, messages and the data of its first flush in one Promise.all and streams the rest into the page's skeletons, and head: pageHead(ROUTES.X). Widgets, dialogs, forms, and table columns live in their own files under presentation/components/custom, one per file, and read their own translations and data instead of receiving labels as props. Forms follow the shadcn TanStack Form pattern with the module's Zod schema, show a field's error only once the visitor leaves it or tries to submit (isFieldInvalid, validateOnBlur and submitForm in src/integrations/tanstack-form/), and keep the submit button enabled, moving focus to the first invalid field on a failed submit. Tables use the DataGrid, with a columns hook in an {entity}-columns.tsx file that declares each column's filter, default visibility and pinning. Email templates contain markup only; the use case that sends an email loads its messages and renders the template.

Validate inputs at the server boundary and authorize protected functions themselves, in addition to page guards. Query and mutation keys are readonly tuples owned by the feature's *.constants.ts; include inputs that change the result in the query key. Domain values such as statuses, kinds, tiers, roles and provider IDs are named once in a constant object (PRODUCT_STATUS, LICENSE_TIER, AUTH_PROVIDER) in the owning module's or integration's *.constants.ts, and code, tests and e2e data import it instead of repeating the string. Reuse exported options for cache access, and invalidate only the data a mutation changes. Application documentation lives in content/docs/, including the architecture guides and the conventions, the coding standard every change follows. Coding agents start from AGENTS.md.

Authentication entry points are in src/integrations/better-auth/:

File Responsibility
auth.server.ts Better Auth, providers, every plugin in plugins, the auth emails, which the verification, account and user modules send, and allowed hosts.
auth.access.ts Roles, every permission statement (APP_STATEMENTS), and permission checks.
auth.roles.ts Role codes and the default role.
auth.hooks.ts Input policy run before Better Auth's own endpoints: the password, name, email and image rules.
auth.routes.ts Sign-in/admin guards, the return path after sign-in, and role-based redirects.
auth.middleware.ts Server-function authorization, error handling, rate limiting, and the client address Better Auth's limiter uses.
auth.session.ts Request-scoped session lookup and UI query options.

Authorization shares a fresh session lookup within one HTTP request; a new request checks session storage again. Route guards let a navigation through on a session the browser checked within the last minute (SESSION_STALE_TIME_MS) and check it again once it is older, or as soon as a server function answers UNAUTHORIZED or FORBIDDEN, so a console click waits for no session request. Sign-in and sign-out remove the previous user's cached data, and so do route guards when the authenticated user changes; public queries (meta: { public: true }), such as translations, stay cached. Rate limiting uses atomic D1 operations, writes nothing for a request it refuses and rejects requests when its storage is unavailable. Expired counters are removed in a bounded batch once per counted request; there is no scheduled cleanup Worker. Verification, password-reset and newsletter confirmation emails are also limited to three of each kind per hour for each address, keyed by a SHA-256 of the address; an email over the limit is skipped without an error, and the resend and reset forms read the allowance first and tell the visitor when they can try again instead of claiming a send.

Email-verification links enter /auth/verify-email and redirect to Better Auth's native endpoint; an expired or used link comes back to a page that names its address and leads with a new link. Newsletter confirmation and unsubscribe links open a page that only loads its messages; the action runs when the visitor presses the button, so link scanners cannot confirm or unsubscribe. Success replaces the token URL with a result notice; a failure shows an error and keeps the token for retry.

src/server.ts sets baseline security headers on every Worker response: a Content Security Policy that sets base-uri, frame-ancestors and object-src to 'none', and on HTML pages also a nonce for scripts and a frame-src that allows only Polar's checkout origin for POLAR_SERVER, Cross-Origin-Opener-Policy, Permissions-Policy, Referrer-Policy, X-Content-Type-Options, X-Frame-Options: DENY, and HSTS on HTTPS responses. They are defined once, as SECURITY_HEADERS and HTTPS_SECURITY_HEADERS in src/modules/_core/constants/api.ts, and replace any value already on the response. Static files that bypass the Worker get the same headers from the /* rule in public/_headers, which a test keeps equal to those constants.

Polar's checkout page appends a customer_session_token, which opens the buyer's Polar customer portal, to the success URL. /app and /app/billing, where checkouts return, and /app/license keep only the search params they declare (onlyDeclaredSearch in src/lib/search-params.ts), so the server redirects to the same address without the token before the sign-in guard or the page reads it, and the token never reaches the address bar, a sign-in redirect or a verification email.

Every page also runs only the scripts it was served with, under a strict policy with 'strict-dynamic': every HTML response gets a nonce of its own in its header, which TanStack Start puts on the scripts of a page it renders and an HTMLRewriter puts on the scripts of a prerendered page, so Cloudflare can give it to the scripts it injects at the edge. Each spec of the browser suite fails when a page reports a violation.

Commands and verification

Use bun run test to invoke the configured Vite+ test runner. Running bun test directly does not use this test setup.

Command Purpose
bun run dev Generate content/class-name tables and start development with local bindings.
bun run deps:update Update every dependency with a range to its latest release, Vite+ through vp migrate, the agent skills, and each GitHub Action to the commit of its latest release, together; name the pinned packages that have a newer release.
bun run typegen Generate Worker declarations, class-name tables, and Fumadocs content/types.
bun run check Generate class-name tables; check for comments, localization, docs and blog content, German and Polish glossary terms, the flow inventory, formatting, lint, and types.
bun run check:comments Fail on any comment in a TypeScript, JavaScript, CSS, or YAML file except a one-line link to where the reason lives or a pinned action's version tag, including the browser suite, the stylesheets, and the workflows that the linter skips.
bun run check:flows Fail when a flow in e2e/data/<feature>.flows.ts names a browser test that is gone or skipped, or does not say why it is missing.
bun run check:fix Run checks and apply supported formatting/lint fixes.
bun run check:skills Fail when a package that an agent skill documents moved without bun run skills:update, or when the installed skills differ from skills-lock.json.
bun run check:types Type-check every file that tsconfig.json includes with tsc --noEmit, the browser suite in e2e among them, as the last step of bun run check; vp check type-checks only the files its linter reads.
bun run check:i18n Validate message parity, scoped translation keys, unrendered keys, ICU formats, forms of address, no-break spaces and the closing punctuation of headings.
bun run check:content Validate the localized docs, blog and changelog content: translated fields, quoted source, links, routes, forms of address, the no-break spaces of the docs and blog, and the search titles and descriptions of the docs and the comparison posts.
bun run check:glossary Fail on German or Polish copy that uses a term from a never column of its locale's glossary (src/data/german-glossary.ts, src/data/polish-glossary.ts), in any inflected form, with its file, line and the preferred term.
bun run check:features Delete the optional features of each scenario in scripts/features.ts, or of the scenarios named, prune every reference to them, then format, type-check and check the translations of the site that is left; fails on any reference that cannot be pruned, in CI too.
bun run test Run node, integration, and component test projects.
bun run test:unit / bun run test:integration / bun run test:component Run one test project.
bun run test:watch / bun run test:changed Watch tests or run tests affected by changes.
bun run test:coverage Run tests with the configured coverage gate and reports.
bun run test:e2e:install Install Chromium/WebKit and their Playwright dependencies.
bun run test:e2e Run the browser suite in Chromium and WebKit.
bun run test:e2e:pr Run the browser suite in Chromium, as the Chromium check of pull request CI does.
bun run test:e2e:smoke Run the Chromium smoke suite.
bun run test:visual Compare screenshots of the landing page, a blog post, a docs page and both workspaces with the approved ones, in Chromium inside Playwright's Docker image.
bun run test:visual:update Rewrite the screenshots that no longer match after an intended change to the layout or the copy, to review and commit.
bun run test:all Run the Vite+ tests followed by Chromium smoke tests.
bun run test:journey Buy each tier on preview with the Polar sandbox, use the published CLI with each licence, and upgrade Core to Complete for the difference.
bun run build / bun run build:preview Build the preview Worker, prerender public pages, and verify/optimize output.
bun run build:production Build and verify the production application.
bun run build:test / bun run start:test Build or serve the isolated test application.
bun run start Serve the most recently built application at 127.0.0.1:3000.
bun run video:encode:<development|test|preview|production> Encode the recordings uploaded in the lesson editors with FFmpeg, then upload them and put each on its lesson with your wrangler login.
bun run video:landing:render / bun run video:landing:studio [locale] Render the landing page videos and posters in every locale, or the compositions and locales named, with Remotion; or open Remotion Studio in one locale.
bun run video:publish:preview / bun run video:publish:production Encode a recording with FFmpeg, then upload and register it with your wrangler login.

Run the commands from the root package scripts; the Remotion commands run inside remotion/.

Test architecture and coverage

Unit and integration tests run in Node; component tests run in jsdom. Tests are colocated in src/**/__test__/. The test RPC helper exercises TanStack validation and middleware, and the D1 adapter applies the checked-in SQLite migrations. External provider operations are mocked. See the testing guide for fixtures and ownership conventions.

Coverage includes TypeScript application code under src, including routes, custom components, providers, and integrations. Exclusions cover tests/fixtures, test infrastructure, generated router/declaration files, and shadcn primitives. The configured gate requires 100% statements, branches, functions, and lines for the included code. This is a test requirement, not a claim that every product workflow is complete. Read measured results in coverage/index.html and coverage/coverage-summary.json; Playwright does not contribute to this report.

Flow coverage is reported on its own. Each feature lists its user and admin flows in e2e/data/<feature>.flows.ts, and FLOWS in scripts/check-flows.ts imports each of those lists: a flow is covered when it names the Playwright test that performs it end to end and asserts its outcome, missing when the feature exists without such a test, and to build when the feature does not exist yet; the last two say why. bun run check runs scripts/check-flows.ts, which lists the browser suite and fails when a flow names a test that is gone or skipped, so renaming a test without its flow fails CI. The Test coverage docs page prints how many flows are covered, every flow with its test, and the gaps.

Browser tests and CI

bun run test:e2e:install
bun run test:e2e

Locally, Playwright recreates the test database with db:reset:test, builds the test application, and starts its preview server unless an existing server already answers at the configured URL. PLAYWRIGHT_BASE_URL overrides the default http://127.0.0.1:3000 and is the one place to choose the port. The test build trusts port 3000 and ports 3020 to 3029 (TEST_SERVER_PORTS in src/data/local-server.ts), and playwright.config.ts refuses any other before it builds. To run the suite beside other worktrees, pick a port in that range on which lsof -nP -iTCP:3027 -sTCP:LISTEN prints nothing, and run it there:

PLAYWRIGHT_BASE_URL=http://127.0.0.1:3027 bun run test:e2e:pr

Leave a server you did not start alone and take another port. Outside CI, e2e/global-setup.ts stops the run before the first test when the server on the port runs from another directory, so Playwright never reuses another worktree's server. See Running beside other worktrees.

bun run test:journey runs the journey suite in e2e/journey/ against the preview deployment instead, by hand or through the Journey workflow: it signs up through Resend's test inbox, buys each tier in the Polar sandbox checkout over the licence page with Stripe's test card, and activates, fills, frees and deactivates machines with the published CLI until a refund ends the licence. A fourth test upgrades Core to Complete for the difference, checks that the key keeps working with Complete's machine limit while the upgrade order's own key is disabled, and refunds the upgrade back to Core. It reads the Polar sandbox token and product IDs and a full-access Resend key from the environment or .env.preview; see Journey suite.

e2e/specs/accessibility.spec.ts runs axe-core with the WCAG 2.0, 2.1 and 2.2 A and AA rules and axe's best practices on the public pages, the course pages, the docs home, every Conventions page and one page from each other docs section, a blog post, and both workspaces in the light and dark themes, and fails on any violation.

e2e/specs/visual-landing.spec.ts and the other visual-*.spec.ts specs compare the landing page's sections, header and footer, a blog post's author card and call to action, a docs page, /admin, /admin/settings and /app/billing with the approved screenshots in e2e/specs/__screenshots__/, so a heading that wraps differently, an extra card or a moved section fails CI. scripts/visual-tests.ts runs the browser in Playwright's Docker image on a laptop and in CI alike, so baselines taken locally match CI; see Visual tests.

build:test selects env.test in the root wrangler.jsonc using CLOUDFLARE_ENV=test. It uses the test Worker entry, local bindings, .env.test, and .wrangler/test; no separate test Wrangler file or E2E=true flag is needed. In CI, one job runs db:reset:test and build:test and uploads the build with its seeded state, and the suite runs on ten parallel shards inside Playwright's Docker image for the installed version, which carries the browsers and their system packages, so the shards install neither; they start only once the build has finished, so none of them holds a runner while it waits, and download its archive with GitHub's download-artifact action, which checks it against its digest, before Playwright starts the server; a failed build skips every shard; one Build and E2E (<browser>) check for each browser, Chromium and WebKit, passes only when its build, every one of its shards and, for Chromium, the visual job pass, and a failed shard's blob report is merged into one HTML report.

  • Main CI runs checks, coverage, E2E in Chromium and in WebKit and an upload of the preview Worker as a version that serves no traffic, on pull requests and on the merge queue's groups. The tests with coverage run on four parallel shards that each upload a Vitest blob report; one Format, lint, types, i18n, tests check merges them, enforces the coverage thresholds on the merged result and passes only when bun run check, every shard, the merge and every scenario of bun run check:features pass. A new commit cancels a pull request's run for the commit it replaces.
  • Deploy deploys each push to main to the shared preview and then to production, and tags and releases each successful production deploy on GitHub. It skips the checks for a commit the merge queue tested and runs them for any other. Its runs queue and never cancel one another.
  • Preview deploys a branch to the shared preview by hand, once its commit has passed the checks main requires.
  • Full E2E runs WebKit again on pushes to main and Chromium and WebKit weekly and on manual dispatch.
  • Journey runs the journey suite against preview every night and on manual dispatch (gh workflow run journey.yml -f journey=all, or core, complete, agency or upgrade for one test), with the Polar sandbox and Resend secrets of the GitHub Preview environment, and writes each test's result to the job summary. It does not run after each deploy, because preview shares its Resend account with production.
  • Updates looks for dependency, agent skill and GitHub Actions updates every week and keeps one GitHub issue listing them, which it opens, rewrites and closes; it opens no pull request, so run bun run deps:update on a branch.
  • Video CI separately checks and bundles the Remotion project when remotion/ or a website file it imports changes, directly or through other website files; src/__test__/workflows.test.ts fails when its trigger paths miss such a file or name a path that none of them matches.

Every action from another repository is pinned to the full commit SHA of a release, with the release tag in a comment after it (uses: <owner>/<repo>@<commit> # <tag>); src/__test__/workflows.test.ts fails on a tag, a branch or a missing tag comment, and bun run deps:update moves each action to its latest release through scripts/github-actions.ts.

The deployment workflow records actual deployment results in GitHub's Preview and Production environments. Configure its credentials as described below before enabling deployments.

Database and deployment

Provision Cloudflare resources

For a new Cloudflare account, create a preview database, KV namespace, and R2 buckets:

bunx wrangler login
bunx wrangler d1 create saasyland_com_preview
bunx wrangler kv namespace create CACHE --env preview
bunx wrangler r2 bucket create saasyland-preview
bunx wrangler r2 bucket create saasyland-bundles-preview

Replace database_id, database_name, the KV namespace id, and the bucket_name of MEDIA and BUNDLES under preview in wrangler.jsonc. Keep the binding names DB, CACHE, MEDIA, and BUNDLES, and preserve migrations_dir. The development environment binds local resources and needs no change. Update Worker names and custom-domain routes for your account.

Create separate production resources with saasyland_com_production, bunx wrangler kv namespace create CACHE --env production, bunx wrangler r2 bucket create saasyland, and bunx wrangler r2 bucket create saasyland-bundles, then update the production bindings. The BUNDLES buckets hold the CLI's template bundles, each with the SHA-256 of its content as its sha256 custom metadata, which the licence API answers with instead of reading the archive; the CLI repository's release uploads them to both; see Publishing bundles. The deployment guard rejects missing bindings, placeholder IDs, and a production environment that shares its database, namespace, or bucket with preview; it does not verify that the existing IDs belong to your account or that the R2 buckets exist, and a deploy fails while a bound bucket is missing.

Migrations

Module schemas are collected by drizzle.schemas.ts, and every table with createdAt and updatedAt spreads them from timestamps() in drizzle.columns.ts. Generate migrations with:

bun run db:generate

Review and commit SQL files under src/integrations/drizzle-orm/migrations/ with their schema changes. The deployment scripts and CI apply the target's migrations before deploying; apply them to the local databases yourself.

Command Database affected
bun run db:migrate:local Local development database under .wrangler/state, used by bun run dev.
bun run db:reset:local Deletes the local development database, then migrates it.
bun run db:seed:local Seeds the local development database: the admin, the curriculum, licences, and an order.
bun run db:migrate:test Local test database in .wrangler/test.
bun run db:reset:test Deletes .wrangler/test, then migrates and seeds the local test database.
bun run db:migrate:preview Remote preview database.
bun run db:migrate:production Remote production database.
bun run courses:sync:preview Remote preview database: copies production's published courses.
bun run orders:backfill-amounts:local, bun run orders:backfill-amounts:preview, bun run orders:backfill-amounts:production The local, remote preview or remote production database: shows the subtotal, net amount and refunded tax of orders mirrored before they were kept, from Polar, and copies them with --apply.
bun run orders:backfill:local, bun run orders:backfill:preview, bun run orders:backfill:production The local, remote preview or remote production database: copies the discount and billing country of orders mirrored before they were kept, from Polar.
bun run admin:grant:local, bun run admin:grant:preview, bun run admin:grant:production The local, remote preview or remote production database: grants one verified account the admin role (The first admin).

db:migrations:local, db:migrations:preview, and db:migrations:production list the migrations each database has not applied yet, without changing anything. db:studio:local opens Drizzle Studio on the local SQLite file that the dev server uses, which scripts/studio-local.ts locates under .wrangler/state/v3/d1/. db:studio:preview and db:studio:production open it on a remote database using the corresponding environment file, and the matching db:introspect:* scripts introspect D1 through its HTTP API; set the three CLOUDFLARE_* credentials to the target account/database for these tools. The full guide is Database.

Course data

Locally, bun run db:seed:local imports content/courses/saasy-land-courses.json. On production an admin imports the same file: Content → Courses, Import, choose the file, Check file, then Import. Importing it twice changes nothing.

Preview gets production's courses from bun run courses:sync:preview (after bunx wrangler login). scripts/sync-courses.ts reads production with SELECT statements only and copies every published course with its chapters, lessons and link attachments, by id, so running it again changes only what production changed. Lessons new to preview start without a video and show as being recorded, and the others keep preview's videos, because the recordings stay in production's bucket; videos, uploads, file attachments, users, sessions, licences, orders, subscriptions and progress are never copied. See Copying the courses to preview.

The first admin

The application has no endpoint, seed, or variable that grants the admin role. On preview and production, create the first admin with:

bunx wrangler login
bun run admin:grant:production [email protected]

Sign up on the site with that address and verify it first. scripts/grant-admin.ts reads the account with wrangler d1 execute --remote, prints it before and after, refuses an unknown, unverified, or banned account, and changes only that account's role. It is the only way to create the first admin, and it is safe: only someone who can write to that Cloudflare account's D1 database can run it, with their own wrangler login; the application enforces roles on the server (requireAdmin and authorized(...) on every admin server function); and later admins are granted in Administration → User management with Change role by an existing admin, or invited there with the admin role.

Automatic GitHub deployments

Pull requests reach main only through GitHub's merge queue, which tests each one again on top of main and the pull requests ahead of it. Put a green pull request in the queue with bun scripts/enqueue-pr.ts <number>: it gives the title the commit hook's emoji, which the squash commit on main keeps, and runs gh pr merge --auto --squash. Every pull request and every merge group uploads the preview Worker as a new version without deploying it, which proves that Cloudflare accepts the upload, its size and its bindings, while the preview keeps serving main.

The Deploy and Preview workflows deploy only a commit that passed formatting, lint, types, localization, coverage, E2E in Chromium and in WebKit and the Worker upload:

Event Cloudflare target GitHub environment URL
Push to main, from the merge queue saasyland-preview (preview), then saasyland (production) Preview, then Production https://preview.saasyland.com, https://saasyland.com
Manual run of the Preview workflow saasyland-preview (preview) Preview https://preview.saasyland.com

Preview is a shared environment that runs main: each deployment replaces the previous preview, using the same preview D1 database, KV namespace, and R2 bucket, and every migration reaches it before production. It does not create a separate Worker or database for each PR. To try a branch there before it merges, run gh workflow run preview.yml --ref <branch> once its checks passed; the next push to main puts main back. Fork and Dependabot PRs skip the Worker upload, which needs the Cloudflare credentials, and the merge queue uploads their build before they merge.

In repository Settings → Environments, configure the existing Preview and Production environments with these secrets:

Secret Purpose
CLOUDFLARE_API_TOKEN Wrangler authentication with permission to deploy the Worker, manage its configured bindings/routes, and apply D1 migrations. Scope the token to the intended account and zones.
CLOUDFLARE_ACCOUNT_ID Cloudflare account containing the selected Worker, D1 database, KV namespace, and R2 bucket.

These are deployment credentials. CLOUDFLARE_API_TOKEN is separate from the CLOUDFLARE_ACCESS_TOKEN used by Drizzle Studio. Repository secrets with the same names can be used as a fallback; environment-specific secrets allow different credentials for preview and production. Follow Cloudflare's GitHub Actions authentication guide when creating the token.

The existing Workers must already have all runtime secrets required by wrangler.jsonc. CI builds with committed dummy credentials from .env.test because prerendering initializes provider clients, while still selecting the real preview/production configuration and Worker entry. It removes the generated local .dev.vars file before deployment. No real provider credentials are needed in GitHub, and no secrets file is uploaded: Wrangler inherits the selected Worker's existing secrets. A new Worker still needs the initial provisioning described in the manual deployment section.

Deployment jobs build and verify artifacts, apply the target D1 migrations, deploy the tested revision, then run the live site check (scripts/verify-deployment.ts) that the manual deployment scripts run, which fails the job when the deployed site does not answer as expected, so a failed check on preview stops the production deploy. They do not run any of the deploy checks the features declare (scripts/run-deploy-checks.ts; today auth:verify and polar:verify), because CI has no .env.<environment> and GitHub holds only the Cloudflare deployment credentials and, in Preview, the journey suite's sandbox settings. The URL each GitHub environment links to is typed in the workflow, and src/__test__/workflows.test.ts fails when it differs from the environment's host in DEPLOYED_HOSTS. Runs on main, merge queue runs, and deployments never cancel one another, with a separate deployment queue per environment; only a pull request's superseded run is cancelled. Schema changes must remain compatible with the currently running application because migrations run before the new Worker is deployed. WebKit's additional main-branch suite runs independently of the production deployment gate.

GitHub creates deployment records from the job's environment declaration and shows the job's real result. See GitHub's deployment tracking documentation.

After a production deploy succeeds, the release job tags the deployed commit vYYYY.MM.DD with the UTC date (later deploys that day get .2, .3, and so on) and publishes a GitHub Release whose notes are the changelog entries that release shipped since the previous release tag, each ending with its pull request's number. The production deploy chooses that tag before it builds, so the changelog it ships links each entry to the first release that shipped it. It is the only job with contents: write, and preview deploys are never tagged. The changelog dates each entry by the squash commit that brought its pull request to main, and the sitemap dates every page by the last commit that changed its sources, so the checkouts that build the site and the release job clone the whole history (fetch-depth: 0, in one request that the checkout action retries when it fails). In CI, the build fails while the changelog would list an entry as unreleased that is not the pull request's own, or any entry in the merge queue or on main. CI/CD explains how to roll back to a release.

Keep this workflow the only deployment owner: disable automatic deploy triggers in Cloudflare Workers Builds so a push does not deploy twice or bypass the CI gate. Worker source maps are not uploaded (upload_source_maps: false in wrangler.jsonc), because they pushed the upload past Cloudflare's size limit. Production environment branch rules can restrict deployment to main; preview rules must allow PR merge refs, the merge queue's gh-readonly-queue/main/* branches, whose upload jobs read the Preview credentials, and the branches you deploy with the Preview workflow. Required environment reviewers, if configured, pause deployment until approval.

Manual preview and production deployment

After provisioning resources and configuring domains and secrets:

cp .env.example .env.preview
# Fill in preview secrets and sandbox provider settings before continuing.
bun run deploy:preview

For production:

cp .env.example .env.production
# Fill in production secrets and live provider settings before continuing.
bun run deploy:production

Each deployment script verifies the bindings, writes the secrets that wrangler.jsonc declares for that environment from the environment file to .wrangler/secrets.<environment>.json, failing if any is empty or a placeholder such as [UPDATE] or TODO, runs every <name>:verify:<environment> script in package.json (scripts/run-deploy-checks.ts; today auth:verify, which checks that the GitHub and Google client IDs have their providers' formats, and polar:verify, which checks that the environment's Polar organisation matches the code), builds the selected environment, checks the generated artifacts, optimizes prerendered HTML, and writes the sitemap and social cards. It then applies the environment's D1 migrations, deploys dist/server/wrangler.json (the configuration the Cloudflare Vite plugin generates) with that secrets file, and finally checks the live site: it requests the paths that LIVE_SITE_CHECKS names in src/lib/deployment.ts: /, /courses, /robots.txt, /.well-known/security.txt, /sitemap.xml, /sitemap-pages.xml, /sitemap-courses.xml, /blog/rss.xml, /images/og/site.png, /images/logo.png, /api and /api/auth/get-session, and starts the GitHub and Google sign-in through /api/auth/sign-in/social as the browser does, failing unless each provider's authorize URL is on that provider's host and carries a client ID in that provider's format and a callback to the same host. It retries each failing check twice. Builds alone do not apply remote migrations or deploy resources.

Public pages are prerendered to dist/client; protected, authentication, newsletter-action, course, and API routes are excluded from prerendering. After prerendering, scripts/deployed-worker.ts builds the Worker that is deployed again, without the rendered MDX of docs and blog pages and without the landing and legal page translations, which only prerendered pages use. The build verifier checks the Worker deployment configuration, localized home/legal pages and SEO links, that every docs page and published blog post was prerendered, fonts, client JavaScript, and selected route exclusions. scripts/generate-seo-files.ts then reads the head of every prerendered page and writes dist/client/sitemap-pages.xml, the sitemap index dist/client/sitemap.xml, the blog's RSS feed in every language (dist/client/blog/rss.xml and its localized copies), the organisation's logo and one social card per page under dist/client/images/og/, and, in every build mode but production, a dist/client/robots.txt that disallows every path, so the preview deployment keeps crawlers out as well as carrying noindex; the Worker serves them all from static assets. The application still requires a Worker for server-rendered routes, authentication, APIs, video delivery, and locale handling.

Localization and content

The supported locales are en-US, de-DE, es-ES, fr-FR, it-IT, ja-JP, pl-PL, pt-BR, and uk-UA, defined in i18n.config.ts.

English uses unprefixed paths. Other languages use the full locale, such as /de-DE/docs or /pl-PL/blog; short aliases redirect to canonical paths. Switching language opens the current path in the chosen language; the query string and fragment are not carried over. The locale always comes from the URL path, so server functions that need it receive it as input, because their /_serverFn URLs carry no locale prefix.

  • Store UI messages in messages/{locale}/, using the same keys, ICU arguments, rich-text tags, file paths, and commands across locales and each language's plural categories.
  • Store documentation and blog content as slug.{locale}.mdx under content/docs and content/blog, and each pull request's changelog entry as {number}.{locale}.mdx under content/changelog; localized navigation uses meta.{locale}.json.
  • Translate frontmatter, visible component attributes, FAQ entries, and body text. Preserve slugs, inline code, MDX components and their untranslated props, code examples, table rows, and link destinations; bun run check:content compares them with English.
  • Write internal links in content as the paths the site serves, such as /docs/cli or /#pricing: no locale, no trailing slash, /index or .html. MDX links add the page's locale with localizeHref, which keeps the query and fragment, and bun run check:content rejects a link the site would redirect.
  • Every page route owns one namespace (const NAMESPACE = "pages.x", with metadata.title and metadata.description for its head); layout routes preload the namespaces their subtree shares. Root namespaces (common, components.*, errors*) load for every page, and the translations provider wraps the whole document so error screens are translated too.
  • Use one useTranslations per component and name the translator t. A later useTranslations call re-scopes every following t() for i18n-ally, and bun run check:i18n fails on keys that do not resolve in their scope.
  • Link with <Link to={ROUTES.X}>; the router adds the locale prefix. For a raw URL in the current locale, such as an authentication callback, use router.buildLocation(...).publicHref; for a URL in a given locale, such as an email link, use localizePathname.
  • Email messages live in emails.* namespaces and are loaded by the sending use case, never by browser code.
  • Address the reader one way in each locale, in the form that FORMS_OF_ADDRESS in forms-of-address.ts names; bun run check:i18n rejects the forms that contradict it.
  • Keep a number with the word after it, and a separator or a dash with the word before it, through a no-break space, U+00A0; bun run check:i18n fails an ordinary space there. See No-break spaces.
  • Put a no-break space, U+00A0, between a number and the percent sign in German, Spanish and French, and no space in the other locales; bun run check:i18n and bun run check:content fail an ordinary space before the sign in German, Spanish and French and any space in the other locales. See No-break spaces.
  • Join the words of a product name with a no-break space, U+00A0, in messages and in the title and metaTitle of docs pages and blog posts; PRODUCT_NAMES in src/lib/product-names.ts lists the names, and bun run check:i18n and bun run check:content fail another space there. See No-break spaces.
  • Never join a number to its word, or one abbreviation to another, with a hyphen, after which a line can break: Geist has no glyph for the non-breaking hyphen, so reword (a call of {callMinutes, number} minutes, Umsatzsteuer-ID for USt-IdNr.); bun run check:i18n fails both. See No-break spaces.
  • Write German and Polish copy with the terms of the German style guide and the Polish style guide; bun run check:glossary rejects a term from a never column of its locale's glossary.
  • Run bun run check:i18n, bun run check:content and bun run check:glossary after changes. Builds additionally verify localized home and legal-page output.

Fumadocs generates .source/; edit the source MDX and catalogues instead of generated output. The public legal routes are /privacy, /terms, /refunds, /withdrawal, /licence, and /affiliates. Review their content when adapting the application to a different business.

Performance

PageSpeed Insights results for https://saasyland.com/, measured on 2 December 2026 with Lighthouse 13.6.0.

Mobile (emulated Moto G Power, Slow 4G throttling)

PageSpeed Insights mobile scores: Performance 100, Accessibility 100, Best Practices 100, SEO 100, Agentic Browsing 3/3

Desktop

PageSpeed Insights desktop scores: Performance 100, Accessibility 100, Best Practices 100, SEO 100, Agentic Browsing 3/3

Metric Mobile Desktop
First Contentful Paint 1.2 s 0.3 s
Largest Contentful Paint 1.2 s 0.4 s
Total Blocking Time 40 ms 50 ms
Cumulative Layout Shift 0 0
Speed Index 1.9 s 0.8 s

These are lab results. PageSpeed Insights runs on shared hardware, so scores vary between runs; compare several runs before judging a change. Run the analysis for current results.

The following decisions produce these results. Review them before changing the related code:

  • Public pages are prerendered. Every page, prerendered or rendered for each request, carries one modulepreload hint, for its own entry script at low priority: DocumentHead drops the dependency hints TanStack Start emits, so the stylesheet and fonts load first. The script policy keeps that order: the Worker only adds each response's nonce to the entry script and its hint.
  • The Worker's Link header names only the locale's fonts, whose file names stay the same across deploys. Cloudflare replays a page's last Link header as 103 Early Hints, also after a deploy, so a hinted stylesheet, which Vite names after its content, would point at a deleted file. In the zone's Speed settings Early Hints stays on and Speed Brain is off, because Cloudflare refuses its prefetches of pages that run the Worker; see Cloudflare Workers.
  • Once a page has loaded and the browser is idle, the site header preloads the code and data of its pages through TanStack Router, so a click on Pricing, Courses, Blog, Docs or Sign in waits neither for a new Worker isolate nor for its server functions. It preloads nothing with data saver on, nor for a crawler until something interacts with the page, and other links keep preloading on hover; see Performance.
  • Providers whose value changes after hydration, such as the theme and Motion providers, wrap only their consumers and never a route <Outlet />. A change above a route's Suspense boundary forces that route to hydrate synchronously in one long task, or to render on the client and shift the layout.
  • robots.txt and llms.txt are static files that bypass the Worker through run_worker_first in wrangler.jsonc. Lighthouse fails the SEO and Agentic Browsing audits for these files when the requests time out.
  • src/server.ts serves prerendered pages from static assets and imports the TanStack Start handler only for other requests, so page requests do not load the full server bundle. Its static imports stay free of TanStack Start and provider SDKs, because a cold Worker evaluates them before it can answer.
  • The deployed Worker leaves out what only prerendering needs: scripts/deployed-worker.ts rebuilds it after prerendering without the compiled docs and blog pages and without the landing and legal page translations, which keeps the upload well below Cloudflare's Worker size limit. The docs, the blog and the docs search read indexes that scripts/content-indexes.ts builds into static assets, so they never wait for a Worker isolate; see Performance.

Landing page videos

remotion/ contains editable video compositions with a separate npm toolchain. Install it only when editing videos:

cd remotion
npm ci
npm run check

bun run video:landing:studio [locale] opens Remotion Studio in one locale; Remotion Studio runs on port 3001. Every video shows the website's own messages in each of its locales, and bun run video:landing:render renders them all, or the compositions and locales it names, into src/presentation/assets/motion/<locale>/, with full-size and responsive posters; Vite emits them with content hashes under /assets/, and the landing page loads only the video and posters of its own locale. The course tour, which plays on request with controls, also ships an MP4 and AVIF posters. Keep the source and published assets in Git. Editor dependencies, bundles, caches, and temporary renders are ignored.

Normal application builds serve the checked-in assets without installing Remotion or rendering videos. Follow the rendering instructions when updating a composition or the messages it shows, and regenerate its video and posters together.

Contributing

Read CONTRIBUTING.md and the Code of Conduct before contributing, and SUPPORT.md for where to get help. Report vulnerabilities privately as SECURITY.md describes, not in a public issue.

Follow the conventions and the architecture guides, and use the existing theme, typography and radius definitions: every corner takes rounded-lg, rounded-md, rounded-sm or rounded-full by the kind of element, and the radius/no-off-scale lint rule fails bun run check on any other radius (see Theme); text sizes come from the theme's type scale, which type/no-off-scale enforces, and code is set in the mono face, which type/mono-for-code enforces. Keep tests beside their owner, update localized content and documentation under content/docs/ when changing user-facing behavior, and add the pull request's changelog entry, content/changelog/<number>.<locale>.mdx in every locale, once it has its number (see Changelog entries).

Before opening a pull request, run the checks relevant to your change. The application verification sequence is:

bun run check
bun run test:coverage
bun run build:test
bun run test:e2e:install
bunx playwright test e2e/specs/<spec>.spec.ts --project=chromium

The last command builds the local test application when it starts its own server and runs the specs you name in Chromium: run the ones that cover your change. CI runs every spec in Chromium and in WebKit on the pull request and again in the merge queue, and the pull request merges only when both browsers pass; bun run test:e2e:pr runs every spec locally in Chromium. Run bun run test:e2e as well for changes that may behave differently in WebKit. Use the isolated test build for provider-independent checks, and validate real provider integrations separately when changing their configuration.

Optional agent guidance can be restored with bun run skills:sync. It rebuilds .agents/skills from skills-lock.json, groups skills by vendor, and links them into .claude/skills; bun run skills:update moves every skill to the latest commit of its source first. bun run deps:update updates the dependencies and the skills together, and bun run check fails when a package that a skill documents moved without a skills update or when the installed skills differ from the lock; see Agent skills. The command replaces those local skill directories; keep custom guidance elsewhere.

For documentation corrections, verify commands and links against the implementation. For feature changes, describe the resulting behavior, relevant validation, and any workflow left incomplete in the pull request. An admin screen ships only with a real source for its data.

Licensing

The website source code and associated technical documentation, including account, checkout, and licence-management code, are covered by the MIT licence in LICENSE and the scope statements in LICENSING.md. A commercial purchase is not required to reuse the MIT-covered website code.

SaaSy Land's original logos and brand artwork are excluded from that grant, and no rights to the SaaSy Land name or trademarks are granted. Generic interface components remain covered; third-party assets retain their own licences. Reuse must not imply that a fork is the official service or has its endorsement. Previously granted MIT and other third-party permissions remain in effect.

The separately maintained CLI, private generator templates, and separately supplied paid learning/design material are proprietary. Their use is governed by the commercial product agreement, presented on /licence, rather than this repository's MIT grant. A purchase and valid licence key are required for the CLI; generated applications do not require a runtime licence key. The website checks licence keys and machine activations for the CLI through its licence API; the private CLI's installation and generation are not part of this repository.

関連プロジェクトを探す

読み込み中…