CROP
ProjectsParts Services

Environment Configuration

Quick Start for New Developers

Environment Configuration

Quick Start for New Developers

  1. Copy example files:
for service in payment catalog user search cart health-analytics analytics media; do
  cp services/$service/.env.example services/$service/.env
done
  1. Get secrets from team lead (MongoDB URI, API tokens, etc.)

  2. Start services:

bun run dev

File Structure

Each service has exactly 2 env files:

FilePurposeGit
.env.exampleTemplate with placeholders✅ Committed
.envActual secrets for local dev❌ Ignored

Shared Secrets

All services share these credentials:

VariableSourceUsed By
MONGODB_URIMongoDB AtlasAll services
SENTRY_DSNSentry.ioAll services
ADMIN_API_TOKENGenerate locallysearch, catalog, analytics

Service Ports

ServicePort
cart3000
search3001
payment3004
user3005
health-analytics3005
catalog3010
analytics3020

Environment-Specific Config

EnvironmentMongoDB DatabaseAPI Gateway
Developmentcrop_devhttp://localhost:*
Stagecrop_stagehttps://api.crop-dev.app
Productioncrop_prodhttps://api.crop.app

Generating Secrets

# Admin API token
openssl rand -hex 32

# Webhook secret (Stripe/Clerk format)
openssl rand -base64 32 | tr -d '\n' | sed 's/^/whsec_/'

Troubleshooting

Service won't start:

  • Check .env file exists (not just .env.example)
  • Verify MongoDB URI is accessible
  • Check port isn't already in use

Authentication errors:

  • Verify CLERK_* variables match Clerk dashboard
  • Check ADMIN_API_TOKEN matches between services

On this page