Overview
Replit is the primary deployment platform for JOIP Web Application, offering seamless hosting with built-in authentication, automatic HTTPS, and zero-configuration deployment. This guide covers the complete deployment process from initial setup to production.Prerequisites
Before deploying to Replit, ensure you have:- A Replit account (free or paid)
- PostgreSQL database (Neon recommended)
- Supabase project for file storage
- Required API keys (Reddit, AI providers)
- Basic understanding of environment variables
Deployment Steps
Create New Repl
- Log in to Replit
- Click “Create Repl”
- Select “Import from GitHub” or upload your code
- Choose Node.js as the language
- Name your Repl (e.g., “joip-production”)
Configure Environment Variables
Navigate to the Secrets tab (Tools → Secrets) and add all required environment variables. See the Environment Variables page for the complete reference.Critical Variables:
Configure Replit OIDC Authentication
Replit provides built-in OpenID Connect (OIDC) authentication. Configure these variables:The application automatically detects Replit environment and enables OIDC when
REPLIT_DOMAINSsupports multiple domains separated by commasREPL_IDis automatically populated by Replit- The app prioritizes
app.joip.ioif present in domains
REPLIT_DOMAINS is set.Install Dependencies
Run the following command in the Replit Shell:This installs all dependencies defined in
package.json.Setup Database Schema
Apply database migrations to create all required tables:This command uses Drizzle ORM to synchronize your database schema with the definitions in
shared/schema.ts.Build Production Bundle
Create optimized production builds:This command:
- Bundles the React client with Vite →
dist/public/ - Compiles the Express server with esbuild →
dist/index.js - Optimizes assets for production delivery
Configure Replit Run Command
In Or use the Replit interface:
.replit file, set the run command:- Click the three dots next to “Run”
- Select “Configure the run button”
- Set command to
npm start
Custom Domain Setup
Replit supports custom domains for paid plans:Add Custom Domain
- Open your Repl settings
- Navigate to Domains
- Click “Add custom domain”
- Enter your domain (e.g.,
app.joip.io)
Replit-Specific Configuration
Automatic Environment Detection
The application automatically detects Replit deployment through environment variables:OIDC Authentication Flow
WhenREPLIT_DOMAINS is set, the application uses Passport.js with Replit OIDC strategy:
- User clicks “Login with Replit”
- Redirect to Replit’s identity service
- User authorizes the application
- Callback to
/api/callbackwith auth code - Exchange code for user profile
- Create/update user in database
- Establish session with secure cookies
Session Management
Replit deployments use secure session cookies:Port Configuration
JOIP always runs on port 5000 regardless of environment:Do not change the port number. Replit’s internal proxy expects port 5000.
Environment Validation
The application validates environment setup on startup:Deployment Checklist
Pre-Deployment
- Database provisioned and accessible
- All environment variables configured
- Supabase project created and configured
- API keys obtained (Reddit, OpenRouter, etc.)
- Custom domain DNS configured (if applicable)
Initial Deployment
- Dependencies installed (
npm install) - Database schema applied (
npm run db:push) - Production build created (
npm run build) - Environment validation passes
- Application starts successfully
Troubleshooting
OIDC Authentication Fails
Symptoms: Login redirects fail or show errors Solutions:- Verify
REPLIT_DOMAINSincludes your actual domain - Check
REPL_IDis set correctly - Ensure
ISSUER_URL=https://identity.util.repl.co - Clear browser cookies and try again
Database Connection Errors
Symptoms: “Connection timeout” or “Connection refused” errors Solutions:- Verify
DATABASE_URLformat:postgresql://user:pass@host:5432/db - Check database firewall allows Replit IP ranges
- Test connection with
npm run db:push - Review Neon/database provider status page
File Upload Failures
Symptoms: Manual sessions or media vault uploads fail Solutions:- Check Supabase project is not paused
- Verify all three Supabase env vars are set
- Test storage with
GET /api/storage/status - Review Supabase Storage bucket permissions
Application Won’t Start
Symptoms: Run button fails or crashes immediately Solutions:- Check for TypeScript errors:
npm run check - Review startup logs in Replit console
- Verify all required env vars are set
- Rebuild:
npm run build - Clear Replit cache and reinstall:
rm -rf node_modules && npm install
Performance Optimization
Enable Connection Pooling
For better database performance, configure connection pool settings:Monitor Resource Usage
Replit provides built-in monitoring:- Open your Repl
- Click “Monitoring” in the left sidebar
- Review CPU, memory, and network usage
- Set up alerts for threshold breaches
Enable Always On (Paid Plans)
For production deployments, enable “Always On” to prevent automatic shutdown:- Open Repl settings
- Toggle “Always On”
- Your application will run 24/7 without sleeping
Security Best Practices
- Use strong
SESSION_SECRET(32+ random characters) - Rotate API keys periodically
- Enable Replit’s “Private” Repl setting for closed-source projects
- Review Replit audit logs regularly
- Keep dependencies updated:
npm update - Monitor for security advisories:
npm audit
Scaling Considerations
Database Scaling
Neon supports automatic scaling:- Enable autoscaling in Neon dashboard
- Set compute limits based on traffic
- Monitor query performance
- Add read replicas for heavy read workloads
File Storage Scaling
Supabase Storage scales automatically:- Buckets have no hard file limits
- CDN handles global distribution
- Monitor storage quota in Supabase dashboard
- Implement cleanup jobs for old files
Application Scaling
For high-traffic deployments:- Upgrade to Replit’s higher-tier plans
- Enable connection pooling (see above)
- Implement Redis caching for session data
- Consider load balancing across multiple Repls
Next Steps
Environment Variables
Complete reference for all environment variables
Database Setup
PostgreSQL and Neon configuration guide
Storage Configuration
Supabase Storage setup and management
Architecture
Understanding JOIP’s technical architecture