- GitHub account
- Railway account (sign up at https://railway.app)
- Vercel account (sign up at https://vercel.com)
- Git installed on your machine
cd d:\DVS
git init# Create .gitignore file
@"
node_modules/
.env
.env.local
*.log
.DS_Store
backend/uploads/*
!backend/uploads/.gitkeep
backend/cache/
backend/artifacts/build-info/
frontend/build/
"@ | Out-File -FilePath .gitignore -Encoding utf8git add .
git commit -m "Initial commit - Blockchain Voting System"
git branch -M main
# Create repo on GitHub first, then:
git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git
git push -u origin mainnpm install -g @railway/clirailway loginBrowser will open - authorize Railway
cd d:\DVS\backendrailway initSelect "Empty Project" → Give it a name like "voting-backend"
railway addSelect "PostgreSQL" from the list
# Railway will auto-set DATABASE_URL from PostgreSQL
# You need to add these manually:
railway variables set JWT_SECRET="your_super_secret_jwt_key_$(Get-Random)"
railway variables set SESSION_SECRET="your_super_secret_session_key_$(Get-Random)"
railway variables set NODE_ENV="production"
railway variables set PORT="5000"# Link to GitHub repo
railway link
# Or deploy directly
railway up# Open Railway shell
railway run npm run migrate
railway run node create-superadmin.jsGo to Railway Dashboard:
- Open your project
- Click on the service
- Go to "Settings" → "Deploy"
- Set Start Command:
node railway-start.js - Click "Redeploy"
railway statusCopy the URL (e.g., https://voting-backend-production.up.railway.app)
npm install -g vercelcd d:\DVS\frontendCreate/update .env.production:
@"
REACT_APP_API_URL=https://YOUR_RAILWAY_BACKEND_URL/api
"@ | Out-File -FilePath .env.production -Encoding utf8Replace YOUR_RAILWAY_BACKEND_URL with actual Railway URL
vercel loginFollow the authentication steps
# First deployment (interactive)
vercel
# Answer prompts:
# Set up and deploy? Yes
# Which scope? Your account
# Link to existing project? No
# Project name? voting-frontend
# Directory? ./
# Override settings? No
# Deploy to production
vercel --prod- Go to https://vercel.com/dashboard
- Select your project
- Go to "Settings" → "Environment Variables"
- Add:
- Variable:
REACT_APP_API_URL - Value:
https://your-railway-backend-url.up.railway.app/api - Environment: Production, Preview, Development
- Variable:
- Click "Save"
- Go to "Deployments" → Redeploy
Your app is now live at: https://voting-frontend-xxx.vercel.app
Update backend to allow Vercel domain:
- Go to Railway dashboard → Your service → Shell
- Or update locally and push:
Edit backend/src/server.js - update CORS:
const corsOptions = {
origin: [
'http://localhost:3000',
'https://your-vercel-app.vercel.app', // Add your Vercel URL
'https://*.vercel.app' // Allow all Vercel preview deployments
],
credentials: true
};- Push changes:
git add .
git commit -m "Update CORS for production"
git pushRailway will auto-redeploy.
# Test health endpoint
curl https://your-railway-backend.up.railway.app/
# Should return: "Blockchain Voting System Backend Running"Open your Vercel URL in browser: https://your-app.vercel.app
- Register a voter
- Login
- Vote
- Check blockchain transaction
Railway (Backend):
- Automatically deploys when you push to GitHub
- Set up in Railway Dashboard → Settings → Deploy
Vercel (Frontend):
- Automatically deploys on git push
- Already configured by default
# Backend (Railway)
cd d:\DVS\backend
railway up
# Frontend (Vercel)
cd d:\DVS\frontend
vercel --prod- ✅ 500 hours/month
- ✅ 1GB RAM
- ✅ PostgreSQL included
- ✅ No credit card required
- ✅ Unlimited bandwidth
- ✅ 100GB storage
- ✅ Automatic SSL
- ✅ No credit card required
# View logs
railway logs
# Restart service
railway restart
# Open shell
railway shell# View deployment logs
vercel logs
# Redeploy
vercel --prod --force# Connect to PostgreSQL
railway connect postgres
# Run migrations again
railway run npm run migrate- Backend: https://voting-backend-production.up.railway.app
- Frontend: https://voting-frontend.vercel.app
- Database: (Managed by Railway)
- Blockchain: (Running on Railway with backend)
# Railway
railway login
railway logs
railway shell
railway restart
# Vercel
vercel login
vercel logs
vercel --prod- Never commit .env files
- Use strong JWT_SECRET and SESSION_SECRET
- Keep Railway and Vercel environment variables secure
- Enable 2FA on GitHub, Railway, and Vercel
- Railway Docs: https://docs.railway.app
- Vercel Docs: https://vercel.com/docs
- Issues: Create GitHub issue in your repo
Deployment Complete! 🎉