Prerequisites
- A Vercel account
- The Vercel CLI installed (optional, for CLI deployment)
- Your project pushed to a Git repository (GitHub, GitLab, or Bitbucket)
Vercel Configuration
The application includes avercel.json configuration file that defines the build and routing settings:
vercel.json
Configuration Details
- Runtime: Python 3.9 is used for serverless function execution
- Build Source: The
app.pyfile is the entry point for the application - Builder:
@vercel/pythonhandles Python serverless functions - Install Command: Dependencies from
requirements.txtare automatically installed during build - Routing: All requests are routed to the Flask application
Deployment Methods
Method 1: Deploy via Vercel Dashboard (Recommended)
Import Project
- Go to Vercel Dashboard
- Click Add New → Project
- Import your Git repository
Configure Build Settings
Vercel will automatically detect the
vercel.json configuration. Verify the settings:- Framework Preset: Other
- Build Command: (leave empty, handled by vercel.json)
- Output Directory: (leave empty)
- Install Command:
pip install -r requirements.txt
Set Environment Variables
Before deploying, add the required environment variable:
- Go to Settings → Environment Variables
- Add
NEPAL_ADMIN_DATA_URLwith your data source URL - Set it for Production, Preview, and Development environments
Method 2: Deploy via Vercel CLI
Build Process
During deployment, Vercel performs the following steps:- Install Dependencies: Runs
pip install -r requirements.txt - Build Function: Converts
app.pyinto a serverless function - Configure Routes: Sets up routing based on
vercel.json - Deploy: Deploys the serverless function to Vercel’s edge network
Accessing Your Application
Once deployed, your application provides:- Web Interface:
https://your-project-name.vercel.app/ - API Documentation:
https://your-project-name.vercel.app/docs - API Endpoints:
/api/provinces//api/districts//api/municipalities/
Vercel automatically assigns a unique URL to your deployment. You can configure a custom domain in the Vercel dashboard under Settings → Domains.
Environment Variables in Production
To manage environment variables after deployment:- Go to your project in the Vercel dashboard
- Navigate to Settings → Environment Variables
- Add, edit, or remove variables as needed
- Redeploy for changes to take effect
Monitoring and Logs
Vercel provides built-in monitoring tools:- Deployment Logs: View build and deployment logs in the Vercel dashboard
- Function Logs: Real-time logs for your serverless function
- Analytics: Track visits, performance, and errors
- Vercel Dashboard → Your Project → Deployments → View Logs
- Vercel CLI:
vercel logs
Continuous Deployment
Vercel automatically deploys your application when you push changes to your Git repository:- Production: Pushes to the
mainormasterbranch - Preview: Pushes to other branches or pull requests
Next Steps
- Configure environment variables for different environments
- Set up a custom domain in Vercel settings
- Monitor your application’s performance and logs
- Enable Vercel Analytics for usage insights