A Next.js-based GeoGuessr-style game deployed on Cloudflare Workers with D1 database.
- Node.js 18+
- pnpm (recommended) or npm
- Cloudflare account (for production deployment)
- Wrangler CLI installed globally
-
Clone and install dependencies:
git clone https://github.com/charlesfrisbee/free-o-guessr.git cd free-o-guessr pnpm install -
Environment Variables: Create a
.envfile in the root directory:NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
Getting a Google Maps API Key:
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable the Maps JavaScript API and Street View Static API
- Create credentials (API Key)
- Restrict the API key to your domain(s) for security
-
Set up database:
# Create D1 database wrangler d1 create free-o-guessrUpdate
wrangler.jsoncwith your new database ID (replace the existingdatabase_id).# Generate migration files (if needed) pnpm migration:generate # Apply migrations to database pnpm migration:apply
-
Start development server:
pnpm dev
-
Open the application: Visit http://localhost:3000 in your browser.
Run the test suites:
# Unit tests
# D1 database tests
pnpm test:d1
# UI component tests
pnpm test:ui-
Apply database migrations to production:
# Apply migrations to the remote database pnpm migration:apply-remote -
Deploy to Cloudflare:
# Build and deploy pnpm deploy # Or preview before deploying pnpm preview
The application uses Cloudflare Workers with:
- D1 Database: SQLite-compatible database for storing panorama data
- OpenNext: Adapter for running Next.js on Cloudflare Workers
- Wrangler: CLI tool for managing Cloudflare Workers
The application uses Drizzle ORM with the following key tables:
- Panorama locations with Google Street View integration
- Game results and scoring
| Command | Description |
|---|---|
pnpm dev |
Start development server with Turbopack |
pnpm build |
Build application for production |
pnpm start |
Start production server locally |
pnpm lint |
Run ESLint |
pnpm deploy |
Build and deploy to Cloudflare |
pnpm preview |
Build and preview on Cloudflare |
pnpm cf-typegen |
Generate Cloudflare types |
pnpm migration:generate |
Generate new database migrations |
pnpm migration:apply |
Apply migrations to local database |
pnpm migration:apply-remote |
Apply migrations to remote database |
- Framework: Next.js 15 with App Router
- Runtime: Cloudflare Workers
- Database: Cloudflare D1 (SQLite)
- ORM: Drizzle ORM
- Styling: Tailwind CSS
- Maps: Google Maps API via @vis.gl/react-google-maps
- State Management: Zustand
- Testing: Vitest + Playwright
src/app/- Next.js app router pagessrc/components/- React componentssrc/actions/- Server actionssrc/db/- Database schema and configurationsrc/lib/- Utility functionsdrizzle/migrations/- Database migration filestests/- Test files (unit, integration, e2e)
