Configuration Guide¶
In this guide, we'll walk through configuring the Craft Your Startup Boilerplate for both local development and production environments. The project uses environment variables stored in .env files to manage settings like database credentials, API keys, and other configurations.
Table of Contents¶
- Environment Files
- Configuring Environment Variables
- Database Configuration
- OAuth and API Keys
- Mailchimp Integration
- Other Environment Variables
- Local vs Production Setup
- Best Practices for Managing Secrets
Environment Files¶
The project uses .env files to manage environment-specific configurations. The following files are typically used:
local.env: For local development.prod.env: For the production environment.local.env.example: An example file provided with default values. This file can be copied to createlocal.envandprod.env.
Setting Up .env Files¶
-
Copy the example environment file to create your
local.envfor development:Bash -
For production, create a
prod.env:Bash -
Customize each file with your environment-specific values (e.g., API keys, database credentials).
Configuring Environment Variables¶
The .env files hold key-value pairs that configure the appโs behavior. Below is a breakdown of the key variables and how to configure them.
Database Configuration¶
You'll need to set up PostgreSQL database connection details for both local and production environments.
| Text Only | |
|---|---|
db_username: The PostgreSQL username.db_password: The PostgreSQL password.db_host: The hostname where your database is running (usuallylocalhostfor development).db_port: The port where the database is accessible (54323 in this example).db_database: The name of the database.db_sslmode: SSL mode for securing the database connection. Typicallyrequirein production.
OAuth and API Keys¶
The project integrates with third-party services like AWS and Google for OAuth. Make sure to configure these in your .env files.
| Text Only | |
|---|---|
google_oauth2_client_id: Your Google OAuth client ID.google_oauth2_secret: Your Google OAuth client secret.aws_access_key_id: AWS access key for interacting with AWS services (e.g., S3).aws_secret_access_key: AWS secret key.
Mailchimp Integration¶
If you're using Mailchimp for transactional emails or email marketing, configure it with the following environment variable:
mailchimp_api_key: The Mailchimp API key, used for accessing Mailchimp services (e.g., email campaigns, transactional emails).
Make sure to securely store your Mailchimp API key to prevent unauthorized access.
Other Environment Variables¶
You may also have additional environment variables for other services and settings.
| Text Only | |
|---|---|
| |
stripe_api_key: API key for Stripe, used for managing payments and subscriptions.stripe_webhook_secret: Webhook secret key for verifying Stripe payment notifications.redirect_after_login: The URL users are redirected to after successful login (usually your React app).support_email: The support email address for users to contact.env: Specifies the environment (e.g.,local,production).
Local vs Production Setup¶
Local Development¶
For local development, ensure your local.env is configured with local database credentials and appropriate development values:
| Text Only | |
|---|---|
Production Environment¶
In the production environment, you'll need to update the values to match your production infrastructure (e.g., cloud database credentials, production API keys).
| Text Only | |
|---|---|
| |
Make sure to secure your production environment and avoid exposing sensitive information like API keys or database credentials.
Best Practices for Managing Secrets¶
-
Use
.envFiles in Development: Keep environment-specific configuration isolated in.envfiles, but never commit these files to version control. Add.envto your.gitignore. -
Use Secret Management in Production: For production, consider using secret management tools like:
- AWS Secrets Manager
- Google Secret Manager
- Vault by HashiCorp
-
Environment Variables in CI/CD: When deploying through a CI/CD pipeline, use your platformโs secret management to inject environment variables securely.
That's it for configuration! Make sure your environment files are properly set up before running the application, and follow best practices for managing secrets in production.