f1 predict
live
./docs / deployment

Deployment

Overview

LayerPlatformHow it deploys
web/Cloudflare PagesPush to master → GitHub integration auto-builds
api/Cloudflare WorkersPush to master → GitHub integration auto-builds
data-engine/RenderCron jobs triggered on schedule
DB migrationsNeonManual — run locally via drizzle-kit

Never run wrangler deploy or bun run deploy from the CLI. Push to GitHub and let Cloudflare pick it up automatically.


Environment Variables

API — Cloudflare Workers Dashboard

VariableHow to setNotes
DATABASE_URLWorkers → Settings → Variables and Secrets → SecretNeon connection string

keep_vars = true is set in api/wrangler.toml so deploys never erase dashboard-set variables.

Set this as a Secret (not plaintext) so it’s encrypted at rest.

Frontend — Cloudflare Pages Dashboard

VariableHow to setNotes
PUBLIC_API_URLPages → Settings → Environment VariablesFull Worker URL

Example value: https://f1-intelligence-api.gorkemkaryol.workers.dev

keep_vars = true is set in web/wrangler.toml.

Data Engine — Render Dashboard

VariableHow to set
DATABASE_URLRender → Service → Environment → Environment Variables

CORS

The API allows requests only from:

  • https://f1.gorkemkaryol.dev (production)
  • http://localhost:4321 (Astro dev)
  • http://localhost:8787 (Wrangler dev)

Configured in api/src/main.ts. Only GET and OPTIONS methods are allowed.


First-Time Setup

1. Database

cd db
bun install
# Set DATABASE_URL in your shell or .env
bun run drizzle-kit push    # applies schema to Neon

Then seed circuits and seasons:

cd data-engine
source venv/bin/activate
python src/main.py --job sync_schedule --year 2025
python src/main.py --job sync_season   --year 2025 --round 1

2. API (Cloudflare Workers)

  1. Connect the api/ directory to a Cloudflare Worker via the GitHub integration in the Cloudflare dashboard.
  2. In the Worker’s dashboard, add DATABASE_URL as a Secret.
  3. Push to master to trigger the first deploy.

3. Frontend (Cloudflare Pages)

  1. Connect the web/ directory to Cloudflare Pages via the GitHub integration.
  2. Set build command: bun run build
  3. Set output directory: dist
  4. Add environment variable PUBLIC_API_URL pointing to your Worker URL.
  5. Push to master to trigger the first deploy.

4. Data Engine (Render)

  1. Create a new Render service from the data-engine/ directory.
  2. Add DATABASE_URL as an environment variable.
  3. Configure cron jobs:
    • python src/main.py --job ingest_qualifying && python src/main.py --job compute_features && python src/main.py --job compute_predictions — Saturday 22:00 UTC
    • python src/main.py --job ingest_race && python src/main.py --job compute_season_stats — Sunday 18:00 UTC

Production Domain

Frontend: https://f1.gorkemkaryol.dev (custom domain on Cloudflare Pages)


Local Development

# API
cd api
bun install
bun run dev        # starts on http://localhost:8787

# Frontend
cd web
bun install
bun run dev        # starts on http://localhost:4321

# Data engine
cd data-engine
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # add DATABASE_URL