Architecture
PayOnProof uses a monorepo structure with two separate Vercel projects:- API Service (
services/api) - Vercel serverless functions - Web Service (
services/web) - Next.js application
Prerequisites
- A Vercel account
- Vercel CLI installed:
npm i -g vercel - Git repository hosted on GitHub, GitLab, or Bitbucket
- Completed database setup
- Production environment variables prepared
Deploy API service
Create Vercel project for API
- Go to Vercel Dashboard
- Click Add New → Project
- Import your PayOnProof repository
- Configure project settings:
- Project Name:
payonproof-api(or your preferred name) - Framework Preset: Other
- Root Directory:
services/api - Build Command: Leave empty (Vercel auto-detects serverless functions)
- Output Directory:
.(default)
- Project Name:
Configure environment variables
Add all required environment variables from Environment variables.In your project settings → Environment Variables, add:Required:
POP_ENV=productionSTELLAR_HORIZON_URL=https://horizon.stellar.orgSTELLAR_NETWORK_PASSPHRASE=Public Global Stellar Network ; September 2015SUPABASE_URL= Your Supabase project URLSUPABASE_SERVICE_ROLE_KEY= Your service role keyWEB_ORIGIN= Your web app URL (e.g.,https://app.yourdomain.com)CORS_ALLOWED_ORIGINS= Same as WEB_ORIGIN
EXECUTION_STATE_SECRET= Strong random string (32+ chars)ANCHOR_CALLBACK_SECRET= Strong random string (32+ chars)CRON_SECRET= Strong random string (32+ chars)
STELLAR_ANCHOR_DIRECTORY_URL= URL to anchor export JSONSEP10_CLIENT_DOMAIN= Your app domainMAX_COMPARE_ROUTES=12
You can set these for all environments (Production, Preview, Development) or configure them separately.
Deploy API service
Click Deploy. Vercel will:
- Build your serverless functions
- Deploy to a production URL
- Set up automatic deployments for future commits
https://your-project.vercel.appDeploy web service
Create Vercel project for Web
- Go to Vercel Dashboard
- Click Add New → Project
- Import the same PayOnProof repository
- Configure project settings:
- Project Name:
payonproof-web(or your preferred name) - Framework Preset: Next.js
- Root Directory:
services/web - Build Command:
npm run build(auto-detected) - Output Directory:
.next(auto-detected)
- Project Name:
Configure environment variables
Add frontend environment variables:
NEXT_PUBLIC_POP_ENV=productionNEXT_PUBLIC_API_BASE_URL= Your API URL (e.g.,https://api.yourdomain.com)NEXT_PUBLIC_APP_URL= Your web app URL (e.g.,https://app.yourdomain.com)
Deploy web service
Click Deploy. Vercel will:
- Build your Next.js application
- Deploy to a production URL
- Set up automatic deployments
https://your-project.vercel.appVercel configuration files
API service configuration
The API service includes avercel.json configuration file:
services/api/vercel.json
Update the
Access-Control-Allow-Origin header to match your production web URL.Cron jobs
The API service includes a cron job configuration for anchor catalog synchronization:- Path:
/api/anchors/ops - Schedule: Daily at midnight UTC (
0 0 * * *)
Deployment workflow
Automatic deployments
Vercel automatically deploys:- Production: Commits to your main/master branch
- Preview: Commits to other branches and pull requests
Manual deployments
Deploy manually using the Vercel CLI:Environment-specific configurations
Staging environment
Create a separate Vercel project for staging:- Follow the same deployment steps
- Use staging environment variables:
POP_ENV=stagingSTELLAR_HORIZON_URL=https://horizon-testnet.stellar.org- Point to a staging Supabase database
- Deploy from a
stagingordevelopbranch
Preview deployments
Preview deployments are created automatically for:- Pull requests
- Non-production branches
Post-deployment verification
Verify web application
- Visit your web app URL
- Test the send payment flow
- Verify API connectivity
- Check browser console for errors
Verify cron job
- Go to API project → Settings → Cron Jobs
- Verify the anchor sync job is scheduled
- Check Deployments → Functions for execution logs
Troubleshooting
Build failures
TypeScript errors:- Run
npm run typechecklocally before deploying - Fix type errors in your code
- Verify all dependencies are in
package.json - Run
npm installlocally to updatepackage-lock.json
Function timeouts
- Vercel free tier: 10-second timeout
- Vercel Pro: 60-second timeout
- Optimize slow operations or upgrade your plan
Environment variable issues
- Variables are environment-specific (Production/Preview/Development)
- Redeploy after changing environment variables
- Check logs for missing variable errors
CORS errors
- Verify
CORS_ALLOWED_ORIGINSmatches your web app URL - Update
vercel.jsonCORS headers - Ensure no trailing slashes in URLs
Cron job not running
- Verify cron schedule in
vercel.json - Check function logs in Vercel dashboard
- Ensure
CRON_SECRETis set (if required)
Monitoring and logs
Access deployment logs:- Go to Vercel Dashboard → Your Project
- Click Deployments
- Select a deployment
- View build logs and runtime logs