backend/.env- Backend environment variables with your database configuration.env.local- Frontend environment variables for Next.js
- ✅ DATABASE_URL - Connected to your Render PostgreSQL database
- Database:
alphadb_y2ju - Host:
dpg-d5chbk95pdvs73cd5qo0-a.virginia-postgres.render.com - User:
alphadb_y2ju_user - SSL: Enabled
- Database:
- PORT: 5000
- NODE_ENV: development
- JWT_SECRET: Configured (
⚠️ Change in production!)
- SMTP_HOST: smtp.gmail.com
- SMTP_PORT: 587
- EMAIL_USER:
⚠️ Update with your email - EMAIL_PASS:
⚠️ Update with your app password - EMAIL_DISABLED: false
- OTP_SKIP_EXPIRY: false
- OTP_GRACE_MS: 120000 (2 minutes)
- CORS_ORIGIN: http://localhost:3000,http://localhost:5000
- NEXT_PUBLIC_API_URL: http://localhost:5000
If you want email functionality (password reset, OTP), update these in backend/.env:
EMAIL_USER=your-actual-email@gmail.com
EMAIL_PASS=your-gmail-app-specific-passwordHow to get Gmail App Password:
- Go to Google Account Settings
- Enable 2-Factor Authentication
- Go to Security → App Passwords
- Generate a new app password for "Mail"
- Copy the 16-character password
Or disable emails during development:
EMAIL_DISABLED=trueFor production, generate a secure JWT secret:
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"Then update JWT_SECRET in backend/.env
The database tables need to be created. Run the migration:
cd backend
npx sequelize-cli db:migrateThis will create all necessary tables including:
super_adminsactivitiesplansmerchantsagentscustomers- And all other tables
Create your first super admin account:
cd backend
node create-super-admin.jsFollow the prompts to enter:
- Name
- Password (minimum 8 characters)
cd backend
npm run devExpected output:
Database connection has been established successfully.
Server is running on port 5000
In a new terminal:
# From root directory
npm run devExpected output:
ready - started server on 0.0.0.0:3000
- Open browser: http://localhost:3000/admin
- Login with the super admin credentials you created
- Verify dashboard shows real data from your database
Test the database connection:
cd backend
node -e "require('dotenv').config(); const {Sequelize} = require('sequelize'); const seq = new Sequelize(process.env.DATABASE_URL, {dialect:'postgres', dialectOptions:{ssl:{require:true,rejectUnauthorized:false}}}); seq.authenticate().then(() => console.log('✅ Database connected!')).catch(e => console.error('❌ Error:', e.message));"Expected output:
✅ Database connected!
Your database is hosted on Render with the following details:
- Database Name: alphadb_y2ju
- Host: dpg-d5chbk95pdvs73cd5qo0-a.virginia-postgres.render.com
- Port: 5432
- SSL: Required (already configured)
- ✅ Current configuration is suitable for development
- ✅ Database credentials are in
.env(gitignored)
- Change JWT_SECRET to a strong, unique value
- Update EMAIL credentials if using email features
- Set NODE_ENV=production in backend/.env
- Update CORS_ORIGIN to your production frontend URL
- Update NEXT_PUBLIC_API_URL to your production backend URL
- Never commit
.envfiles to version control
Error: "Connection refused"
- Check if DATABASE_URL is correct in
backend/.env - Verify your IP is whitelisted on Render (if applicable)
- Ensure SSL is enabled
Error: "password authentication failed"
- Verify database credentials are correct
- Check if password contains special characters (should be URL-encoded in DATABASE_URL)
Error: "relation already exists"
- Some tables may already exist
- Check which tables exist:
npx sequelize-cli db:migrate:status - You can skip existing migrations or drop and recreate
Error: "Invalid login"
- Verify EMAIL_USER and EMAIL_PASS are correct
- Use Gmail App Password, not regular password
- Or set EMAIL_DISABLED=true to skip emails
Error: "Failed to fetch"
- Verify backend is running on port 5000
- Check NEXT_PUBLIC_API_URL in
.env.local - Restart frontend server after changing
.env.local
Alphaweb-main/
├── backend/
│ └── .env ✅ Backend configuration
├── .env.local ✅ Frontend configuration
└── ENV_SETUP_COMPLETE.md ✅ This file
- Created
backend/.envwith database configuration - Created
.env.localwith API URL - Database credentials configured
- JWT secret configured
- Run database migration
- Create super admin user
- Update email configuration (optional)
- Start backend server
- Start frontend server
- Test login and verify data
Your environment is now configured with:
- ✅ Database connection to Render PostgreSQL
- ✅ Backend environment variables
- ✅ Frontend API configuration
- ✅ Security settings
Next: Follow the steps above to run migrations and start the servers!
Need Help? Check the troubleshooting section above or refer to:
Last Updated: January 3, 2026