GitHub Pages + Free Backend Deployment Guide
This guide explains how to deploy the Asset Management Platform using GitHub Pages (free) for the frontend and free backend hosting services for the API and database.
π― Free Hosting Strategy
- Frontend: GitHub Pages (completely free, unlimited bandwidth)
- Backend: Free tier from Render/Railway/Fly.io
- Database: PostgreSQL included with backend hosting services
π Quick Deploy
Step 1: Enable GitHub Pages
- Go to your repository Settings β Pages
- Set Source to βGitHub Actionsβ
- The workflow will automatically deploy your frontend
Step 2: Set up GitHub Secrets (Optional for demo)
For full functionality, add these secrets in Settings β Secrets and variables β Actions:
JWT_SECRET=your_jwt_secret_here
JWT_REFRESH_SECRET=your_refresh_secret_here
GOOGLE_CLIENT_ID=your_google_oauth_client_id
Step 3: Deploy Frontend
The frontend deploys automatically on every push to main/master, or manually:
- Go to Actions tab
- Select Deploy to GitHub Pages workflow
- Click Run workflow
- Optionally specify your backend URL
Step 4: Deploy Backend
Choose one of these free backend hosting services:
π Option A: Render (Recommended)
- Sign up at render.com
- Connect your GitHub repository
- Create a new Web Service
- Set build settings:
- Environment: Docker
- Dockerfile Path:
./backend/Dockerfile
- Add environment variables:
NODE_ENV=production
DATABASE_URL=<provided-by-render>
JWT_SECRET=<your-secret>
JWT_REFRESH_SECRET=<your-secret>
JWT_ACCESS_TOKEN_EXPIRY=15m
JWT_REFRESH_TOKEN_EXPIRY=7d
JWT_ACCESS_TOKEN_EXPIRY_REMEMBER=1h
JWT_REFRESH_TOKEN_EXPIRY_REMEMBER=30d
GOOGLE_CLIENT_ID=<your-client-id>
- Deploy!
π Option B: Railway
- Sign up at railway.app
- Connect your GitHub repository
- Railway will auto-detect your project
- Add environment variables (same as above)
- Deploy!
πͺΆ Option C: Fly.io
- Sign up at fly.io
- Install Fly CLI:
curl -L https://fly.io/install.sh | sh
- Run:
fly launch in your project root
- Configure with your
backend/Dockerfile
- Set secrets:
fly secrets set JWT_SECRET=your-secret
- Deploy:
fly deploy
π Environment Variables
Required for Backend
# Database (provided by hosting service)
DATABASE_URL=postgresql://...
# Authentication
JWT_SECRET=your_jwt_secret_here
JWT_REFRESH_SECRET=your_refresh_secret_here
JWT_ACCESS_TOKEN_EXPIRY=15m
JWT_REFRESH_TOKEN_EXPIRY=7d
JWT_ACCESS_TOKEN_EXPIRY_REMEMBER=1h
JWT_REFRESH_TOKEN_EXPIRY_REMEMBER=30d
# Google OAuth
GOOGLE_CLIENT_ID=your_google_client_id_here
# Environment
NODE_ENV=production
Frontend Configuration
The frontend automatically gets the backend URL via the VITE_API_URL environment variable during build.
ποΈ Database Setup
Most free hosting services provide PostgreSQL databases. For initial data setup:
- After backend deployment, connect to your database
- Run the initialization scripts:
# Install dependencies
npm install
# Initialize database schema
cd scripts
npm run init-db
# Seed with sample data
python3 simple_db_seed.py
π URLs After Deployment
- Frontend:
https://yourusername.github.io/repository-name
- Backend:
https://your-app-name.onrender.com (or similar)
- API Docs:
https://your-app-name.onrender.com/api-docs
π Updating Deployment
Frontend Updates
- Automatic on push to
main/master
- Or manual trigger with new backend URL
Backend Updates
- Automatic if connected to GitHub
- Or manual deploy via hosting service dashboard
π§ͺ Testing Deployment
Local Testing
# Test the deployment setup locally
./test-deployment.sh
Health Checks
- Frontend: Visit your GitHub Pages URL
- Backend: Check
https://your-backend-url/api/health
- API Docs: Visit
https://your-backend-url/api-docs
π Free Tier Limits
GitHub Pages
- β
Unlimited bandwidth
- β
Custom domains supported
- β
HTTPS included
Backend Services (approximate free limits)
- Render: 750 hours/month, auto-sleep
- Railway: $5/month credit, then pay-as-you-go
- Fly.io: 3 shared CPUs, 256MB RAM free
π§ Troubleshooting
Frontend Issues
- Check GitHub Pages deployment status in Actions tab
- Verify
VITE_API_URL is set correctly
- Check browser console for CORS errors
Backend Issues
- Check hosting service logs
- Verify environment variables are set
- Test database connection
CORS Issues
- Ensure backend allows your GitHub Pages domain
- Check CORS configuration in
server.ts
π‘ Pro Tips
- Custom Domain: Add a custom domain to GitHub Pages for a professional look
- Monitoring: Set up uptime monitoring for your free services
- Backup: Regularly backup your database data
- Scaling: Monitor usage and upgrade plans as needed
π Youβre Done!
Your Asset Management Platform is now live using free hosting! π
- Frontend: GitHub Pages (free)
- Backend: Render/Railway/Fly.io (free tier)
- Database: Included with backend hosting
Enjoy your deployed application! π