Skip to content

stewarthsoj/bitduel

Repository files navigation

Bitduel

A real-time Bitcoin price prediction game where users guess if the price will go up or down within 60 seconds.

Features

  • 🪙 Real-time Bitcoin price updates using Coinbase API and server-sent events
  • ⏱ 60-second countdown for price predictions
  • 📈 Score tracking system with animated feedback
  • 🔐 User authentication via Clerk
  • 🚀 Background job processing with Trigger.dev
  • 🗄 SQLite database with Turso and Drizzle ORM
  • 🎮 Interactive UI with motion animations
  • 📊 Database migrations and schema management
  • ✅ End-to-end type safety with TypeScript
  • 🧪 Comprehensive test suite with Vitest (TODO: E2E tests)

Getting Started

Prerequisites

  • Node.js 22.x (recommended: Volta or nvm)
  • pnpm 10.x: npm install -g [email protected]
  • Turso CLI: curl -sSfL https://get.tur.so/install.sh | bash

Platform Accounts

  1. Clerk - Authentication provider
    • Create application and get API keys
  2. Turso - Database hosting
    • Create database and get connection URL (local or remote)
  3. Fly.io - Application hosting
    • Install flyctl (for deployment)
  4. Trigger.dev - Background jobs
    • Create project and get secret key

Installation

  1. Clone repository

    git clone https://github.com/stewarthsoj/bitduel
    cd bitduel
  2. Install dependencies

    pnpm install
  3. Configure environment variables Create .env file with:

    NODE_ENV=development
    CLERK_SECRET_KEY=sk_test_...
    VITE_CLERK_PUBLISHABLE_KEY=pk_test_...
    TURSO_CONNECTION_URL=libsql://...
    TURSO_AUTH_TOKEN=...
    TRIGGER_SECRET_KEY=tr_dev_...

Database Setup

  1. Initialize Turso database

    • Local development:
      turso dev --db-file <filepath>
    • Remote database:
      turso db create bitduel --org <your-org>
  2. Run migrations

    pnpm run db:migrate
  3. Start DB Studio (optional)

    pnpm run db:studio

Starting Servers

  1. Start Trigger.dev worker (in separate terminal)

    pnpm run trigger:dev
  2. Start development server

    pnpm run dev

Deployment

Database Deployment

  1. Push production migrations
    pnpm run db:migrate

Trigger.dev Deployment

  1. Link your project

    pnpm dlx @trigger.dev/cli@latest login
    pnpm dlx @trigger.dev/cli@latest init
  2. Add environment variables

    pnpm dlx @trigger.dev/cli@latest env:set TURSO_CONNECTION_URL=... TURSO_AUTH_TOKEN=...
  3. Deploy triggers to production

    pnpm dlx @trigger.dev/cli@latest deploy

Fly.io Deployment

  1. Create fly application

    flyctl launch
  2. Set environment variables

    flyctl secrets set \
      NODE_ENV=production \
      CLERK_SECRET_KEY=... \
      TURSO_CONNECTION_URL=... \
      TURSO_AUTH_TOKEN=... \
      TRIGGER_SECRET_KEY=...
  3. Deploy

    flyctl deploy

Development Scripts

Command Description
pnpm dev Start dev server
pnpm test Run Vitest suite
pnpm lint:check Check code quality with Biome
pnpm lint:write Fix linting issues
pnpm type:check Validate TypeScript types
pnpm build Create production build
pnpm trigger:dev Start Trigger.dev worker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published