Files
2025-12-12 14:47:36 +01:00

88 lines
2.3 KiB
Bash
Executable File

#!/bin/bash
# Stock Analyzer - Quick Start Script
set -e
echo "🚀 Stock Analyzer - Quick Start"
echo "================================"
echo ""
# Check if .env file exists
if [ ! -f .env ]; then
echo "⚠️ No .env file found. Creating from env.example..."
if [ -f env.example ]; then
cp env.example .env
echo "✅ Created .env file. Please edit it with your API keys."
echo ""
echo "Required API keys:"
echo " - OPENAI_API_KEY"
echo " - ANTHROPIC_API_KEY"
echo " - NEWS_API_KEY"
echo ""
read -p "Press Enter after you've configured your API keys..."
else
echo "❌ env.example not found. Please create a .env file manually."
exit 1
fi
fi
# Load environment variables
export $(cat .env | grep -v '^#' | xargs)
echo "1️⃣ Starting MongoDB..."
docker run -d -p 27017:27017 --name stock-analyzer-mongodb mongo:latest 2>/dev/null || docker start stock-analyzer-mongodb
echo "✅ MongoDB started"
echo ""
echo "2️⃣ Starting Backend (Spring Boot)..."
cd backend
./gradlew bootRun &
BACKEND_PID=$!
cd ..
echo "✅ Backend starting on http://localhost:8080"
echo ""
# Wait for backend to be ready
echo "⏳ Waiting for backend to be ready..."
for i in {1..30}; do
if curl -s http://localhost:8080/actuator/health > /dev/null 2>&1; then
echo "✅ Backend is ready!"
break
fi
sleep 2
done
echo ""
echo "3️⃣ Installing Frontend Dependencies..."
cd frontend
if [ ! -d "node_modules" ]; then
npm install
fi
echo "✅ Dependencies installed"
echo ""
echo "4️⃣ Starting Frontend (Vue.js)..."
npm run dev &
FRONTEND_PID=$!
cd ..
echo "✅ Frontend starting on http://localhost:5173"
echo ""
echo "================================"
echo "✨ Stock Analyzer is running!"
echo "================================"
echo ""
echo "📊 Frontend: http://localhost:5173"
echo "🔧 Backend: http://localhost:8080"
echo "🗄️ MongoDB: mongodb://localhost:27017"
echo ""
echo "Press Ctrl+C to stop all services"
echo ""
# Trap Ctrl+C and cleanup
trap "echo ''; echo '🛑 Stopping services...'; kill $BACKEND_PID $FRONTEND_PID 2>/dev/null; docker stop stock-analyzer-mongodb 2>/dev/null; echo '✅ All services stopped'; exit 0" INT
# Wait for processes
wait