This guide provides instructions for deploying the Java Mastery Platform to various hosting platforms with persistent database storage.
-
Create a Supabase account:
- Go to supabase.com
- Sign up for a free account
- Create a new project
-
Get your database connection string:
- In your Supabase project dashboard
- Go to Project Settings → Database
- Copy the connection string (PostgreSQL format)
-
Deploy to Vercel:
- Connect your GitHub repository to Vercel
- In your Vercel project settings, go to Environment Variables
- Add a new variable:
- Key:
DATABASE_URL - Value: Your Supabase connection string
- Key:
- Redeploy your project
-
Create a Neon account:
- Go to neon.tech
- Sign up for a free account
- Create a new project
-
Get your database connection string:
- In your Neon dashboard
- Go to Connection Details
- Copy the connection string
-
Deploy to Vercel:
- Follow the same steps as for Supabase above
-
Create a Heroku account and install the Heroku CLI
-
Create a PostgreSQL database:
heroku addons:create heroku-postgresql:hobby-dev -a your-app-name
-
Set environment variables:
heroku config:set FLASK_APP=app.py -a your-app-name heroku config:set FLASK_ENV=production -a your-app-name
-
Deploy:
git push heroku main
For other platforms, the process is similar:
- Set up a PostgreSQL database service
- Get the connection string
- Configure it as an environment variable named
DATABASE_URL - Deploy your application
Your production deployment requires these environment variables:
DATABASE_URL: PostgreSQL connection string (format:postgresql://username:password@host:port/database_name)SECRET_KEY: A random secret key for session managementMAIL_SERVER,MAIL_PORT,MAIL_USERNAME,MAIL_PASSWORD: For email functionality (optional)
When deploying for the first time or after schema changes:
- The application will automatically create tables if they don't exist
- The sample data initialization will run if the database is empty
- After deployment, visit your application URL
- Register a new account to test the database connection
- Verify that user data persists between sessions
- Database connection errors: Verify your
DATABASE_URLis correctly formatted and accessible - Migration errors: Check that your PostgreSQL version is compatible
- Permission errors: Ensure your database user has CREATE and WRITE permissions
You can test your database connection by running:
from app import app, db
with app.app_context():
# This will attempt to connect to the database
db.create_all()
print("Database connection successful!")- For production use, consider upgrading from free tiers to ensure reliability
- Monitor database connection limits based on your expected user load
- Consider using connection pooling for high-traffic applications