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
Backend Environment Variables
Database Configuration
MongoDB connection string.
- Local MongoDB
- MongoDB Atlas
The database name
SkillRise is automatically appended in configs/mongodb.js:7Three-letter ISO currency code for payments (e.g.,
INR, 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
From the Clerk dashboard:
- Go to API Keys in the sidebar
- Copy Publishable key →
CLERK_PUBLISHABLE_KEY - Copy Secret key →
CLERK_SECRET_KEY
Configure webhook (for user sync)
SkillRise syncs Clerk users to MongoDB via webhooks.
- 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
To test webhooks locally:
Public API key for Clerk. Starts with
pk_test_ (test) or pk_live_ (production).Secret API key for Clerk. Starts with
sk_test_ or sk_live_.Signing secret for verifying webhook requests from Clerk. Starts with
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)
Your Cloudinary cloud name (found on dashboard).
API key for Cloudinary uploads.
API secret for signing Cloudinary requests.Used in
server/configs/cloudinary.js:6 to configure the Cloudinary SDK.Razorpay (Payment Processing)
For international users: Replace Razorpay with Stripe. See Payment Integration Guide for Stripe setup.
Create Razorpay account
- Go to dashboard.razorpay.com/signup
- Sign up (requires Indian phone number and business details)
- Complete KYC verification
Get API keys
From Razorpay dashboard:
- Go to Settings → API Keys
- Click Generate Test Key (for development)
- Copy:
- Key ID →
RAZORPAY_KEY_ID - Key Secret →
RAZORPAY_KEY_SECRET
- Key ID →
Razorpay API Key ID (starts with
rzp_test_ or rzp_live_).Used in:server/services/payments/razorpay.service.js:11server/services/payments/razorpay.service.js:33
Razorpay API Key Secret for server-side requests.
Signing secret to verify webhook requests from Razorpay.Used in
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_)
Groq API key for AI chat and roadmap generation.Used in:
server/services/chatbot/aiChatbotService.js:3- AI chatbot- Quiz generation
- Learning roadmap generation
SkillRise uses the
openai/gpt-oss-120b model by default. Groq offers generous free tier limits.Optional Variables
Frontend URL for CORS configuration.Used in
server/server.js:29 to configure CORS policy.Port for the Express server.Used in
server/server.js:123 to start the HTTP server.Node environment mode.
development- Enables verbose loggingproduction- EnforcesFRONTEND_URLrequirement
Frontend Configuration
Create Client Environment File
Frontend Environment Variables
Clerk publishable key (same as backend Used in:
CLERK_PUBLISHABLE_KEY).client/src/main.jsx:6- Initialize ClerkProviderclient/src/context/AppContext.jsx- Auth state
The
VITE_ prefix is required for Vite to expose the variable to client code.Base URL for API requests.Used in:
client/src/context/AppContext.jsx:23- Axios instance base URLclient/src/hooks/useTimeTracker.js:12- Analytics tracking
Razorpay public key ID for client-side checkout (if using Razorpay).
Only required if you’re implementing Razorpay embedded checkout in the frontend.
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
Configuration complete! Proceed to run the application or set up Docker.
Environment Variable Reference
Complete .env template (server)
Complete .env template (server)
server/.env
Complete .env template (client)
Complete .env template (client)
client/.env
Troubleshooting
Environment variables not loading
Environment variables not loading
Symptom:
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
Error:
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
Symptom: Login redirects to 404 or fails silentlySolutions:
- 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
Error:
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
Error:
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