Overview
SkillRise uses environment variables to configure database connections, authentication, payments, AI services, and media uploads. This guide walks you through setting up all required configuration.Backend Configuration
Create Server Environment File
Navigate to server directory
Create .env file
Add environment variables
server/.env and add the following:Backend Environment Variables
Database Configuration
- Local MongoDB
- MongoDB Atlas
SkillRise is automatically appended in configs/mongodb.js:7INR, USD, EUR).Used in:server/controllers/userController.js:123server/services/payments/razorpay.service.js:14
Clerk Authentication
Create a Clerk application
- Go to dashboard.clerk.com
- Click Create Application
- Choose Email and OAuth providers (Google, GitHub recommended)
- Click Create Application
Get API keys
- Go to API Keys in the sidebar
- Copy Publishable key →
CLERK_PUBLISHABLE_KEY - Copy Secret key →
CLERK_SECRET_KEY
Configure webhook (for user sync)
- In Clerk dashboard, go to Webhooks → Add Endpoint
- Enter endpoint URL:
- Local dev (with ngrok):
https://your-ngrok-url.ngrok.app/clerk - Production:
https://api.yourapp.com/clerk
- Local dev (with ngrok):
- Select events:
user.created,user.updated,user.deleted - Click Create
- Copy Signing Secret →
CLERK_WEBHOOK_SECRET
Local development with ngrok
Local development with ngrok
pk_test_ (test) or pk_live_ (production).sk_test_ or sk_live_.whsec_.Used in server/controllers/webhooks.js to verify request authenticity.Cloudinary (Media Uploads)
Create Cloudinary account
- Go to cloudinary.com/users/register_free
- Sign up for a free account (25 GB storage, 25 GB bandwidth/month)
Get credentials
- Go to Dashboard (home page)
- Find Account Details section
- Copy:
- Cloud Name →
CLOUDINARY_NAME - API Key →
CLOUDINARY_API_KEY - API Secret →
CLOUDINARY_SECRET_KEY
- Cloud Name →
server/configs/cloudinary.js:6 to configure the Cloudinary SDK.Razorpay (Payment Processing)
Create Razorpay account
- Go to dashboard.razorpay.com/signup
- Sign up (requires Indian phone number and business details)
- Complete KYC verification
Get API keys
- Go to Settings → API Keys
- Click Generate Test Key (for development)
- Copy:
- Key ID →
RAZORPAY_KEY_ID - Key Secret →
RAZORPAY_KEY_SECRET
- Key ID →
Configure webhook
- Go to Settings → Webhooks
- Click Add New Webhook
- Enter webhook URL:
- Local:
https://your-ngrok-url.ngrok.app/razorpay - Production:
https://api.yourapp.com/razorpay
- Local:
- Select events:
payment.captured,payment.failed - Copy Secret →
RAZORPAY_WEBHOOK_SECRET
rzp_test_ or rzp_live_).Used in:server/services/payments/razorpay.service.js:11server/services/payments/razorpay.service.js:33
server/controllers/webhooks.js:45 to validate payment notifications.Groq AI (Chatbot & Roadmap)
Get Groq API key
- Go to console.groq.com
- Sign in with Google or GitHub
- Click API Keys in sidebar
- Click Create API Key
- Copy the key (starts with
gsk_)
server/services/chatbot/aiChatbotService.js:3- AI chatbot- Quiz generation
- Learning roadmap generation
openai/gpt-oss-120b model by default. Groq offers generous free tier limits.Optional Variables
server/server.js:29 to configure CORS policy.server/server.js:123 to start the HTTP server.development- Enables verbose loggingproduction- EnforcesFRONTEND_URLrequirement
Frontend Configuration
Create Client Environment File
Navigate to client directory
Create .env file
Add environment variables
client/.env and add:Frontend Environment Variables
CLERK_PUBLISHABLE_KEY).client/src/main.jsx:6- Initialize ClerkProviderclient/src/context/AppContext.jsx- Auth state
VITE_ prefix is required for Vite to expose the variable to client code.client/src/context/AppContext.jsx:23- Axios instance base URLclient/src/hooks/useTimeTracker.js:12- Analytics tracking
Verify Configuration
Before running the application, verify your configuration:Configuration Checklist
Backend environment
Verify server/.env
Verify server/.env
-
MONGODB_URI- Database connection string -
CLERK_PUBLISHABLE_KEY- Clerk public key -
CLERK_SECRET_KEY- Clerk secret key -
CLERK_WEBHOOK_SECRET- Clerk webhook secret -
CLOUDINARY_NAME- Cloudinary cloud name -
CLOUDINARY_API_KEY- Cloudinary API key -
CLOUDINARY_SECRET_KEY- Cloudinary API secret -
RAZORPAY_KEY_ID- Razorpay key ID -
RAZORPAY_KEY_SECRET- Razorpay key secret -
RAZORPAY_WEBHOOK_SECRET- Razorpay webhook secret -
GROQ_CHATBOT_API_KEY- Groq API key
Frontend environment
Verify client/.env
Verify client/.env
-
VITE_CLERK_PUBLISHABLE_KEY- Clerk public key -
VITE_BACKEND_URL- Backend API URL
External services configured
- Clerk webhook endpoint created
- Razorpay webhook endpoint created
- MongoDB database accessible
- Cloudinary account active
Environment Variable Reference
Complete .env template (server)
Complete .env template (server)
Complete .env template (client)
Complete .env template (client)
Troubleshooting
Environment variables not loading
Environment variables not loading
undefined when accessing process.env.VARIABLE_NAMESolutions:- Verify
.envfile exists in the correct directory (server/orclient/) - Restart the dev server after changing
.env - For Vite (client), ensure variables start with
VITE_ - Check for typos in variable names (they’re case-sensitive)
CORS errors when calling API
CORS errors when calling API
Access to XMLHttpRequest at 'http://localhost:3000/api/...' from origin 'http://localhost:5173' has been blocked by CORS policySolutions:- Set
FRONTEND_URL=http://localhost:5173inserver/.env - Verify
VITE_BACKEND_URL=http://localhost:3000inclient/.env - Restart both servers
Clerk authentication not working
Clerk authentication not working
- Verify
CLERK_PUBLISHABLE_KEYmatches in bothserver/.envandclient/.env(asVITE_CLERK_PUBLISHABLE_KEY) - Check Clerk dashboard → API Keys → ensure you’re using keys from the correct application
- Clear browser cookies and localStorage, then try again
MongoDB connection failed
MongoDB connection failed
MongoServerError: Authentication failedSolutions:- Verify
MONGODB_URIis correct - For Atlas: ensure your IP is whitelisted in Network Access
- For Atlas: verify database user credentials are correct
- For local: ensure MongoDB is running (
brew services listorsudo systemctl status mongod)
Cloudinary uploads failing
Cloudinary uploads failing
Invalid API keySolutions:- Go to Cloudinary dashboard → verify cloud name, API key, and secret
- Ensure no extra spaces in
.envvalues - Restart the server after updating
.env