Skip to content

sadeshmukh/spectrum

Repository files navigation

Spectrum

made with ❤️ by sadeshmukh

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!

Setup

1. Clone and install

git clone https://github.com/sadeshmukh/spectrum.git
cd spectrum
npm install

2. GitHub OAuth setup

  1. Go to GitHub Developer Settings
  2. Create a new OAuth App:
    • Name: Spectrum
    • Homepage: http://localhost:4321
    • Callback: http://localhost:4321/api/auth/callback/github
  3. Copy the Client ID and Client Secret

3. Environment variables

Copy the example file and fill in your values:

cp env.example .env

Required 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=auto

Generate AUTH_SECRET: openssl rand -hex 32

4. Database setup (optional)

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 spectrum

Update your .env with the connection details, then push the schema:

npm run db:push:schema

Optionally seed the database with initial data:

npm run db:seed

5. Run locally

npm run dev

Visit http://localhost:4321 and sign in with GitHub.

Usage

  • Regular users: Sign in and play the guessing game
  • Admins: Use the admin panel to add new items (requires matching ADMIN_EMAIL)

Scripts

  • npm run dev - Local development
  • npm run build - Production build
  • npm run db:push:schema - Sync schema to remote database
  • npm run db:seed - Execute seed file against remote database
  • npm run populate:* - Seed data scrapers (amazon, fakestore, dummyjson, mock, bestbuy)

Population

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
  },
  ...
]

Deployment

  1. Set up Turso database (see Database setup above)
  2. Configure environment variables
  3. Run npm run db:push:schema
  4. Optionally run npm run db:seed to populate initial data
  5. Deploy to your preferred platform

License

MIT

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •