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:
- Clerk (authentication)
- Supabase (database)
- Stripe (payments)
- OpenRouter (AI model access)
- A GitHub repository with your GitRead code
- Access to the Python ingestion API or your own hosted version
Deploying to Vercel
Connect your repository
- Sign in to Vercel
- Click “Add New” → “Project”
- Import your GitHub repository
- Select the repository containing GitRead
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
Add environment variables
In the Vercel project settings, add all environment variables:
- Go to Project Settings → Environment Variables
- Add each variable from your
.env.localfile - Set them for Production, Preview, and Development environments
Custom domain setup
GitRead supports multiple domains with automatic redirects (configured inmiddleware.ts:6):
Add your domain in Vercel
- Go to Project Settings → Domains
- Add your custom domain (e.g.,
gitread.dev) - Follow DNS configuration instructions
Configure domain redirects
The middleware handles redirects from alternate domains:Supported domain patterns:
gitread.com→gitread.devgeneratemyreadme.com→gitread.devpleasegeneratemyreadmesoidonthaveto.com→gitread.dev
Database setup
Run production migrations
In your Supabase production project:
- Navigate to SQL Editor
- Run migrations from
supabase/migrations/:20240320000000_rls_policies.sql20240320000000_add_credit_transaction.sql
Stripe webhook configuration
For production payment processing:Create a webhook endpoint
- Go to Stripe Dashboard → Developers → Webhooks
- Click “Add endpoint”
- Enter your webhook URL:
https://your-domain.vercel.app/api/verify-payment
Select events to listen to
Subscribe to these events:
checkout.session.completedpayment_intent.succeeded
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
- 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):
- 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:- Analytics: Track page views and Web Vitals
- Logs: View real-time function logs
- Errors: Monitor and track errors
- Sentry for error tracking
- LogRocket for session replay
- Supabase built-in logging
- Stripe Dashboard for payment monitoring
Environment-specific configuration
Development
Preview (Vercel)
Production
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
mainbranch - Preview: Pull requests and other branches
Git workflow
- Create a feature branch
- Make changes and commit
- Push to GitHub
- Vercel creates a preview deployment
- Merge to
mainafter testing - Vercel deploys to production automatically
Rollback and versioning
To rollback a deployment:- Go to Vercel Dashboard → Deployments
- Find the previous working deployment
- 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
Troubleshooting
Build failures
- Check Vercel build logs
- Verify all dependencies are in
package.json - Ensure environment variables are set
- Test build locally:
npm run build
Runtime errors
- Check Vercel function logs
- Verify API endpoints are accessible
- Test database connections
- Check external service status (Clerk, Stripe, OpenRouter)
Performance issues
- Review Vercel Analytics
- Optimize large dependencies
- Implement caching strategies
- Consider upgrading Vercel plan for higher limits
Next steps
- Review all environment variables
- Configure authentication for production
- Set up monitoring and error tracking
- Plan for scaling and optimization