Skip to content

Understanding Backend Env

To get started with the backend server of The DevStarter boilerplate, we need to configure the following environment variables. Each variable has been explained below with its use case and example value.

General Configuration

These variables configure general settings for the backend server.

  • DJANGO_SECRET_KEY: Django secret key for security purposes.
    • Example: YourSecretKeyHere
  • DJANGO_DEBUG: Set to ‘true’ or ‘false’ to enable or disable debug mode in Django. Never set to ‘true’ in production.
    • Example: true
  • BASE_URL: Base URL for the backend server.
    • Example: http://localhost:8000
  • COMPANY_NAME: Company name associated with the project.
    • Example: YourCompanyName

Database

These variables configure the database connection for the backend server.

  • POSTGRES_DB_NAME: Name of the PostgreSQL database.
    • Example: dev_db
  • POSTGRES_USER: Username for PostgreSQL database access.
    • Example: admin
  • POSTGRES_PASSWORD: Password for PostgreSQL database access.
    • Example: password123
  • POSTGRES_HOST: Hostname or IP address of the PostgreSQL server.
    • Example: localhost

Payments

These variables are related to Stripe payments. You can access the required API keys from your Stripe dashboard. For guidance on locating these keys, you can refer to the following URL: Locate API keys in the dashboard

  • STRIPE_WEBHOOK_SECRET_LIVE: Stripe webhook secret for live mode.
    • Example: YourStripeWebhookSecretLive
  • STRIPE_SECRET_KEY: Stripe secret key for handling transactions.
    • Example: YourStripeSecretKey
  • STRIPE_PUBLISHABLE_KEY: Stripe publishable key for handling transactions.
    • Example: YourStripePublishableKey
  • FRONTEND_SITE_URL: URL of the frontend site.
    • Example: https://example.com
  • PAYMENT_SUCCESS_URL: URL to redirect after successful payment.
    • Example: https://example.com/success
  • PAYMENT_FAILURE_URL: URL to redirect after failed payment.
    • Example: https://example.com/failure

AUTH

These variables are related to authentication and authorization. You can obtain the required Google OAuth2 credentials by following the instructions provided in the Getting Google OAuth2 credentials guide.

  • JWT_AUTH_SECRET: Secret string for JWT authentication.
    • Example: YourJWTAuthSecret
  • JWT_AUTH_ALGORITHM: Algorithm used for JWT authentication.
    • Example: HS256
  • DJANGO_SETTINGS_MODULE: Django settings module for the backend.
    • Example: thedevstarter_backend.settings
  • GOOGLE_OAUTH2_CLIENT_ID: Google OAuth2 client ID.
    • Example: YourGoogleOAuth2ClientID
  • GOOGLE_OAUTH2_CLIENT_SECRET: Google OAuth2 client secret.
    • Example: YourGoogleOAuth2ClientSecret
  • GOOGLE_REDIRECT_URI: Redirect URI after Google OAuth2 authentication.
    • Example: http://localhost:3000/callback
  • PASSWORD_REDIRECT_URI: Redirect URI after password reset.
    • Example: http://localhost:3000/forgot-password
  • DEFAULT_USER_AVATAR: URL or path to the default user avatar image.
    • Example: https://example.com/default-avatar.png
  • VERIFY_EMAIL_ON_SIGNUP: Whether to send an email verification link on signup or not.
    • Example: true or false
  • EMAIL_VERIFICATION_REDIRECT_URI: Redirect URI after email verification.
    • Example: http://localhost:3000/callback
  • AUTH_TOKEN_EXPIRY_DAYS: Expiry duration of authentication tokens in days.
    • Example: 14

EMAIL

These variables are related to email configuration.

  • EMAIL_BACKEND: Backend for sending emails.
    • Example: 'django.core.mail.backends.smtp.EmailBackend'
  • EMAIL_HOST: SMTP server hostname.
    • Example: smtp.example.com
  • EMAIL_HOST_USER: User for SMTP server.
    • Example: smtp_user@example.com
  • EMAIL_HOST_PASSWORD: Password for SMTP server.
    • Example: YourSMTPPassword

SENTRY

These variables are related to Sentry, a monitoring solution for error tracking.

  • SENTRY_DSN: Sentry Data Source Name for error tracking.
    • Example: YourSentryDSN

Newsletters and Captchas

Newsletters are managed by Beehiv. You can configure any newsletter provider or build your own based on your use case.

Brevo is used to manage the user email lists to send product updates, etc., to your users.

The DevStarter uses reCAPTCHA to protect open API routes like contact us forms, and you can configure it to use it for your use cases from the codebase.

Storage

The project utilizes Django Storages, a powerful storage plugin for Django, configured here with AWS S3. However, it can be used with any provider such as Google Cloud Storage, Digital Ocean, Azure, etc. For more details about the Storage configuration, please refer to the documentation at DocumentationURL.

  • USE_S3: Set to False to use local storage for images.
    • Example: False
  • MEDIA_ROOT: Root directory for media files.
    • Example: media/
  • AWS_ACCESS_KEY_ID: Access key ID for AWS S3.
    • Example: YourAWSAccessKeyID
  • AWS_SECRET_ACCESS_KEY: Secret access key for AWS S3.
    • Example: YourAWSSecretAccessKey
  • AWS_REGION_NAME: AWS region name where the bucket is located.
    • Example: us-west-1
  • AWS_BUCKET_NAME: Name of the AWS S3 bucket.
    • Example: your-bucket-name
## Django Settings
DJANGO_SECRET_KEY="YourSecretKeyHere"
DJANGO_DEBUG="true"
DJANGO_SETTINGS_MODULE="thedevstarter_backend.settings"
## Base URL Configuration
BASE_URL="http://localhost:8000"
FRONTEND_SITE_URL="FRONTEND_SITE_URL"
GOOGLE_REDIRECT_URI="http://localhost:3000/callback"
PASSWORD_REDIRECT_URI="http://localhost:3000/forgot-password"
PAYMENT_SUCCESS_URL="PAYMENT_SUCCESS_URL"
PAYMENT_FAILURE_URL="PAYMENT_FAILURE_URL"
EMAIL_VERIFICATION_REDIRECT_URI="http://localhost:3000/callback"
## Database Configuration
POSTGRES_DB_NAME="dev_db"
POSTGRES_USER="admin"
POSTGRES_PASSWORD="password123"
POSTGRES_HOST="localhost"
## Stripe Configuration
STRIPE_WEBHOOK_SECRET_LIVE="STRIPE_WEBHOOK_SECRET_LIVE"
STRIPE_SECRET_KEY="STRIPE_SECRET_KEY"
STRIPE_PUBLISHABLE_KEY="STRIPE_PUBLISHABLE_KEY"
## JWT Authentication
JWT_AUTH_SECRET="JWT_AUTH_SECRET"
JWT_AUTH_ALGORITHM='HS256'
AUTH_TOKEN_EXPIRY_DAYS=14
## Google OAuth2 Configuration
GOOGLE_OAUTH2_CLIENT_ID='GOOGLE_OAUTH2_CLIENT_ID'
GOOGLE_OAUTH2_CLIENT_SECRET='GOOGLE_OAUTH2_CLIENT_SECRET'
## Default User Avatar
DEFAULT_USER_AVATAR="any user avatar image"
## Email Configuration
EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST="SMTP server"
EMAIL_HOST_USER='User for SMTP server'
EMAIL_HOST_PASSWORD='Password for SMTP server'
ADMIN_EMAIL='ADMIN_EMAIL'
## Error Tracking (Sentry)
SENTRY_DSN="SENTRY_DSN"
## Beehiv Configuration
BEEHIV_API_KEY='BEEHIV_API_KEY'
BEEHIV_PUBLICATION_ID='BEEHIV_PUBLICATION_ID'
## reCAPTCHA Configuration
RECAPTCHA_SECRET_KEY="RECAPTCHA_SECRET_KEY"
## Brevo Configuration
BREVO_API_KEY="BREVO_API_KEY"
## AWS S3 Configuration
USE_S3=False
MEDIA_ROOT="media/"
AWS_ACCESS_KEY_ID="AWS_ACCESS_KEY_ID"
AWS_SECRET_ACCESS_KEY="AWS_SECRET_ACCESS_KEY"
AWS_REGION_NAME="AWS_REGION_NAME"
AWS_BUCKET_NAME="AWS_BUCKET_NAME"