#!/bin/bash # Smart Parking Finder - Development Start Script echo "πŸš— Starting Smart Parking Finder Development Environment..." # Function to check if a command exists command_exists() { command -v "$1" >/dev/null 2>&1 } # Check required tools echo "Checking required tools..." if ! command_exists node; then echo "❌ Node.js is not installed. Please install Node.js first." exit 1 fi if ! command_exists npm; then echo "❌ npm is not installed. Please install npm first." exit 1 fi if ! command_exists docker; then echo "❌ Docker is not installed. Please install Docker first." exit 1 fi # Check if Docker is running if ! docker info >/dev/null 2>&1; then echo "❌ Docker is not running. Please start Docker and try again." exit 1 fi echo "βœ… All required tools are available" # Start infrastructure services (PostgreSQL, Redis, Valhalla) echo "🐳 Starting infrastructure services..." docker-compose up -d postgres redis valhalla # Wait for services to be ready echo "⏳ Waiting for services to be ready..." sleep 10 # Check if services are running if docker-compose ps | grep -q "Up"; then echo "βœ… Infrastructure services are running" else echo "❌ Failed to start infrastructure services" docker-compose logs exit 1 fi # Start backend in background echo "πŸ”§ Starting backend server..." cd backend npm run start:dev & BACKEND_PID=$! cd .. # Wait a bit for backend to start sleep 5 # Start frontend echo "🌐 Starting frontend server..." cd frontend npm run dev & FRONTEND_PID=$! cd .. echo "" echo "πŸŽ‰ Smart Parking Finder is starting up!" echo "" echo "πŸ“‘ Backend API: http://localhost:3001" echo " - Swagger API docs: http://localhost:3001/api" echo " - Health check: http://localhost:3001/health" echo "" echo "🌐 Frontend App: http://localhost:3000" echo "" echo "πŸ—„οΈ Database: PostgreSQL on localhost:5432" echo " - PgAdmin: http://localhost:5050 (admin@admin.com / admin)" echo "" echo "⚑ Redis: localhost:6379" echo " - Redis Commander: http://localhost:8081" echo "" echo "πŸ—ΊοΈ Valhalla Routing: http://localhost:8002" echo "" echo "Press Ctrl+C to stop all services" # Function to cleanup on exit cleanup() { echo "" echo "πŸ›‘ Stopping all services..." kill $BACKEND_PID 2>/dev/null kill $FRONTEND_PID 2>/dev/null docker-compose down echo "βœ… All services stopped" exit 0 } # Set trap to cleanup on script exit trap cleanup SIGINT SIGTERM # Keep script running wait