All configuration is via environment variables. Set them in .env (Docker Compose) or your deployment environment.
Runtime
| Variable | Required | Default | Description |
|---|
UNISAVE_ENV | No | local | Environment name (local, staging, production) |
UNISAVE_PORT | No | 8080 | HTTP server listen port |
Database
| Variable | Required | Default | Description |
|---|
UNISAVE_DATABASE_URL | Yes | — | Postgres connection string. Example: postgres://unisave:unisave@localhost:5432/unisave?sslmode=disable |
UNISAVE_DB_MAX_CONNS | No | 10 | Max pool connections (must be > 0) |
UNISAVE_DB_MIN_CONNS | No | 1 | Min pool connections (0 ≤ min ≤ max) |
UNISAVE_DB_MAX_CONN_LIFETIME_SECONDS | No | 1800 | Max connection age in seconds |
UNISAVE_DB_MAX_CONN_IDLE_SECONDS | No | 300 | Max idle time before connection is closed |
UNISAVE_DB_HEALTH_CHECK_PERIOD_SECONDS | No | 30 | Health check interval (must be > 0) |
Authentication
Change these from the defaults before deploying. The example values in .env.example are placeholders only.
| Variable | Required | Default | Description |
|---|
UNISAVE_JWT_HMAC_KEY | Yes | — | HMAC signing key for JWT access tokens. Minimum 32 bytes. |
UNISAVE_REFRESH_TOKEN_PEPPER | Yes | — | Pepper for hashing refresh tokens. Minimum 16 bytes. |
OAuth Providers
| Variable | Required | Default | Description |
|---|
UNISAVE_GOOGLE_OAUTH_CLIENT_ID | No* | — | Google OAuth client ID for ID token verification |
UNISAVE_APPLE_OAUTH_CLIENT_ID | No* | — | Apple OAuth client ID (Services ID) |
*Required if you want Google/Apple sign-in. Without these, only anonymous auth works.
AI & Embeddings
| Variable | Required | Default | Description |
|---|
UNISAVE_EMBEDDING_DIM | No | 768 | Vector embedding dimension for semantic search |
UNISAVE_OPENAI_API_KEY | No* | — | API key for generating embeddings |
*Required for semantic search. Without this, search falls back to FTS + fuzzy only.
Rate Limiting & Quotas
| Variable | Required | Default | Description |
|---|
UNISAVE_FREE_ENRICH_PER_MINUTE | No | 5 | Max enrichments per minute for free users |
UNISAVE_FREE_ENRICH_PER_MONTH | No | 200 | Max enrichments per month for free users |
Testing
These variables are only used by go test — ignored by runtime binaries.
| Variable | Required | Default | Description |
|---|
UNISAVE_TEST_DATABASE_URL | No | — | Postgres URL for integration tests. Tests skip if unset. |
UNISAVE_TEST_ALLOW_NON_LOCAL_DB | No | 0 | Set to 1 to allow tests against non-localhost databases |
Generating Secrets
# JWT HMAC key (32+ bytes)
openssl rand -base64 32
# Refresh token pepper (16+ bytes)
openssl rand -hex 16
Minimal Production .env
UNISAVE_ENV=production
UNISAVE_PORT=8080
UNISAVE_DATABASE_URL=postgres://user:pass@db-host:5432/unisave?sslmode=require
UNISAVE_JWT_HMAC_KEY=<your-32-byte-random-key>
UNISAVE_REFRESH_TOKEN_PEPPER=<your-16-byte-random-pepper>
UNISAVE_GOOGLE_OAUTH_CLIENT_ID=<your-google-client-id>
UNISAVE_APPLE_OAUTH_CLIENT_ID=<your-apple-services-id>
UNISAVE_OPENAI_API_KEY=<your-openai-key>