Skip to main content

Overview

SkillRise requires environment variables for database connections, third-party services, and application configuration. The server uses runtime environment variables, while the client uses build-time variables.

Server Variables

Runtime configuration via .env file

Client Variables

Build-time configuration with Vite

Server Environment Variables

The server reads variables from a .env file in the server/ directory at runtime.

Quick Reference

Configuration File

Create a .env file in the server/ directory:
server/.env
Never commit the .env file to version control. Add it to .gitignore.

Variable Details

PORT (Optional)
  • Type: Number
  • Default: 3000
  • Usage: server.js:157
  • Description: HTTP server listening port
NODE_ENV (Optional)
  • Type: String
  • Values: development, production
  • Usage: server.js:26, server.js:149
  • Description: Controls error logging verbosity and CORS validation
FRONTEND_URL (Required in production)
  • Type: URL
  • Default: http://localhost:5173
  • Usage: server.js:26-29
  • Description: CORS allowed origin for frontend requests
In production, FRONTEND_URL must be set to prevent “CORS origin mismatch” errors.
BACKEND_PUBLIC_URL (Optional)
  • Type: URL
  • Fallback: VITE_BACKEND_URL
  • Usage: userController.js:66-67
  • Description: Public-facing backend URL for email links and webhooks
MONGODB_URI (Required)
  • Type: Connection string
  • Usage: configs/mongodb.js:7
  • Description: MongoDB connection URI
  • Format: mongodb+srv://username:password@host/database?options
The database name SkillRise is automatically appended to the connection string.
Getting MongoDB URI:
1

Create MongoDB Atlas Account

2

Create Cluster

  • Choose cloud provider and region
  • Select free tier (M0) or paid tier
  • Click “Create Cluster”
3

Configure Database Access

  • Go to Database Access
  • Click Add New Database User
  • Create username and password
  • Grant “Read and write to any database” permission
4

Configure Network Access

  • Go to Network Access
  • Click Add IP Address
  • Add 0.0.0.0/0 for all IPs (or restrict to your server IP)
5

Get Connection String

  • Go to ClustersConnect
  • Choose Connect your application
  • Copy connection string
  • Replace <password> with your database user password
Example:
Remove /test or any database name from the connection string. The server appends /SkillRise automatically.
CLERK_WEBHOOK_SECRET (Required)
  • Type: String (starts with whsec_)
  • Usage: controllers/webhooks.js:10
  • Description: Secret key for verifying Clerk webhook signatures
Getting Clerk Webhook Secret:
1

Create Clerk Application

Sign up at clerk.com and create a new application
2

Configure Webhook Endpoint

  • Go to Webhooks in Clerk dashboard
  • Click Add Endpoint
  • Enter URL: https://yourdomain.com/clerk
  • Select events: user.created, user.updated, user.deleted
3

Copy Signing Secret

  • After creating endpoint, reveal Signing Secret
  • Copy the whsec_... value
  • Add to .env as CLERK_WEBHOOK_SECRET
Clerk webhooks sync user data between Clerk and your MongoDB database.
CLOUDINARY_NAME (Required)
  • Type: String
  • Usage: configs/cloudinary.js:5
  • Description: Cloudinary cloud name
CLOUDINARY_API_KEY (Required)
  • Type: String
  • Usage: configs/cloudinary.js:6
  • Description: Cloudinary API key
CLOUDINARY_SECRET_KEY (Required)
  • Type: String
  • Usage: configs/cloudinary.js:7
  • Description: Cloudinary API secret
Getting Cloudinary Credentials:
1

Create Cloudinary Account

Sign up at cloudinary.com
2

Access Dashboard

Go to Dashboard after logging in
3

Copy Credentials

Find the Account Details section:
  • Cloud name: Your unique cloud name
  • API Key: Your API key (15 digits)
  • API Secret: Click “Reveal” to see secret
Usage in SkillRise:
  • Course thumbnails
  • Lesson video uploads
  • User profile pictures
  • Certificate backgrounds
  • Community post images
RAZORPAY_KEY_ID (Required)
  • Type: String (starts with rzp_test_ or rzp_live_)
  • Usage: services/payments/razorpay.service.js:16, razorpay.service.js:37
  • Description: Razorpay API key ID
RAZORPAY_KEY_SECRET (Required)
  • Type: String
  • Usage: services/payments/razorpay.service.js:17, razorpay.service.js:50
  • Description: Razorpay API key secret
RAZORPAY_WEBHOOK_SECRET (Required)
  • Type: String
  • Usage: controllers/webhooks.js:72
  • Description: Webhook signature verification secret
CURRENCY (Optional)
  • Type: ISO 4217 currency code
  • Default: INR
  • Usage: razorpay.service.js:20, userController.js:508
  • Description: Currency for payment amounts
  • Supported: INR, USD, EUR, GBP, etc.
Getting Razorpay Credentials:
1

Create Razorpay Account

Sign up at razorpay.com
2

Generate API Keys

  • Go to SettingsAPI Keys
  • Click Generate Test Keys (for testing)
  • Or Generate Live Keys (for production)
  • Copy Key ID and Key Secret
3

Configure Webhook

  • Go to SettingsWebhooks
  • Click Add Webhook
  • Enter URL: https://yourdomain.com/razorpay
  • Select events: payment.authorized, payment.captured, payment.failed
  • Copy Webhook Secret
Use test keys (rzp_test_...) during development and live keys (rzp_live_...) in production.
GROQ_CHATBOT_API_KEY (Required)
  • Type: String (starts with gsk_)
  • Usage: services/chatbot/aiChatbotService.js:3
  • Description: Groq API key for AI chatbot functionality
Getting Groq API Key:
1

Create Groq Account

Sign up at console.groq.com
2

Generate API Key

  • Go to API Keys section
  • Click Create API Key
  • Name your key (e.g., “SkillRise Production”)
  • Copy the generated key (starts with gsk_)
3

Set Usage Limits (Optional)

Configure rate limits and spending caps if needed
Groq Features in SkillRise:
  • AI-powered course assistant chatbot
  • Quiz generation from course content
  • Personalized learning roadmap generation
  • Content recommendations
Groq offers high-speed LLM inference with generous free tier limits.

Client Environment Variables

The client uses Vite environment variables that are embedded into the build at compile time.

Quick Reference

Configuration

Client variables are passed as build arguments when building the Docker image:
client/Dockerfile

Local Development

For local development, create a .env file in the client/ directory:
client/.env
Vite automatically loads .env files during development (npm run dev).

Variable Details

Type: String (starts with pk_test_ or pk_live_)
Usage: client/src/main.jsx:11
Description: Clerk publishable key for client-side authentication
Getting the Key:
  1. Go to Clerk Dashboard
  2. Select your application
  3. Navigate to API Keys
  4. Copy Publishable key (starts with pk_test_ or pk_live_)
This is a public key safe to include in client code. Do not confuse with the secret key.
Type: String (starts with pk_test_ or pk_live_)
Usage: Client-side Stripe integration (if implemented)
Description: Stripe publishable key for payment UI
SkillRise currently uses Razorpay for payments. This variable is included for future Stripe integration or international payments.
Getting the Key:
  1. Go to Stripe Dashboard
  2. Click DevelopersAPI keys
  3. Copy Publishable key
Test vs Live:
  • Test key: pk_test_... (for development)
  • Live key: pk_live_... (for production)
Type: URL
Usage: client/src/context/AppContext.jsx:12, client/src/hooks/useTimeTracker.js:28
Description: Backend API base URL for all API requests
Environment-Specific Values:
  • Local development: http://localhost:3000
  • Staging: https://api-staging.yourdomain.com
  • Production: https://api.yourdomain.com
This URL is embedded in the build and cannot be changed after compilation. Ensure it matches your deployment environment.

Build-Time vs Runtime

Runtime Configuration
  • Variables loaded from .env file when server starts
  • Can be changed without rebuilding
  • Update by modifying .env and restarting container
Advantages:
  • Easy to update
  • Different per environment
  • Kept secret from version control

Security Best Practices

Do:
  • Use environment variables for all secrets
  • Never commit .env files to Git
  • Add .env to .gitignore
  • Use different credentials for development/production
  • Rotate secrets regularly
Don’t:
  • Hardcode secrets in source code
  • Share .env files via email or chat
  • Commit secrets to version control
  • Use production secrets in development
  • Log secret values
.gitignore
Public Keys (Safe in client code):
  • VITE_CLERK_PUBLISHABLE_KEY (starts with pk_)
  • VITE_STRIPE_PUBLISHABLE_KEY (starts with pk_)
  • VITE_BACKEND_URL
Secret Keys (Server-only):
  • CLERK_WEBHOOK_SECRET
  • RAZORPAY_KEY_SECRET
  • CLOUDINARY_SECRET_KEY
  • GROQ_CHATBOT_API_KEY
  • MONGODB_URI (contains password)
Never pass secret keys as build arguments to client Docker image. They will be embedded in the JavaScript bundle and exposed to users.
Use separate credentials for each environment:Development:
Staging:
Production:
Store secrets in GitHub repository settings for CI/CD:
  1. Repository SettingsSecrets and variablesActions
  2. Add secrets (never use .env file in CI)
  3. Reference in workflows: ${{ secrets.SECRET_NAME }}
Required GitHub Secrets:
  • DOCKER_USERNAME
  • DOCKER_PASSWORD
  • VITE_CLERK_PUBLISHABLE_KEY
  • VITE_STRIPE_PUBLISHABLE_KEY
  • VITE_BACKEND_URL
Use GitHub Environments for environment-specific secrets (development, staging, production).

Environment Templates

Complete Server .env Template

server/.env.template

Complete Client .env Template

client/.env.template

Validation

Add validation to ensure all required variables are set:
server/validateEnv.js
Run before starting the server:
server/server.js

Troubleshooting

Error:
Solution:
  1. Check .env file exists in correct directory
  2. Verify variable name is spelled correctly
  3. Ensure no spaces around = (use KEY=value, not KEY = value)
  4. Restart server after changing .env
Error:
Solutions:
  • Verify MONGODB_URI is correct
  • Check MongoDB Atlas IP whitelist (add 0.0.0.0/0 or your server IP)
  • Ensure database user has correct permissions
  • Test connection string in MongoDB Compass
Error:
Solutions:
  • Verify CLERK_WEBHOOK_SECRET matches Clerk dashboard
  • Check webhook endpoint URL is correct
  • Ensure request body is not modified before webhook handler
  • Test webhook with Clerk dashboard testing tool
Error:
Solutions:
  • Verify FRONTEND_URL in server .env matches client URL exactly
  • Check VITE_BACKEND_URL in client build is correct
  • Ensure no trailing slashes in URLs
  • Clear browser cache and rebuild client
Issue: Changes to VITE_* variables not reflectedSolution: Client variables are build-time only. You must rebuild:

Next Steps

Docker Deployment

Deploy with environment variables

CI/CD Pipeline

Configure secrets for GitHub Actions