Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

StyleGrab is configured via environment variables. Copy .env.example to .env and customize.

Required Variables

VariableDescription
DATABASE_URLPostgreSQL connection string
JWT_SECRETSecret key for JWT token signing (min 32 chars)
STRIPE_SECRET_KEYStripe API secret key for payments
STRIPE_WEBHOOK_SECRETStripe webhook signing secret

Optional Variables

VariableDefaultDescription
HOST0.0.0.0Server bind address
PORT3000Server port
BROWSER_WS_URLws://127.0.0.1:9222CDP WebSocket URL for headless browser
REDIS_URLredis://127.0.0.1:6379Redis connection URL
LOG_LEVELinfoLogging level (trace, debug, info, warn, error)

Example Configuration

# Database
DATABASE_URL=postgres://stylegrab:password@localhost:5432/stylegrab

# Authentication
JWT_SECRET=your-super-secret-jwt-key-min-32-characters

# Stripe (for payments)
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

# Browser
BROWSER_WS_URL=ws://chrome:9222

# Server
HOST=0.0.0.0
PORT=3000

# Redis (optional, for caching)
REDIS_URL=redis://localhost:6379

# Logging
LOG_LEVEL=info

Database Migrations

Migrations run automatically on startup. To run them manually:

# Using sqlx-cli
cargo install sqlx-cli
sqlx migrate run

# Or via Docker
docker compose exec app sqlx migrate run

Production Considerations

Security

  • Use strong, unique values for JWT_SECRET
  • Enable HTTPS via a reverse proxy (nginx, Caddy, etc.)
  • Restrict database access to the application server only
  • Use environment-specific Stripe keys (live vs test)

Performance

  • Enable Redis caching for frequently accessed data
  • Use connection pooling for PostgreSQL
  • Run multiple app instances behind a load balancer

Monitoring

Set LOG_LEVEL=debug for troubleshooting. In production, use info or warn.

Next Steps