readme

Rainfall Game Studio Website

A premium, interactive website for a startup game company focusing on multiplayer experiences. Built with SvelteKit, Svelte 5, TypeScript, Drizzle ORM, Cloudflare D1, Better Auth (GitHub OAuth), and UploadThing.


⚠️ FOR AI AGENTS & COLLABORATORS

Before making any updates or additions to this project:

  1. Always read this README first for the most up-to-date environment configuration, schema definitions, and migration guidelines.
  2. Keep this README updated if you add new features, environment variables, database fields, or deployment steps.

Project Configuration

1. Environment Variables (.env)

Create a .env file in the root directory (based on .env.example):

# Cloudflare D1 Credentials (for remote drizzle-kit access)
CLOUDFLARE_ACCOUNT_ID="your-cloudflare-account-id"
CLOUDFLARE_DATABASE_ID="0c825123-e9b5-4121-b204-760f91bbacba"
CLOUDFLARE_D1_TOKEN="your-d1-api-token"

# Base Server URL
ORIGIN="http://localhost:5173"

# Better Auth Secret (Generate a high-entropy 32-character string)
BETTER_AUTH_SECRET="02ad68bd-077d-435b-a6d8-3ea36e088090"

# GitHub OAuth Credentials
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
# Admin access: active members of this GitHub org (https://github.com/Rainfall-7)
GITHUB_ORG="Rainfall-7"

# UploadThing Token (For client-side file uploads)
UPLOADTHING_TOKEN="your-uploadthing-token"

# Local Development Helpers
BYPASS_ORG_CHECK="true" # Set to true to bypass GitHub Organization membership check in dev

2. GitHub OAuth App Setup

To enable authentication:

  1. Go to your GitHub account settings -> Developer Settings -> OAuth Apps -> New OAuth App.
  2. Homepage URL: http://localhost:5173 (or production URL).
  3. Authorization Callback URL: ${ORIGIN}/api/auth/callback/github.
  4. Copy the Client ID and Client Secret into your .env file.
  5. In production, ensure the user is an active member of the Rainfall-7 GitHub organization (GITHUB_ORG) to access /admin. In local development, you can set BYPASS_ORG_CHECK=true in .env to skip this verification.

If admin says you're missing read:org, visit /auth/reauthorize (or use the button on the admin page). That revokes the old GitHub authorization and sends you through OAuth again so GitHub prompts for organization access. A normal sign-out/sign-in often will not re-prompt.

3. UploadThing Setup

  1. Log in to the UploadThing Dashboard.
  2. Create a new app named Rainfall.
  3. Copy the API Key Token and set it as UPLOADTHING_TOKEN in your .env.

Database Management & Migrations

We use Drizzle ORM coupled with Cloudflare D1.

Local D1 Development Migrations

Wrangler emulates D1 locally. Follow these steps when schemas change:

  1. Generate migration SQL files:
    bun run db:generate
    
  2. Apply migrations to the local database:
    bunx wrangler d1 migrations apply DB --local
    
  3. Apply migrations to the remote production database:
    bunx wrangler d1 migrations apply DB --remote
    

Developing & Running

Install Dependencies

bun install

Start Development Server

bun run dev

Build & Preview Production Pages locally

bun run build
bun run preview
← Back to Blog

© 2026 Rainfall Game Studio. All rights reserved.