4.3 KiB
4.3 KiB
Development Scripts
This directory contains scripts to help manage your development environment for the Customer Portal project.
Quick Start
Single command to start everything:
pnpm start:all
# or
pnpm dev:start
# or
./scripts/dev.sh
This will:
- ✅ Check if Docker is running
- 🔍 Check if services are already running (skips if already up)
- 🐳 Start PostgreSQL and Redis containers (if needed)
- ⏳ Wait for databases to be ready
- 🗄️ Start Prisma Studio (available at http://localhost:5555)
- 🚀 Start both frontend and backend in development mode
Available Commands
Package.json Scripts (Recommended)
# Start everything (Docker + Databases + Frontend + Backend)
pnpm start:all # Enhanced Node.js script with pretty output
pnpm start:simple # Simple version using basic commands
# Individual service management
pnpm start:services # Start only Docker services (PostgreSQL + Redis)
pnpm stop:services # Stop Docker services
pnpm restart:services # Restart Docker services
# Complete environment management
pnpm restart:all # Stop everything and restart
pnpm dev:restart # Same as above using bash script
# Monitoring and debugging
pnpm logs # Show Docker service logs
pnpm status # Show Docker service status
pnpm dev:logs # Show logs using bash script
pnpm dev:status # Show status using bash script
# Database management
pnpm db:migrate # Run database migrations
pnpm db:studio # Open Prisma Studio
pnpm db:reset # Reset database (careful!)
Direct Script Usage
# Using the bash script directly
./scripts/dev.sh start # Start everything
./scripts/dev.sh stop # Stop everything
./scripts/dev.sh restart # Restart everything
./scripts/dev.sh logs # Show logs
./scripts/dev.sh status # Show status
# Using the Node.js script directly
node scripts/dev-start.js
What Gets Started
When you run pnpm start:all, the following services start:
-
PostgreSQL Database (port 5432)
- Container:
portal-postgres - Database:
portal - User:
app/ Password:app
- Container:
-
Redis Cache (port 6379)
- Container:
portal-redis
- Container:
-
Backend (BFF) (port 4000)
- NestJS application with hot reload
- API available at
http://localhost:4000
-
Frontend (port 3000)
- Next.js application with Turbopack
- App available at
http://localhost:3000
-
Prisma Studio (port 5555)
- Database management interface
- Available at
http://localhost:5555
Stopping Everything
# Stop everything
pnpm stop:services
# Or use the bash script
./scripts/dev.sh stop
# Or use Ctrl+C to stop the development servers
# (Docker services will keep running)
Troubleshooting
Docker Issues
- "Docker is not running": Start Docker Desktop or Docker daemon
- Port conflicts: Check if ports 3000, 4000, 5432, or 6379 are in use
Database Issues
- Connection refused: Wait a moment for PostgreSQL to fully start
- Migration errors: Run
pnpm db:resetto reset the database
Development Server Issues
- Port 3000/4000 in use: Kill existing processes or change ports
- Module not found: Run
pnpm installto install dependencies
General Issues
- Run
pnpm dev:statusto check service health - Run
pnpm dev:logsto see service logs - Try
pnpm dev:restartfor a fresh start
Features
- 🚀 One command startup: Everything starts with a single command
- 🔍 Smart detection: Checks if services are already running to avoid conflicts
- ⏳ Smart waiting: Scripts wait for databases to be ready before starting apps
- 📋 Clear service URLs: Shows all running service URLs for easy access
- 🎨 Pretty output: Colored, organized logging with emojis
- 🔄 Easy restart: Quick restart commands for development iteration
- 🐳 Docker health checks: Ensures services are actually ready, not just started
- 💻 Cross-platform: Works on Linux, macOS, and Windows (WSL)
Tips
- Use
pnpm start:allfor daily development - Use
pnpm dev:restartwhen you need a fresh environment - Use
pnpm dev:logsto debug service issues - Keep Docker running to avoid startup delays
- The scripts automatically handle graceful shutdowns with Ctrl+C