betfun-arena/RUN_APP.md

341 lines
6.3 KiB
Markdown

# ๐Ÿš€ Run BetFun Arena - Complete Guide
## โœ… WHAT'S READY
All code is complete! Here's how to run it:
---
## ๐Ÿ“‹ STEP 1: Install Dependencies
```bash
cd /Users/arhansubasi/betfun-arena/betfun-arena
# Install root dependencies
npm install
# Install frontend dependencies
cd apps/web
npm install
# Go back to root
cd ../..
```
---
## ๐Ÿ”ง STEP 2: Quick Environment Setup
### Option A: Use Default Dev Settings (Fastest)
```bash
# Frontend
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
# Backend (Optional - only if you want full functionality)
# For now, frontend works standalone with mock data
```
---
## ๐ŸŽฏ STEP 3: Run the App
### Fastest Way: Frontend Only
```bash
cd apps/web
npm run dev
```
Then open: **http://localhost:3000**
### Full Stack: All Services
Open **4 terminal windows**:
**Terminal 1 - Frontend:**
```bash
cd apps/web
npm run dev
# Runs on http://localhost:3000
```
**Terminal 2 - API (Optional):**
```bash
cd packages/api
npm install
npm run dev
# Runs on http://localhost:3001
```
**Terminal 3 - WebSocket (Optional):**
```bash
cd packages/websocket
npm install
npm run dev
# Runs on http://localhost:3002
```
**Terminal 4 - Indexer (Optional):**
```bash
cd packages/indexer
npm install
npm run dev
# Runs in background
```
---
## ๐ŸŽจ WHAT YOU'LL SEE
Once running, you'll have access to:
### Pages (15 total)
1. **Home** - Landing page with hero
2. **Feed** - Browse all arenas
3. **Markets** - Advanced market browser with filters
4. **Market Details** - Individual market with charts
5. **Create** - Create new prediction markets
6. **Arena** - Arena details with live battles
7. **Trading** - Advanced trading interface
8. **Activity** - Your trading history
9. **Portfolio** - Your positions and P&L
10. **Profile** - User profile with achievements
11. **Leaderboard** - Top traders rankings
12. **Notifications** - Real-time alerts
13. **Settings** - Account preferences
14. **Analytics** - Platform metrics
15. **Tags** - Browse by category
### Features Available
- โœ… Browse markets
- โœ… View market details
- โœ… See price charts
- โœ… Check trading history
- โœ… View user profiles
- โœ… See leaderboards
- โœ… Check analytics
- โœ… All UI/UX features
### Features Needing Backend
- โณ Actually place trades (needs smart contracts + API)
- โณ Real-time updates (needs WebSocket)
- โณ User authentication (needs Supabase)
- โณ Data persistence (needs database)
---
## ๐Ÿณ ALTERNATIVE: Docker (Easiest)
If you have Docker installed:
```bash
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3.8'
services:
frontend:
build:
context: ./apps/web
ports:
- "3000:3000"
environment:
- NEXT_PUBLIC_RPC_URL=https://api.devnet.solana.com
- NEXT_PUBLIC_PROGRAM_ID=BetFunArenaPredictionMarketGameV1111111111111
volumes:
- ./apps/web:/app
- /app/node_modules
redis:
image: redis:7-alpine
ports:
- "6379:6379"
EOF
# Run
docker-compose up
```
---
## ๐ŸŽฏ SIMPLIFIED STARTUP (RECOMMENDED)
For demo/development, just run the frontend:
```bash
# 1. Go to frontend
cd /Users/arhansubasi/betfun-arena/betfun-arena/apps/web
# 2. Install if needed
npm install
# 3. Create .env.local
echo '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' > .env.local
# 4. Run
npm run dev
# 5. Open browser
open http://localhost:3000
```
**That's it!** The frontend works standalone with:
- โœ… All 15 pages
- โœ… Complete UI/UX
- โœ… Navigation
- โœ… Mock data for demo
- โœ… Responsive design
---
## ๐Ÿ”Œ For Full Functionality
To enable trading, real-time updates, and persistence:
### 1. Setup Supabase (Free)
```bash
# Go to https://supabase.com
# Create new project
# Copy Project URL and API Key
# Add to .env files
```
### 2. Setup Redis (Local)
```bash
# macOS
brew install redis
redis-server
# Ubuntu
sudo apt install redis-server
sudo systemctl start redis
```
### 3. Deploy Smart Contracts
```bash
cd packages/anchor
anchor build
anchor deploy --provider.cluster devnet
# Note the Program ID
```
### 4. Update Environment Variables
```bash
# Update apps/web/.env.local with:
# - Real Program ID
# - Supabase URL
# - Redis URL
```
### 5. Start All Services
```bash
# Terminal 1
cd apps/web && npm run dev
# Terminal 2
cd packages/api && npm run dev
# Terminal 3
cd packages/websocket && npm run dev
# Terminal 4
cd packages/indexer && npm run dev
```
---
## ๐Ÿ“Š Current Status
| Component | Status | What Works |
|-----------|--------|------------|
| **Frontend** | โœ… 100% | All pages, UI, navigation |
| **Smart Contracts** | โœ… 100% | Code complete, needs deployment |
| **API Service** | โœ… 100% | Code complete, needs backend setup |
| **WebSocket** | โœ… 100% | Code complete, needs backend setup |
| **Indexer** | โœ… 100% | Code complete, needs backend setup |
---
## ๐ŸŽฎ Quick Demo Mode
Want to see it NOW? Just run the frontend:
```bash
cd apps/web
npm run dev
```
You'll see:
- โœ… Beautiful UI
- โœ… All pages working
- โœ… Mock data populated
- โœ… Smooth animations
- โœ… Responsive design
- โœ… Complete user flows
---
## โšก Ultra Quick Start
```bash
cd /Users/arhansubasi/betfun-arena/betfun-arena/apps/web
npm install
npm run dev
open http://localhost:3000
```
**Done!** Browse all 15 pages and see the complete platform! ๐ŸŽ‰
---
## ๐Ÿ†˜ Troubleshooting
### Port 3000 in use
```bash
lsof -i :3000
kill -9 <PID>
# Or change port: npm run dev -- -p 3001
```
### Module not found
```bash
rm -rf node_modules package-lock.json
npm install
```
### Build errors
```bash
npm run build
# Check for errors
# Fix TypeScript issues if any
```
---
## ๐Ÿ“ž Support
**Everything is ready to run!** If you need help:
- Check logs in terminal
- See QUICKSTART.md for more details
- Read DEPLOYMENT_GUIDE.md for production
- Review README.md for full documentation
---
**Status**: โœ… Ready to Run
**Next**: `cd apps/web && npm run dev`
**Then**: Open http://localhost:3000
๐ŸŽ‰ Enjoy BetFun Arena! โš”๏ธ๐Ÿ†