Skip to main content

Environment File

The Reservations application requires environment variables to be defined in a .env file at the root of the project. Create this file before running the application:
touch .env

Required Environment Variables

All environment variables listed below are required for the application to run successfully. The application validates these variables on startup and will fail if any are missing.

Application Settings

PORT
string
required
The port number on which the backend server will listen
PORT=8080
APP_ENV
string
required
The application environment (e.g., development, production, staging)
APP_ENV=development

Database Configuration

DB_HOST
string
required
PostgreSQL database host address
DB_HOST=localhost
DB_PORT
string
required
PostgreSQL database port (default: 5432)
DB_PORT=5432
DB_DATABASE
string
required
Name of the PostgreSQL database
DB_DATABASE=reservations
DB_USERNAME
string
required
PostgreSQL database username
DB_USERNAME=postgres
DB_PASSWORD
string
required
PostgreSQL database password
DB_PASSWORD=your_secure_password
DB_SCHEMA
string
required
PostgreSQL schema name (usually public)
DB_SCHEMA=public

JWT Authentication

JWT_ACCESS_SECRET
string
required
Secret key for signing JWT access tokens. Use a strong, randomly generated string.
JWT_ACCESS_SECRET=your_access_secret_key_min_32_chars
JWT_ACCESS_EXP_MIN
integer
required
JWT access token expiration time in minutes
JWT_ACCESS_EXP_MIN=15
JWT_REFRESH_SECRET
string
required
Secret key for signing JWT refresh tokens. Use a different strong, randomly generated string.
JWT_REFRESH_SECRET=your_refresh_secret_key_min_32_chars
JWT_REFRESH_EXP_MIN
integer
required
JWT refresh token expiration time in minutes
JWT_REFRESH_EXP_MIN=10080
10080 minutes equals 7 days

Email Configuration

RESEND_API_TEST
string
required
Resend API key for sending transactional emails. Get your API key from Resend
RESEND_API_TEST=re_xxxxxxxxxxxx
ENABLE_EMAILS
boolean
required
Enable or disable email sending functionality
ENABLE_EMAILS=true
Set to false in development to prevent sending emails

OAuth Configuration

GOOGLE_OAUTH_CLIENT_ID
string
required
Google OAuth 2.0 client ID for Google authentication. Obtain from Google Cloud Console
GOOGLE_OAUTH_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRET
string
required
Google OAuth 2.0 client secret
GOOGLE_OAUTH_CLIENT_SECRET=your_google_client_secret
FACEBOOK_OAUTH_CLIENT_ID
string
required
Facebook OAuth client ID (App ID) for Facebook authentication. Obtain from Facebook Developers
FACEBOOK_OAUTH_CLIENT_ID=your_facebook_app_id
FACEBOOK_OAUTH_CLIENT_SECRET
string
required
Facebook OAuth client secret (App Secret)
FACEBOOK_OAUTH_CLIENT_SECRET=your_facebook_app_secret

Frontend Configuration

VITE_MAPBOX_TOKEN
string
required
Mapbox access token for map functionality in the frontend. Get your token from Mapbox
VITE_MAPBOX_TOKEN=pk.xxxxxxxxxxxx
This variable is prefixed with VITE_ to expose it to the Vite frontend build

Example .env File

Here’s a complete example .env file with all required variables:
.env
# Application
PORT=8080
APP_ENV=development

# Database
DB_HOST=localhost
DB_PORT=5432
DB_DATABASE=reservations
DB_USERNAME=postgres
DB_PASSWORD=your_secure_password
DB_SCHEMA=public

# JWT Authentication
JWT_ACCESS_SECRET=your_access_secret_key_min_32_chars
JWT_ACCESS_EXP_MIN=15
JWT_REFRESH_SECRET=your_refresh_secret_key_min_32_chars
JWT_REFRESH_EXP_MIN=10080

# Email
RESEND_API_TEST=re_xxxxxxxxxxxx
ENABLE_EMAILS=false

# OAuth
GOOGLE_OAUTH_CLIENT_ID=your_google_client_id.apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRET=your_google_client_secret
FACEBOOK_OAUTH_CLIENT_ID=your_facebook_app_id
FACEBOOK_OAUTH_CLIENT_SECRET=your_facebook_app_secret

# Frontend
VITE_MAPBOX_TOKEN=pk.xxxxxxxxxxxx
Never commit the .env file to version control. It should be included in your .gitignore file.

Validation

The application validates all required environment variables on startup (see backend/cmd/config/config.go:84-103). If any variables are missing or invalid, the application will fail to start with a clear error message indicating which variable is missing.

Next Steps

Build docs developers (and LLMs) love