Deployment
Overview
| Layer | Platform | How it deploys |
|---|---|---|
web/ | Cloudflare Pages | Push to master → GitHub integration auto-builds |
api/ | Cloudflare Workers | Push to master → GitHub integration auto-builds |
data-engine/ | Render | Cron jobs triggered on schedule |
| DB migrations | Neon | Manual — 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
| Variable | How to set | Notes |
|---|---|---|
DATABASE_URL | Workers → Settings → Variables and Secrets → Secret | Neon 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
| Variable | How to set | Notes |
|---|---|---|
PUBLIC_API_URL | Pages → Settings → Environment Variables | Full Worker URL |
Example value: https://f1-intelligence-api.gorkemkaryol.workers.dev
keep_vars = true is set in web/wrangler.toml.
Data Engine — Render Dashboard
| Variable | How to set |
|---|---|
DATABASE_URL | Render → 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)
- Connect the
api/directory to a Cloudflare Worker via the GitHub integration in the Cloudflare dashboard. - In the Worker’s dashboard, add
DATABASE_URLas a Secret. - Push to
masterto trigger the first deploy.
3. Frontend (Cloudflare Pages)
- Connect the
web/directory to Cloudflare Pages via the GitHub integration. - Set build command:
bun run build - Set output directory:
dist - Add environment variable
PUBLIC_API_URLpointing to your Worker URL. - Push to
masterto trigger the first deploy.
4. Data Engine (Render)
- Create a new Render service from the
data-engine/directory. - Add
DATABASE_URLas an environment variable. - 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 UTCpython 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