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
- Example:
DJANGO_DEBUG
: Set to ‘true’ or ‘false’ to enable or disable debug mode in Django. Never set to ‘true’ in production.- Example:
true
- Example:
BASE_URL
: Base URL for the backend server.- Example:
http://localhost:8000
- Example:
COMPANY_NAME
: Company name associated with the project.- Example:
YourCompanyName
- Example:
Database
These variables configure the database connection for the backend server.
POSTGRES_DB_NAME
: Name of the PostgreSQL database.- Example:
dev_db
- Example:
POSTGRES_USER
: Username for PostgreSQL database access.- Example:
admin
- Example:
POSTGRES_PASSWORD
: Password for PostgreSQL database access.- Example:
password123
- Example:
POSTGRES_HOST
: Hostname or IP address of the PostgreSQL server.- Example:
localhost
- Example:
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
- Example:
STRIPE_SECRET_KEY
: Stripe secret key for handling transactions.- Example:
YourStripeSecretKey
- Example:
STRIPE_PUBLISHABLE_KEY
: Stripe publishable key for handling transactions.- Example:
YourStripePublishableKey
- Example:
FRONTEND_SITE_URL
: URL of the frontend site.- Example:
https://example.com
- Example:
PAYMENT_SUCCESS_URL
: URL to redirect after successful payment.- Example:
https://example.com/success
- Example:
PAYMENT_FAILURE_URL
: URL to redirect after failed payment.- Example:
https://example.com/failure
- Example:
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
- Example:
JWT_AUTH_ALGORITHM
: Algorithm used for JWT authentication.- Example:
HS256
- Example:
DJANGO_SETTINGS_MODULE
: Django settings module for the backend.- Example:
thedevstarter_backend.settings
- Example:
GOOGLE_OAUTH2_CLIENT_ID
: Google OAuth2 client ID.- Example:
YourGoogleOAuth2ClientID
- Example:
GOOGLE_OAUTH2_CLIENT_SECRET
: Google OAuth2 client secret.- Example:
YourGoogleOAuth2ClientSecret
- Example:
GOOGLE_REDIRECT_URI
: Redirect URI after Google OAuth2 authentication.- Example:
http://localhost:3000/callback
- Example:
PASSWORD_REDIRECT_URI
: Redirect URI after password reset.- Example:
http://localhost:3000/forgot-password
- Example:
DEFAULT_USER_AVATAR
: URL or path to the default user avatar image.- Example:
https://example.com/default-avatar.png
- Example:
VERIFY_EMAIL_ON_SIGNUP
: Whether to send an email verification link on signup or not.- Example:
true
orfalse
- Example:
EMAIL_VERIFICATION_REDIRECT_URI
: Redirect URI after email verification.- Example:
http://localhost:3000/callback
- Example:
AUTH_TOKEN_EXPIRY_DAYS
: Expiry duration of authentication tokens in days.- Example:
14
- Example:
These variables are related to email configuration.
EMAIL_BACKEND
: Backend for sending emails.- Example:
'django.core.mail.backends.smtp.EmailBackend'
- Example:
EMAIL_HOST
: SMTP server hostname.- Example:
smtp.example.com
- Example:
EMAIL_HOST_USER
: User for SMTP server.- Example:
smtp_user@example.com
- Example:
EMAIL_HOST_PASSWORD
: Password for SMTP server.- Example:
YourSMTPPassword
- Example:
SENTRY
These variables are related to Sentry, a monitoring solution for error tracking.
SENTRY_DSN
: Sentry Data Source Name for error tracking.- Example:
YourSentryDSN
- Example:
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 toFalse
to use local storage for images.- Example:
False
- Example:
MEDIA_ROOT
: Root directory for media files.- Example:
media/
- Example:
AWS_ACCESS_KEY_ID
: Access key ID for AWS S3.- Example:
YourAWSAccessKeyID
- Example:
AWS_SECRET_ACCESS_KEY
: Secret access key for AWS S3.- Example:
YourAWSSecretAccessKey
- Example:
AWS_REGION_NAME
: AWS region name where the bucket is located.- Example:
us-west-1
- Example:
AWS_BUCKET_NAME
: Name of the AWS S3 bucket.- Example:
your-bucket-name
- Example: