Local Development
Guide to setting up and running the monorepo locally.
Initial Setup
bash
# Clone the repo
git clone <repo-url>
cd emerge-turbo
# Install dependencies and start Redis
pnpm setup:developerThis runs pnpm install and starts a local Redis server.
Environment System
The monorepo uses a profile-based environment system that consolidates scattered .env files into unified configs.
Environment Profiles
Profiles live in config/environments/:
config/environments/
├── secrets/ # Encrypted secrets (git-crypt)
│ ├── local.env
│ ├── staging.env
│ └── production.env
├── base.env # Shared base config
├── local.env # Local development overrides
├── staging.env # Staging overrides
└── production.env # Production overridesBuilding Environment Files
bash
# List available profiles
pnpm env:list
# Build .env files for a profile
pnpm env:buildThe env:build command:
- Reads the profile (local/staging/production)
- Merges base + profile + secrets
- Writes consolidated
.envfiles to each package that needs them
Profile Hierarchy
base.env # Shared defaults
↓
{profile}.env # Profile-specific overrides
↓
secrets/{profile}.env # Secrets (git-crypt encrypted)Database Credentials
Database and Redis credentials are stored in:
packages/database/.env.{profile}Each file contains:
DATABASE_URL- PostgreSQL connection (pooled)DIRECT_URL- PostgreSQL direct connection (migrations)REDIS_URL- Redis connection string
Development Dashboard
bash
# Start Zellij-based dev dashboard
pnpm env:startThis opens a terminal multiplexer with:
- API server logs
- Worker logs
- Redis monitoring
- File watchers
Running Services
Local Redis
bash
# Start Redis
pnpm dev:redis
# Stop Redis
pnpm dev:redis:stopFull Stack
bash
# Start everything (Redis + all services)
pnpm dev:all
# Stop everything
pnpm dev:all:stopIndividual Services
bash
# Run turbo dev for all packages
pnpm devOr run specific apps via turbo:
bash
turbo run dev --filter=@emp/api
turbo run dev --filter=@emp/monitorMachine Development
For working on the GPU worker machine:
bash
# Start local ComfyUI dev container
pnpm dev:machine
# View logs
pnpm dev:machine:logs
# Stop
pnpm dev:machine:downWorking with Worktrees
For parallel feature development:
bash
# Create a new worktree
pnpm worktree:create
# Setup environment in worktree
pnpm worktree:setupSee CLAUDE.md for tmux orchestration patterns.
Common Workflows
Adding a New Package
- Create directory in
packages/orapps/ - Add
package.jsonwith proper name (@emp/package-name) - Run
pnpm installto link - Add to
turbo.jsonif needed
Updating Dependencies
bash
# Update all packages
pnpm update
# Update specific package
pnpm update lodash --filter @emp/coreCleaning Build Artifacts
bash
# Full clean (removes node_modules too)
pnpm clean
# Just turbo cache
turbo cleanTroubleshooting
Build Failures
bash
# Force rebuild with no cache
pnpm build --force
# Check specific package
turbo run build --filter=@emp/core --forceType Errors
bash
# Run type checking
pnpm typecheck
# Check specific package
turbo run typecheck --filter=@emp/apiRedis Issues
bash
# Check if Redis is running
redis-cli ping
# Restart Redis
pnpm dev:redis:stop && pnpm dev:redis