# Root
cp .env.example .env
# Backend
cp apps/backend/.env.example apps/backend/.env
# Frontend
cp apps/frontend/.env.example apps/frontend/.env
# Contracts
cp packages/contracts/.env.example packages/contracts/.env# Generate JWT secret (copy output to apps/backend/.env)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"# MongoDB
docker run -d -p 27017:27017 --name muse-mongo mongo:6
# Redis (optional)
docker run -d -p 6379:6379 --name muse-redis redis:7# Edit configuration
nano apps/backend/.env
# Validate setup
npm run validate-env
# Start development
npm run dev| Error | Cause | Solution |
|---|---|---|
Cannot find module 'mongodb' |
Mongoose not installed | npm install in backend |
MONGODB_URI is undefined |
.env file missing | cp apps/backend/.env.example apps/backend/.env |
connection refused 127.0.0.1:27017 |
MongoDB not running | docker run -d -p 27017:27017 mongo:6 |
JWT_SECRET is too short |
Less than 32 characters | Use generator: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" |
Port 3001 already in use |
Another service on port | Change PORT in .env or kill process |
Cannot reach http://localhost:3001 |
Backend not started | npm run dev:backend or check firewall |
CORS error from frontend |
Wrong FRONTEND_URL | Check CORS_ORIGINS in backend .env matches frontend URL |
Connection to Redis failed |
Redis not running | Install Redis or use fallback (leave REDIS_URL empty) |
API key invalid |
OpenAI/Stability key incorrect | Verify key at platform.openai.com or stability.ai |
Contract ID not found |
Stellar contract not deployed | Deploy contract or use testnet test ID |
PORT=3001
NODE_ENV=development
FRONTEND_URL=http://localhost:3000
MONGODB_URI=mongodb://localhost:27017/muse
JWT_SECRET=generated_secret_hereVITE_API_URL=http://localhost:3001
VITE_ENVIRONMENT=developmentmongodb://localhost:27017/muse
mongodb+srv://user:password@cluster.mongodb.net/muse?retryWrites=true&w=majority
redis://localhost:6379
redis://:password@host:port
# Generate JWT Secret (32 bytes = 64 hex chars)
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Output example:
# a7f3d1e9b2c6f4a8d5e0c2b9f1d7a4e6c8f0b3d5e7a9c1e3f5b7d9e1f3a5c7Copy this to apps/backend/.env as:
JWT_SECRET=a7f3d1e9b2c6f4a8d5e0c2b9f1d7a4e6c8f0b3d5e7a9c1e3f5b7d9e1f3a5c7# 1. Install dependencies
npm install
# 2. Create .env files
cp .env.example .env
cp apps/backend/.env.example apps/backend/.env
cp apps/frontend/.env.example apps/frontend/.env
# 3. Start MongoDB (if local)
# macOS: brew services start mongodb-community
# Docker: docker run -d -p 27017:27017 mongo:6
# Cloud: Create MongoDB Atlas cluster
# 4. Edit configuration
# Update MONGODB_URI if not using localhost
# Set OPENAI_API_KEY if available
# Set STELLAR_CONTRACT_ID if deployed
# 5. Validate
npm run validate-env
# 6. Start
npm run dev
# 7. Test
# Frontend: http://localhost:3000
# Backend: http://localhost:3001/health# In Node.js backend
console.log(process.env.MONGODB_URI);
console.log(process.env.JWT_SECRET);# In browser console (Vite exposes VITE_ variables)
console.log(import.meta.env.VITE_API_URL);# MongoDB
mongosh "mongodb://localhost:27017/muse"
# Redis
redis-cli ping # Should return PONG
# Backend API
curl http://localhost:3001/health
# Frontend
curl http://localhost:3000MONGODB_URI- Database connectionJWT_SECRET- Password for tokensVITE_API_URL- Frontend backend connection
OPENAI_API_KEY- AI generationSTELLAR_CONTRACT_ID- Blockchain address
REDIS_URL- Caching (has fallback)VITE_SENTRY_DSN- Error tracking
.env # Root (optional)
apps/backend/.env # Backend (required)
apps/backend/.env.test # Testing (optional)
apps/frontend/.env # Frontend (required)
packages/contracts/.env # Contracts (optional)
scripts/validate-env.js # Validator script
ENVIRONMENT_SETUP.md # Full documentation
ENVIRONMENT_SETUP_CHECKLIST.md # Interactive checklist
-
Use different secrets per environment
- Dev: Local secrets, less critical
- Prod: Highly secure, rotated regularly
-
Keep .env locally, never commit
git status # Should NOT show .env -
Test configuration before running
npm run validate-env
-
Use Docker for services
docker-compose up # If provided -
Generate strong JWT secret
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))" -
Monitor logs for errors
LOG_LEVEL=debug npm run dev
- Review Documentation: ENVIRONMENT_SETUP.md
- Check Checklist: ENVIRONMENT_SETUP_CHECKLIST.md
- Validate Setup:
npm run validate-env - Check Logs: Look for error messages in console
- Verify Services: Test MongoDB, Redis connectivity
- GitHub Issues: Search existing issues or create new one
| Variable | Backend | Frontend | Contracts | Required? |
|---|---|---|---|---|
| PORT | ✅ | - | - | No (default: 3001) |
| NODE_ENV | ✅ | - | - | Yes |
| MONGODB_URI | ✅ | - | - | Yes |
| JWT_SECRET | ✅ | - | - | Yes |
| VITE_API_URL | - | ✅ | - | Yes |
| OPENAI_API_KEY | ✅ | - | - | No |
| STELLAR_NETWORK | ✅ | - | ✅ | Yes |
| STELLAR_CONTRACT_ID | ✅ | - | - | Yes |
| DEPLOYER_PRIVATE_KEY | - | - | ✅ | No |
- Start Here: README.md Quick Start section
- Setup Guide: ENVIRONMENT_SETUP.md for detailed instructions
- Interactive: ENVIRONMENT_SETUP_CHECKLIST.md to verify setup
- Reference: This document for quick lookup
- Troubleshooting: ENVIRONMENT_SETUP.md troubleshooting section
Last Updated: March 27, 2026 For Full Documentation: See ENVIRONMENT_SETUP.md