Configuration
DearDiary uses environment variables for configuration. Create a .env file in the project root.
Environment Variables
| Variable | Default | Description |
|---|---|---|
BACKEND_JWT_SECRET |
Required | Secret key for JWT token signing. Generate a strong random string. |
BACKEND_PORT |
3001 | Port for the backend API server |
BACKEND_CORS_ORIGIN |
* | CORS allowed origins (comma-separated) |
BACKEND_REGISTRATION_ENABLED |
false | Allow new user registration (true/false) |
BACKEND_DATABASE_URL |
file:/data/deardiary.db | SQLite database path |
BACKEND_MEDIA_DIR |
/data/media | Directory for uploaded media files |
BACKEND_DEFAULT_USER_EMAIL |
- | Email for default admin user (created on first start) |
BACKEND_DEFAULT_USER_PASSWORD |
- | Password for default admin user |
BACKEND_DEFAULT_AI_PROVIDER |
groq | Default AI provider (groq, openai, anthropic, ollama, lmstudio) |
BACKEND_DEFAULT_AI_MODEL |
llama-3.3-70b-versatile | Default AI model |
BACKEND_DEFAULT_AI_API_KEY |
- | Default API key for AI provider |
BACKEND_DEFAULT_AI_BASE_URL |
- | Custom API base URL (for local providers) |
Example .env File
BACKEND_JWT_SECRET=your-super-secret-key-change-this
BACKEND_CORS_ORIGIN=https://your-domain.com
BACKEND_REGISTRATION_ENABLED=false
BACKEND_DEFAULT_USER_EMAIL=admin@your-domain.com
BACKEND_DEFAULT_USER_PASSWORD=change-me-after-login
BACKEND_DEFAULT_AI_PROVIDER=groq
BACKEND_DEFAULT_AI_API_KEY=your-groq-api-key
Using System Default AI Settings
When BACKEND_DEFAULT_AI_* variables are set, all new users will use those settings by default. Users can override these in their personal settings.
Tip: For production, always set
BACKEND_REGISTRATION_ENABLED=false and create the admin user via BACKEND_DEFAULT_USER_EMAIL and BACKEND_DEFAULT_USER_PASSWORD.