A guessing game built with Astro, Turso, and Cloudflare R2. Given real world items from places such as Best Buy and Amazon, can you guess the price?
Includes: public profiles, stats tracking, individual item stats, admin dashboard, public viewable challenge links, and more!
git clone https://github.com/sadeshmukh/spectrum.git
cd spectrum
npm install- Go to GitHub Developer Settings
- Create a new OAuth App:
- Name: Spectrum
- Homepage:
http://localhost:4321 - Callback:
http://localhost:4321/api/auth/callback/github
- Copy the Client ID and Client Secret
Copy the example file and fill in your values:
cp env.example .envRequired variables:
# GitHub OAuth
GITHUB_CLIENT_ID=your_client_id
GITHUB_CLIENT_SECRET=your_client_secret
# Auth
AUTH_SECRET=your_random_secret_32_chars_min
AUTH_TRUST_HOST=true
# Admin access
ADMIN_EMAIL=your_github_email
# Database (optional for local dev)
ASTRO_DB_REMOTE_URL=libsql://your-db.turso.io
ASTRO_DB_APP_TOKEN=your_token
# Storage (optional for local dev)
AWS_ACCESS_KEY_ID=your_key
AWS_SECRET_ACCESS_KEY=your_secret
AWS_REGION=autoGenerate AUTH_SECRET: openssl rand -hex 32
For production, set up Turso:
curl -sLf https://get.tur.so/install.sh | bash
turso auth login
turso db create spectrum
# more details
turso db show spectrum
turso db tokens create spectrumUpdate your .env with the connection details, then push the schema:
npm run db:push:schemaOptionally seed the database with initial data:
npm run db:seednpm run devVisit http://localhost:4321 and sign in with GitHub.
- Regular users: Sign in and play the guessing game
- Admins: Use the admin panel to add new items (requires matching ADMIN_EMAIL)
npm run dev- Local developmentnpm run build- Production buildnpm run db:push:schema- Sync schema to remote databasenpm run db:seed- Execute seed file against remote databasenpm run populate:*- Seed data scrapers (amazon, fakestore, dummyjson, mock, bestbuy)
Example result in db/scraped-items.ts
// This file is auto-generated by scripts/bestbuy-populate.ts
export const scrapedItems = [
{
"link": "https://www.bestbuy.com/site/item-name-huge-thing/6566195.p?skuId=6566195",
"photoUrl": "https://r2.spectrum.sahil.ink/products/123421d12ree1234.webp",
"title": "Item Name Huge Thing",
"actualPrice": 123.45
},
...
]- Set up Turso database (see Database setup above)
- Configure environment variables
- Run
npm run db:push:schema - Optionally run
npm run db:seedto populate initial data - Deploy to your preferred platform
MIT