Skip to main content

Environment Setup

This guide covers setting up your development environment for the Sprout platform.

Prerequisites

Required Software

  • Node.js: v18.0 or higher
  • Bun: Latest version (preferred package manager)
  • Docker: For running PostgreSQL, Redis, and other services
  • Git: For version control
  • Doppler CLI: For environment variable management

Optional Tools

  • Docker Compose: For orchestrating multiple services
  • PostgreSQL Client: For direct database access
  • Redis CLI: For debugging cache/queue issues

Doppler Setup

All environment variables are managed through Doppler. The project uses the "dev" environment and does not use .env files.

Install Doppler CLI

# macOS
brew install doppler

# Or using npm
npm install -g doppler-cli

Authenticate with Doppler

doppler login

Setup Project Access

# Navigate to your project directory
cd /Users/stef/apps/sprout

# Setup Doppler for the project (you'll need the project token)
doppler setup

Running Commands with Doppler

All commands that require environment variables should be run with doppler run:

# Example: Running the backend server
cd sprout_backend
doppler run -- bun run start:dev

# Example: Running ETL service
cd sprout_etl
doppler run -- bun run start:dev

Docker Services

Most repositories require PostgreSQL and Redis. Use Docker Compose to run these services:

Starting Services

# In sprout_backend or sprout_etl directory
docker-compose up -d

This will start:

  • PostgreSQL (typically port 5432)
  • Redis (typically port 6379)

Verifying Services

# Check if PostgreSQL is running
docker ps | grep postgres

# Check if Redis is running
docker ps | grep redis

MeiliSearch Setup

MeiliSearch is used for full-text search. You can run it via Docker:

docker run -d \
-p 7700:7700 \
-e MEILI_MASTER_KEY=your_master_key \
getmeili/meilisearch:latest

Or use the MeiliSearch instance configured in Doppler.

Service Ports

Default ports used by Sprout services:

  • sprout_backend: 3000 (API), 4001 (Worker)
  • sprout_etl: 3001 (API), 4002 (Worker)
  • pricing_dashboard: 5173 (Vite dev server)
  • MeiliSearch: 7700
  • PostgreSQL: 5432
  • Redis: 6379
  • Prometheus: 9090
  • Grafana: 3000
  • Loki: 3100

Development Workflow

  1. Start Docker services:

    cd sprout_backend
    docker-compose up -d
  2. Install dependencies (using bun):

    cd sprout_backend
    bun install
  3. Run database migrations:

    cd sprout_backend
    doppler run -- npx prisma migrate dev
  4. Start the service:

    doppler run -- bun run start:dev

Troubleshooting

Port Already in Use

If a port is already in use, either:

  • Stop the conflicting service
  • Change the port in the service configuration
  • Use lsof -i :PORT to find what's using the port

Doppler Authentication Issues

# Re-authenticate
doppler login

# Verify setup
doppler setup

Database Connection Issues

  • Verify Docker containers are running: docker ps
  • Check database URL in Doppler matches Docker setup
  • Ensure migrations have been run

Missing Environment Variables

All required environment variables should be in Doppler. Check the service's config.ts or src/config.ts for required variables.

Next Steps