Skip to main content

Overview

DevAurva requires several environment variables to be configured for proper operation. These variables control database connections, email notifications, and server settings.

Required Environment Variables

The following environment variables must be set before running the application:

Database Configuration

  • MONGODB_URI - MongoDB connection string for database access

Email Configuration

  • EMAIL_USER - Gmail account email address for sending notifications
  • EMAIL_PASS - Gmail app password (not your regular password)
  • EMAIL_RECIPIENT - Email address to receive form submissions and notifications
Never commit your .env file to version control. Always add .env to your .gitignore file to prevent exposing sensitive credentials.

Creating the .env File

1
Create the environment file
2
In your project root directory, create a new file named .env:
3
touch .env
4
Add environment variables
5
Open the .env file and add your configuration:
6
# MongoDB Configuration
MONGODB_URI=mongodb+srv://username:[email protected]/devaurva?retryWrites=true&w=majority

# Email Configuration (Gmail)
EMAIL_USER=[email protected]
EMAIL_PASS=your-app-specific-password
EMAIL_RECIPIENT=[email protected]
7
Replace placeholder values
8
Update each variable with your actual credentials:
9
  • Replace username:[email protected] with your MongoDB connection details
  • Replace [email protected] with your Gmail address
  • Replace your-app-specific-password with your Gmail app password
  • Replace [email protected] with the email where you want to receive notifications
  • Environment Variables Reference

    VariableTypeRequiredDescription
    MONGODB_URIStringYesFull MongoDB connection string including credentials and database name
    EMAIL_USERStringYesGmail account used for sending emails via Nodemailer
    EMAIL_PASSStringYesGmail app-specific password (requires 2FA enabled)
    EMAIL_RECIPIENTStringOptionalRecipient email for notifications. Defaults to EMAIL_USER if not set

    Loading Environment Variables

    DevAurva uses the dotenv package to load environment variables. This is configured in server.js:10:
    import dotenv from 'dotenv';
    
    // Load environment variables
    dotenv.config();
    
    The dotenv.config() call automatically loads variables from the .env file in your project root.

    Verifying Setup

    To verify your environment variables are properly configured:
    1
    Start the development server
    2
    node server.js
    
    3
    Check console output
    4
    You should see:
    5
    Connected to MongoDB
    Server running on port 3001
    
    6
    Test connectivity
    7
    If you see connection errors, verify:
    8
  • MongoDB URI is correct and accessible
  • Email credentials are valid
  • All required environment variables are set
  • Security Best Practices:
    • Never share your .env file or commit it to Git
    • Use app-specific passwords for Gmail (not your account password)
    • Rotate credentials regularly
    • Use different credentials for development and production
    • Ensure your MongoDB connection string uses strong passwords

    Next Steps

    After setting up your environment variables:
    1. Configure your MongoDB database
    2. Set up email notifications
    3. Start your development server and test the application

    Build docs developers (and LLMs) love