#!/bin/bash # Claude Code Proxy - Build and Run Script set -e echo "🚀 Claude Code Proxy - Starting Services" echo "=========================================" # Colors for output GREEN='\033[0;32m' BLUE='\033[0;34m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Check if Go is installed if ! command -v go &> /dev/null; then echo "❌ Go is not installed. Please install Go 1.20 or higher." exit 1 fi # Check if Node.js is installed if ! command -v node &> /dev/null; then echo "❌ Node.js is not installed. Please install Node.js 18 or higher." exit 1 fi # Check for .env file if [ ! -f .env ]; then echo -e "${YELLOW}⚠️ No .env file found. Creating from .env.example...${NC}" if [ -f .env.example ]; then cp .env.example .env echo -e "${GREEN}✅ Created .env file.${NC}" else echo "❌ No .env.example file found." exit 1 fi fi # Function to cleanup on exit cleanup() { echo -e "\n${YELLOW}Shutting down services...${NC}" kill $PROXY_PID $SVELTE_PID 2>/dev/null || true exit } trap cleanup EXIT INT TERM # Build and start proxy server echo -e "\n${BLUE}📦 Building proxy server...${NC}" cd proxy go mod download go build -o ../bin/proxy cmd/proxy/main.go cd .. echo -e "${GREEN}✅ Proxy server built${NC}" # Install svelte dependencies if needed if [ ! -d "svelte/node_modules" ]; then echo -e "\n${BLUE}📦 Installing svelte dependencies...${NC}" cd svelte npm install cd .. echo -e "${GREEN}✅ Svelte dependencies installed${NC}" fi # Start proxy server echo -e "\n${BLUE}🚀 Starting proxy server on port 3001...${NC}" ./bin/proxy & PROXY_PID=$! # Wait for proxy to start sleep 2 # Start svelte server echo -e "${BLUE}🚀 Starting Svelte Dashboard on port 5174...${NC}" cd svelte npm run dev & SVELTE_PID=$! cd .. echo -e "\n${GREEN}✨ All services started!${NC}" echo "=========================================" echo -e "📊 Svelte Dashboard: ${BLUE}http://localhost:5174${NC}" echo -e "🔌 API Proxy: ${BLUE}http://localhost:3001${NC}" echo -e "💚 Health Check: ${BLUE}http://localhost:3001/health${NC}" echo "=========================================" echo -e "${YELLOW}Press Ctrl+C to stop all services${NC}\n" # Wait for processes wait