This project is now fully configured for deployment to Heroku while maintaining local development capabilities.
- heroku_app.py: Entry point for Heroku that delegates to backend/app.py
- Procfile: Tells Heroku how to run your app with gunicorn
- runtime.txt: Specifies Python 3.11.6 for Heroku
- requirements.txt: Updated with gunicorn for production
- Environment Variables: Production config uses environment variables
- Frontend Serving: Production routes serve frontend files automatically
- Database: Configured to use /tmp/capsules.db on Heroku (ephemeral)
- Heroku Account: Sign up at heroku.com
- Heroku CLI: Install from devcenter.heroku.com/articles/heroku-cli
- Git: Make sure your project is in a git repository
heroku login# Replace 'your-app-name' with your desired app name (must be unique)
heroku create ethereum-time-capsule-yourname# Set your production Pinata credentials
heroku config:set PINATA_JWT="your-actual-jwt-token"
heroku config:set PINATA_API_KEY="your-actual-api-key"
heroku config:set PINATA_SECRET_API_KEY="your-actual-secret"
# Mark as production environment
heroku config:set HEROKU=true
heroku config:set FLASK_ENV=production# Add all files to git (if not already done)
git add .
git commit -m "Prepare for Heroku deployment"
# Deploy to Heroku
git push heroku mainheroku openpython test_heroku_setup.py# Option 1: Run backend directly (recommended for development)
python backend/app.py
# Option 2: Run Heroku entry point (tests production setup)
python heroku_app.pyBoth methods serve the frontend at http://localhost:5000
- Local: Uses
capsules.dbin project root - Heroku: Uses
/tmp/capsules.db(resets on app restart) - Pros: Zero configuration, works immediately
- Cons: Data lost on Heroku restarts
# Add PostgreSQL addon (requires credit card verification)
heroku addons:create heroku-postgresql:mini
# Check database URL
heroku config | findstr DATABASE_URLTo use PostgreSQL, you'd need to modify backend/database.py to support both SQLite and PostgreSQL.
heroku logs --tailheroku configheroku restart# Run the test script
python test_heroku_setup.py
# Check if app imports correctly
python -c "import heroku_app; print('✅ Import successful')"- Go to railway.app
- Connect your GitHub repository
- Set environment variables in Railway dashboard:
PINATA_JWTPINATA_API_KEYPINATA_SECRET_API_KEYRAILWAY_ENVIRONMENT=production
- Railway auto-deploys from GitHub
- Go to render.com
- Create new Web Service from GitHub
- Set build command:
pip install -r requirements.txt - Set start command:
gunicorn heroku_app:app - Add environment variables
- Frontend: Deploy to Netlify/Vercel (just the
frontend/folder) - Backend: Deploy to Railway/Render
- Benefits: Better CDN, separate scaling
- Setup: Update frontend API URLs to point to backend domain
- Test locally with
python test_heroku_setup.py - Verify all environment variables are set
- Test that Pinata API keys work
- Ensure frontend files load correctly
- Check Heroku logs for any errors
- Test homepage loads:
https://your-app.herokuapp.com - Test gallery page:
https://your-app.herokuapp.com/gallery - Test create page:
https://your-app.herokuapp.com/create - Verify database API endpoints work
- Test capsule creation and retrieval
- Set up Heroku log monitoring
- Monitor app performance with
heroku ps - Check for memory/CPU usage issues
- Your
backend/config.pyis git-ignored and won't be deployed - Production uses environment variables instead
- Always use HTTPS in production (Heroku provides this automatically)
- Consider enabling Heroku's security features
- Use
python backend/app.pyfor development (more convenient) - Use
python heroku_app.pyto test production setup - Frontend files are served automatically in both modes
- Database and file storage work the same locally and on Heroku