This guide provides a complete step-by-step workflow for setting up Stellarcade for local development. Follow these steps in order to get all subsystems (contracts, backend, frontend) running on a fresh clone.
Before starting, ensure you have the following installed:
| Tool | Version | Install Link |
|---|---|---|
| Rust | Latest stable | Install Rust |
| Stellar CLI | Latest | cargo install --locked stellar-cli or brew install stellar-cli |
| Node.js | v18+ | Install Node.js |
| Docker | Latest | Install Docker |
| Git | Latest | Install Git |
# Check Rust installation
rustc --version
# Check Stellar CLI
stellar --version
# Check Node.js
node --version # Should be v18+
npm --version
# Check Docker
docker --version
docker compose versionFor the fastest setup, use Docker Compose to run the backend and databases:
# From the project root
git clone https://github.com/stellar/stellarcade.git
cd stellarcade
# Enable Git hooks (mirrors CI checks locally)
git config core.hooksPath .githooks
# Start all services (PostgreSQL, Redis, Backend)
docker-compose up -d
# Verify services are running
docker psgit clone https://github.com/stellar/stellarcade.git
cd stellarcade
# Enable Git hooks for pre-commit formatting and pre-push validation
git config core.hooksPath .githooksContracts must be built first as other subsystems depend on deployed contract IDs.
cd contracts
# Build all contracts (produces WASM files)
soroban contract build
# Run contract tests to verify everything works
cargo test
# Optional: Build a specific contract (e.g., prize-pool)
cd prize-pool
cargo build --target wasm32-unknown-unknown --releaseVerification: You should see WASM files in target/wasm32-unknown-unknown/release/ for each contract.
Note: For local development, you'll need to deploy contracts to a testnet or local network. See Contract Deployment Guide for deployment steps.
cd ../backend
# Install dependencies
npm install
# Copy environment template and configure
cp .env.example .env
# Edit .env with your settings (at minimum, update contract IDs after deployment)
# Required variables:
# - DATABASE_URL (default: postgres://postgres:postgres@localhost:5432/stellarcade)
# - REDIS_URL (default: redis://localhost:6379)
# - STELLAR_NETWORK (default: testnet)
# - Contract IDs (PRIZE_POOL_CONTRACT_ID, RNG_CONTRACT_ID, etc.)Run database migrations:
# If using Docker Compose, the database is already running
npm run migrateSeed the database (optional but recommended for testing):
npm run seedStart the backend:
# Development mode with hot reload
npm run dev
# Or run in production mode
npm startVerification: Backend should be running at http://localhost:3000. Test with:
curl http://localhost:3000/api/healthcd ../frontend
# Install dependencies (frontend uses pnpm)
pnpm install
# Copy environment template
cp .env.example .env
# Update contract IDs in .env to match your deployed contracts
# VITE_PRIZE_POOL_CONTRACT_ID=C...
# VITE_COIN_FLIP_CONTRACT_ID=C...
# etc.Start the development server:
pnpm run devVerification: Frontend should be running at http://localhost:5173 (Vite default). Open in your browser to verify the UI loads.
Always start services in this order:
- Docker services (Database + Redis) →
docker-compose up -d - Backend API →
cd backend && npm run dev - Frontend →
cd frontend && pnpm run dev
Create a convenience script at the project root:
#!/bin/bash
# scripts/start-local.sh
echo "🚀 Starting Stellarcade local development environment..."
# Start infrastructure
echo "📦 Starting Docker services (PostgreSQL, Redis)..."
docker-compose up -d
# Wait for services to be ready
sleep 5
# Start backend
echo "🔧 Starting backend..."
cd backend && npm run dev &
BACKEND_PID=$!
cd ..
# Wait for backend to initialize
sleep 3
# Start frontend
echo "🎨 Starting frontend..."
cd frontend && pnpm run dev &
FRONTEND_PID=$!
echo "✅ All services started!"
echo " Backend PID: $BACKEND_PID"
echo " Frontend PID: $FRONTEND_PID"
echo ""
echo "📍 Access points:"
echo " Frontend: http://localhost:5173"
echo " Backend API: http://localhost:3000"
echo " PostgreSQL: localhost:5432"
echo " Redis: localhost:6379"
echo ""
echo "Press Ctrl+C to stop all services"
waitMake it executable:
chmod +x scripts/start-local.shAfter setup, verify each subsystem:
- All contracts build without errors (
soroban contract build) - All tests pass (
cargo test) - WASM artifacts exist in target directory
- Docker containers are running (
docker ps) - Database migrations completed successfully
- Backend responds to health check:
curl http://localhost:3000/api/health - Can connect to PostgreSQL and Redis
- All dependencies installed (
pnpm install) - Development server starts without errors
- UI loads in browser at
http://localhost:5173 - Can connect to backend API
- Frontend can call backend API
- Backend can read/write to database
- Backend can connect to Redis for caching
- Stellar network connection works (check logs for Horizon API calls)
Port already in use:
# Check what's using the port
lsof -i :3000 # or :5432, :6379, :5173
# Kill the process if needed
kill -9 <PID>Docker containers won't start:
# Check Docker daemon is running
docker ps
# Restart Docker Desktop or daemon
# On macOS: Restart Docker Desktop app
# On Linux: sudo systemctl restart docker
# Clean up stale containers
docker-compose down -v
docker-compose up -dDatabase connection errors:
# Verify PostgreSQL is running
docker ps | grep postgres
# Check connection string in .env matches docker-compose.yml
# Default: postgres://postgres:postgres@localhost:5432/stellarcade
# Test connection directly
docker-compose exec db psql -U postgres -d stellarcade -c "SELECT 1;"Contract build fails:
# Update Rust toolchain
rustup update
# Ensure wasm32 target is installed
rustup target add wasm32-unknown-unknown
# Clean and rebuild
cd contracts
cargo clean
soroban contract buildFrontend won't start:
# Clear node modules and reinstall
cd frontend
rm -rf node_modules pnpm-lock.yaml
pnpm install
pnpm run devStellar network errors:
# Verify you're using the correct network
# Check .env files for STELLAR_NETWORK and HORIZON_URL
# For testnet, ensure you have test XLM
# Get test XLM: https://laboratory.stellar.org/#account-creator?network=test
# Check Horizon API is accessible
curl https://horizon-testnet.stellar.org/To stop all services and clean up:
# Stop Docker services
docker-compose down
# Stop backend and frontend (if running in foreground, press Ctrl+C)
# Optional: Remove all Docker volumes (deletes database data)
docker-compose down -v
# Optional: Clean contract build artifacts
cd contracts && cargo clean- Architecture Overview - Understand system design
- API Documentation - Explore available endpoints
- Game Rules - Learn about game mechanics
- Contributing Guide - Start contributing
- Contract Deployment - Deploy contracts to testnet
- Check existing issues on GitHub
- Review Security Guidelines for security concerns
- Join the community on Discord (placeholder)