4.4 KiB
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:
- โ Frontend at http://localhost:3000
- โ API at http://localhost:3001
- โ WebSocket at http://localhost:3002
- โ Indexer (background)
๐ 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
- Check Supabase credentials in .env files
- Ensure database schema is deployed
- Check network connectivity
- 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
- Open Browser: http://localhost:3000
- Connect Wallet: Use Phantom/Solflare
- Switch to Devnet: In wallet settings
- Get Test SOL: Use faucet at https://faucet.solana.com
- Create Market: Click "Create Arena"
- Start Trading: Browse markets and trade!
๐ Next Steps
- Read README.md for full documentation
- Check DEPLOYMENT_GUIDE.md for production
- See API_DOCUMENTATION.md for API details
- Review DATABASE_SCHEMA.sql for database
๐ Need Help?
- Docs: Check /docs folder
- Issues: GitHub Issues
- Discord: discord.gg/betfun
- Email: support@betfun.arena
Happy Trading! โ๏ธ๐