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:
- Always read this README first for the most up-to-date environment configuration, schema definitions, and migration guidelines.
- 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:
- Go to your GitHub account settings -> Developer Settings -> OAuth Apps -> New OAuth App.
- Homepage URL:
http://localhost:5173(or production URL). - Authorization Callback URL:
${ORIGIN}/api/auth/callback/github. - Copy the Client ID and Client Secret into your
.envfile. - In production, ensure the user is an active member of the
Rainfall-7GitHub organization (GITHUB_ORG) to access/admin. In local development, you can setBYPASS_ORG_CHECK=truein.envto 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
- Log in to the UploadThing Dashboard.
- Create a new app named
Rainfall. - Copy the API Key Token and set it as
UPLOADTHING_TOKENin 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:
- Generate migration SQL files:
bun run db:generate - Apply migrations to the local database:
bunx wrangler d1 migrations apply DB --local - 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