This document explains all environment variables required by the CodeX Club Backend.
Environment variables allow the application to be configured without changing the source code. They store sensitive information such as database credentials, API secrets, and third-party service configuration.
Create a new .env file in the project root.
backend/
│
├── .env
├── .env.example
├── package.json
└── src/
Copy the sample configuration.
cp .env.example .envThen replace the placeholder values with your own configuration.
These variables configure the Express server.
| Variable | Required | Description | Default |
|---|---|---|---|
NODE_ENV |
No | Application environment | development |
PORT |
No | Backend server port | 5000 |
SERVER_URL |
No | Backend server URL | http://localhost:5000 |
CORS_ORIGIN |
No | Allowed frontend origin | * |
Example
NODE_ENV=development
PORT=5000
SERVER_URL=http://localhost:5000
CORS_ORIGIN=http://localhost:5173MongoDB connection configuration.
| Variable | Required | Description |
|---|---|---|
MONGODB_URI |
Yes | MongoDB connection string |
Example
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/codexUsed for administrator authentication and session management.
| Variable | Required | Description |
|---|---|---|
ACCESS_TOKEN_SECRET |
Yes | Secret used to sign JWT tokens |
ACCESS_TOKEN_EXPIRY |
Yes | JWT expiration time |
Example
ACCESS_TOKEN_SECRET=your-super-secret-key
ACCESS_TOKEN_EXPIRY=10dCloudinary stores uploaded images.
Used for:
- Event Cover Images
- Team Member Photos
| Variable | Required | Description |
|---|---|---|
CLOUDINARY_CLOUD_NAME |
Yes | Cloudinary cloud name |
CLOUDINARY_API_KEY |
Yes | Cloudinary API key |
CLOUDINARY_API_SECRET |
Yes | Cloudinary API secret |
Example
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=xxxxxxxxxxxx
CLOUDINARY_API_SECRET=xxxxxxxxxxxxxxxxSMTP credentials are used for sending emails.
Used for:
- Login OTP
- Registration Updates
- Certificate Emails
| Variable | Required | Description |
|---|---|---|
SMTP_HOST |
Yes | SMTP server host |
SMTP_PORT |
Yes | SMTP server port |
SMTP_USER |
Yes | SMTP username |
SMTP_PASSWORD |
Yes | SMTP password |
FROM_EMAIL |
Yes | Sender email address |
FROM_NAME |
Yes | Sender display name |
Example
SMTP_HOST=smtp.mailtrap.io
SMTP_PORT=2525
SMTP_USER=your_username
SMTP_PASSWORD=your_password
FROM_EMAIL=noreply@codex.com
FROM_NAME="CodeX Team"These values are used only during the initial admin seeding process.
| Variable | Required | Description |
|---|---|---|
ADMIN_USERNAME |
No | Initial administrator username |
ADMIN_PASSWORD |
No | Initial administrator password |
Example
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123Note
These variables are only used when creating the first administrator account.
Used when generating links that point to the frontend application.
Examples include:
- Certificate Verification
- Email Links
| Variable | Required | Description |
|---|---|---|
FRONTEND_URL |
Yes | Frontend application URL |
Example
FRONTEND_URL=http://localhost:5173Cloudflare Turnstile protects public forms from automated bots.
Currently used for:
- Student Registration (
/api/v1/students/register) - Contact Inquiries (
/api/v1/contact)
| Variable | Required | Description |
|---|---|---|
TURNSTILE_SECRET |
Yes | Cloudflare Turnstile secret key |
TURNSTILE_HOSTNAMES |
No | Comma-separated list of allowed hostnames (e.g. qucodex.com,api.qucodex.com) |
Example
TURNSTILE_SECRET=0x4AAAAAAD5...
TURNSTILE_HOSTNAMES=qucodex.com,api.qucodex.com# Server
NODE_ENV=development
PORT=5000
SERVER_URL=http://localhost:5000
CORS_ORIGIN=http://localhost:5173
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/codex
# JWT
ACCESS_TOKEN_SECRET=your-super-secret-access-token-key
ACCESS_TOKEN_EXPIRY=10d
# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
# SMTP
SMTP_HOST=smtp.mailtrap.io
SMTP_PORT=2525
SMTP_USER=your_smtp_user
SMTP_PASSWORD=your_smtp_password
FROM_EMAIL=noreply@codex.com
FROM_NAME="CodeX Team"
# Admin
ADMIN_USERNAME=admin
ADMIN_PASSWORD=admin123
# Frontend
FRONTEND_URL=http://localhost:5173
# Turnstile
TURNSTILE_SECRET_KEY=your_turnstile_secret- Never commit the
.envfile to Git. - Commit only the
.env.examplefile. - Use strong, randomly generated JWT secrets.
- Rotate secrets periodically.
- Store production credentials securely.
- Use different credentials for development and production.
- Keep API keys and passwords private.
Before deploying, verify the following:
- All required environment variables are configured.
- MongoDB connection string is correct.
- JWT secret is secure.
- Cloudinary credentials are valid.
- SMTP credentials can send emails.
- Frontend URL points to the production frontend.
- CORS origin is restricted to trusted domains.
| Document | Description |
|---|---|
getting-started.md |
Local project setup |
authentication.md |
JWT and authentication flow |
deployment.md |
Production deployment guide |
security.md |
Security recommendations |