Deploying Backend Applications
Backend applications are more complex to deploy than static sites because they require a server to actually run your code. The hosting platform needs to know how to install your dependencies, start your application, and connect to any databases.
Modern platforms have simplified this significantly. With the right configuration files, deployment can be nearly as easy as static hosting.
What Platforms Need
Most backend hosting platforms require:
Dependency file — Lists what packages your app needs
- Python:
requirements.txt - Node.js:
package.json
Start command — How to run your application
- Python:
python app.pyorgunicorn app:app - Node.js:
node server.jsornpm start
Port configuration — Your app must listen on the port the platform provides, typically through the PORT environment variable.
Environment Variables
Your local .env file doesn't get deployed. Instead, configure environment variables through the platform's dashboard:
- Database connection URLs
- API keys
- Secret keys for sessions
- Any configuration that varies between environments
Database Considerations
If your app uses a database, you have options:
Platform-managed — Most hosting platforms offer one-click database provisioning. This is the easiest approach. Your app connects using a connection URL provided as an environment variable.
Separate service — Use a dedicated database service. More flexible but requires managing another service.
SQLite limitation — SQLite stores data in a file, which doesn't work well on most platforms (the file gets reset on redeploy). For production, switch to PostgreSQL or MySQL.
Deployment Checklist
Before deploying:
-
requirements.txtorpackage.jsonis complete - Start command is defined (in
Procfileor platform config) - App reads port from
PORTenvironment variable - Database connection uses environment variable
- No hardcoded secrets in code
Getting AI Help
AI can guide you through platform-specific setup:
I have a Flask app with SQLite database.
Help me prepare it for deployment to Railway:
- What files do I need to add or modify?
- How do I switch from SQLite to PostgreSQL?
- How do I set up environment variables?
- Walk me through the deployment process.
Popular Platforms
Railway — Simple interface, good free tier, easy database setup.
Render — Similar to Railway, automatic deploys from Git.
Fly.io — More control, runs containers, good for learning.
Start with whichever has the clearest documentation for your stack.