betfun-arena/QUICKSTART.md

4.4 KiB

โšก BetFun Arena - Quick Start Guide

๐Ÿš€ Run the Entire App in 3 Steps

Step 1: Install Dependencies

cd /Users/arhansubasi/betfun-arena/betfun-arena
npm install

Step 2: Setup Environment

Option A: Interactive Setup (Recommended)

npm run setup:env

Option B: Manual Setup (Quick)

# Frontend (.env.local)
cat > apps/web/.env.local << 'EOF'
NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.com
NEXT_PUBLIC_PROGRAM_ID=BetFunArenaPredictionMarketGameV1111111111111
NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_WS_URL=http://localhost:3002
NEXT_PUBLIC_APP_URL=http://localhost:3000
EOF

# API Service (.env)
cat > packages/api/.env << 'EOF'
PORT=3001
SUPABASE_URL=your-supabase-url
SUPABASE_KEY=your-supabase-key
REDIS_URL=redis://localhost:6379
CORS_ORIGIN=http://localhost:3000
EOF

# WebSocket Service (.env)
cat > packages/websocket/.env << 'EOF'
WS_PORT=3002
SUPABASE_URL=your-supabase-url
SUPABASE_KEY=your-supabase-key
REDIS_URL=redis://localhost:6379
CORS_ORIGIN=http://localhost:3000
EOF

# Indexer Service (.env)
cat > packages/indexer/.env << 'EOF'
RPC_URL=https://api.devnet.solana.com
SUPABASE_URL=your-supabase-url
SUPABASE_KEY=your-supabase-key
REDIS_URL=redis://localhost:6379
HELIUS_API_KEY=
WEBHOOK_URL=http://localhost:3001/webhook
EOF

Step 3: Start All Services

npm run dev

This will start:


๐Ÿ“‹ Prerequisites Check

Required Software

# Check Node.js (need >= 18)
node --version

# Check npm (need >= 9)
npm --version

# Check Redis (optional but recommended)
redis-cli ping

Install Missing Dependencies

# macOS
brew install node redis

# Ubuntu/Debian
sudo apt update
sudo apt install nodejs npm redis-server

# Windows
# Download from nodejs.org and redis.io

๐Ÿ”ง Individual Services

Frontend Only

cd apps/web
npm install
npm run dev
# Open http://localhost:3000

API Only

cd packages/api
npm install
npm run dev
# API at http://localhost:3001

WebSocket Only

cd packages/websocket
npm install
npm run dev
# WebSocket at http://localhost:3002

Indexer Only

cd packages/indexer
npm install
npm run dev
# Runs in background

๐Ÿณ Docker Quick Start (Alternative)

# Build and run all services
docker-compose up

# Or build first
docker-compose build
docker-compose up -d

# View logs
docker-compose logs -f

# Stop all
docker-compose down

๐ŸŽฏ Production Build

# Build everything
npm run build

# Start production servers
npm run start:all

โš ๏ธ Troubleshooting

Port Already in Use

# Find process using port 3000
lsof -i :3000

# Kill process
kill -9 <PID>

# Or change port in .env files

Redis Not Running

# Start Redis
redis-server

# Or run in background
redis-server --daemonize yes

# Check if running
redis-cli ping
# Should return: PONG

Module Not Found

# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm install

# Or for specific workspace
cd apps/web
rm -rf node_modules
npm install

Database Connection Failed

  1. Check Supabase credentials in .env files
  2. Ensure database schema is deployed
  3. Check network connectivity
  4. Verify API keys are correct

๐Ÿ“Š Verify Everything is Running

# Check frontend
curl http://localhost:3000

# Check API
curl http://localhost:3001/health

# Check WebSocket
wscat -c ws://localhost:3002

# Check Redis
redis-cli ping

๐ŸŽฎ First Steps After Startup

  1. Open Browser: http://localhost:3000
  2. Connect Wallet: Use Phantom/Solflare
  3. Switch to Devnet: In wallet settings
  4. Get Test SOL: Use faucet at https://faucet.solana.com
  5. Create Market: Click "Create Arena"
  6. Start Trading: Browse markets and trade!

๐Ÿ“š Next Steps


๐Ÿ†˜ Need Help?

  • Docs: Check /docs folder
  • Issues: GitHub Issues
  • Discord: discord.gg/betfun
  • Email: support@betfun.arena

Happy Trading! โš”๏ธ๐Ÿ†