Skip to main content
This guide covers deploying GitRead to production, with a focus on Vercel deployment and production configuration.

Overview

GitRead is built with Next.js 14, making it optimized for deployment on Vercel, the platform created by Next.js’s developers. However, it can also be deployed to other platforms that support Next.js.

Prerequisites

Before deploying, ensure you have:
  • All environment variables configured for production
  • Production accounts for:
  • A GitHub repository with your GitRead code
  • Access to the Python ingestion API or your own hosted version

Deploying to Vercel

1

Connect your repository

  1. Sign in to Vercel
  2. Click “Add New” → “Project”
  3. Import your GitHub repository
  4. Select the repository containing GitRead
2

Configure the project

Vercel will automatically detect Next.js settings:
  • Framework Preset: Next.js
  • Build Command: next build
  • Output Directory: .next
  • Install Command: npm install
3

Add environment variables

In the Vercel project settings, add all environment variables:
  1. Go to Project Settings → Environment Variables
  2. Add each variable from your .env.local file
  3. Set them for Production, Preview, and Development environments
Never commit production secrets to your repository. Always use Vercel’s environment variable system.
4

Update production URLs

Update these environment variables with your production URLs:
# Update after first deployment
NEXT_PUBLIC_APP_URL=https://your-domain.vercel.app

# Update Clerk URLs if using custom domain
NEXT_PUBLIC_CLERK_AFTER_SIGN_IN_URL=https://your-domain.vercel.app/
NEXT_PUBLIC_CLERK_AFTER_SIGN_UP_URL=https://your-domain.vercel.app/
5

Deploy

Click “Deploy” to start the build process. Vercel will:
  • Install dependencies
  • Build the Next.js application
  • Deploy to a production URL
  • Set up automatic deployments for future commits

Custom domain setup

GitRead supports multiple domains with automatic redirects (configured in middleware.ts:6):
1

Add your domain in Vercel

  1. Go to Project Settings → Domains
  2. Add your custom domain (e.g., gitread.dev)
  3. Follow DNS configuration instructions
2

Configure domain redirects

The middleware handles redirects from alternate domains:
// Redirects from gitread.com to gitread.dev
if (host === 'gitread.com' || host.endsWith('.gitread.com')) {
  const url = req.nextUrl.clone()
  url.host = 'gitread.dev'
  return NextResponse.redirect(url)
}
Supported domain patterns:
  • gitread.comgitread.dev
  • generatemyreadme.comgitread.dev
  • pleasegeneratemyreadmesoidonthaveto.comgitread.dev
3

Update service configurations

Update your custom domain in:
  • Clerk: Add domain to allowed origins
  • Stripe: Update success/cancel URLs
  • Environment variables: Update NEXT_PUBLIC_APP_URL

Database setup

1

Run production migrations

In your Supabase production project:
  1. Navigate to SQL Editor
  2. Run migrations from supabase/migrations/:
    • 20240320000000_rls_policies.sql
    • 20240320000000_add_credit_transaction.sql
2

Verify Row Level Security

Ensure RLS is enabled on all tables:
ALTER TABLE user_credits ENABLE ROW LEVEL SECURITY;
ALTER TABLE generated_readmes ENABLE ROW LEVEL SECURITY;
ALTER TABLE processed_stripe_events ENABLE ROW LEVEL SECURITY;
3

Create database indexes

Indexes are created automatically by the migration:
CREATE INDEX idx_user_credits_user_id ON user_credits(user_id);
CREATE INDEX idx_generated_readmes_user_id ON generated_readmes(user_id);
CREATE INDEX idx_processed_stripe_events_event_id ON processed_stripe_events(event_id);

Stripe webhook configuration

For production payment processing:
1

Create a webhook endpoint

  1. Go to Stripe Dashboard → Developers → Webhooks
  2. Click “Add endpoint”
  3. Enter your webhook URL: https://your-domain.vercel.app/api/verify-payment
2

Select events to listen to

Subscribe to these events:
  • checkout.session.completed
  • payment_intent.succeeded
3

Add webhook signing secret

Copy the webhook signing secret and add it to Vercel environment variables:
STRIPE_WEBHOOK_SECRET=whsec_...

Production considerations

Performance optimization

  • Image optimization: Next.js automatically optimizes images
  • Code splitting: Components are automatically code-split
  • Edge functions: Middleware runs on Vercel Edge Network
  • ISR: Consider adding Incremental Static Regeneration for static pages

Security best practices

Always use environment variables for secrets. Never hardcode API keys in your source code.
  • Enable HTTPS only (automatic with Vercel)
  • Use strong Clerk security settings
  • Enable Supabase RLS policies
  • Validate all user inputs
  • Use CORS headers appropriately
  • Monitor Stripe webhooks for fraud

Rate limiting

The application includes built-in queue management (app/api/generate/route.ts:119):
const MAX_QUEUE_SIZE = 20;
const requestQueue: (() => Promise<void>)[] = [];

if (requestQueue.length >= MAX_QUEUE_SIZE) {
  return NextResponse.json({ 
    error: 'Server is busy. Please try again in a few moments.' 
  }, { status: 429 });
}
Consider implementing additional rate limiting:
  • Per-user rate limits
  • IP-based rate limiting
  • API key rate limiting for the Python ingestion service

Monitoring and logging

Vercel provides built-in monitoring:
  1. Analytics: Track page views and Web Vitals
  2. Logs: View real-time function logs
  3. Errors: Monitor and track errors
For additional monitoring, consider:
  • Sentry for error tracking
  • LogRocket for session replay
  • Supabase built-in logging
  • Stripe Dashboard for payment monitoring

Environment-specific configuration

Development

NEXT_PUBLIC_APP_URL=http://localhost:3000

Preview (Vercel)

NEXT_PUBLIC_APP_URL=https://gitread-git-branch-name.vercel.app

Production

NEXT_PUBLIC_APP_URL=https://gitread.dev

Deployment checklist

Before going live:
  • All environment variables configured in Vercel
  • Database migrations run in production Supabase
  • Clerk production instance configured
  • Stripe webhook configured and tested
  • Custom domain configured and DNS updated
  • Test sign-up and sign-in flows
  • Test README generation with various repositories
  • Test payment flow with real card
  • Verify credit deduction and history saving
  • Check error handling and logging
  • Review security settings
  • Set up monitoring and alerts

Continuous deployment

Vercel automatically deploys:
  • Production: Commits to main branch
  • Preview: Pull requests and other branches

Git workflow

  1. Create a feature branch
  2. Make changes and commit
  3. Push to GitHub
  4. Vercel creates a preview deployment
  5. Merge to main after testing
  6. Vercel deploys to production automatically

Rollback and versioning

To rollback a deployment:
  1. Go to Vercel Dashboard → Deployments
  2. Find the previous working deployment
  3. Click ”…” → “Promote to Production”
Always test preview deployments before merging to production.

Alternative deployment platforms

While Vercel is recommended, GitRead can be deployed to:
  • Netlify: Requires adapter configuration
  • AWS Amplify: Supports Next.js SSR
  • Railway: Simple Node.js deployment
  • Self-hosted: Using Docker or PM2
For these platforms, consult their Next.js deployment guides.

Troubleshooting

Build failures

  1. Check Vercel build logs
  2. Verify all dependencies are in package.json
  3. Ensure environment variables are set
  4. Test build locally: npm run build

Runtime errors

  1. Check Vercel function logs
  2. Verify API endpoints are accessible
  3. Test database connections
  4. Check external service status (Clerk, Stripe, OpenRouter)

Performance issues

  1. Review Vercel Analytics
  2. Optimize large dependencies
  3. Implement caching strategies
  4. Consider upgrading Vercel plan for higher limits

Next steps

Build docs developers (and LLMs) love