#!/bin/bash # myFidelityTracker Start Script (Linux) echo "🚀 Starting myFidelityTracker..." echo "" # Check if Docker is running if ! docker info > /dev/null 2>&1; then echo "❌ Docker is not running. Please start Docker and try again." echo " On Linux: sudo systemctl start docker" exit 1 fi # Check if docker compose is available (V2 or V1) if docker compose version &> /dev/null; then DOCKER_COMPOSE="docker compose" elif command -v docker-compose &> /dev/null; then DOCKER_COMPOSE="docker-compose" else echo "❌ Docker Compose not found. Please install it:" echo " sudo apt-get install docker-compose-plugin # Debian/Ubuntu" echo " sudo yum install docker-compose-plugin # CentOS/RHEL" exit 1 fi echo "📦 Using: $DOCKER_COMPOSE" # Check if .env exists, if not copy from example if [ ! -f .env ]; then echo "📝 Creating .env file from .env.example..." cp .env.example .env fi # Create imports directory if it doesn't exist mkdir -p imports # Copy sample CSV if it exists in the root if [ -f "History_for_Account_X38661988.csv" ] && [ ! -f "imports/History_for_Account_X38661988.csv" ]; then echo "📋 Copying sample CSV to imports directory..." cp History_for_Account_X38661988.csv imports/ fi # Start services echo "🐳 Starting Docker containers..." $DOCKER_COMPOSE up -d # Wait for services to be healthy echo "" echo "⏳ Waiting for services to be ready..." sleep 5 # Check if backend is up echo "🔍 Checking backend health..." for i in {1..30}; do if curl -s http://localhost:8000/health > /dev/null 2>&1; then echo "✅ Backend is ready!" break fi if [ $i -eq 30 ]; then echo "⚠️ Backend is taking longer than expected to start" echo " Check logs with: docker compose logs backend" fi sleep 2 done # Check if frontend is up echo "🔍 Checking frontend..." for i in {1..20}; do if curl -s http://localhost:3000 > /dev/null 2>&1; then echo "✅ Frontend is ready!" break fi if [ $i -eq 20 ]; then echo "⚠️ Frontend is taking longer than expected to start" echo " Check logs with: docker compose logs frontend" fi sleep 2 done # Get server IP SERVER_IP=$(hostname -I | awk '{print $1}') echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "✨ myFidelityTracker is running!" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" echo "🌐 Access from this server:" echo " Frontend: http://localhost:3000" echo " Backend: http://localhost:8000" echo " API Docs: http://localhost:8000/docs" echo "" echo "🌐 Access from other computers:" echo " Frontend: http://${SERVER_IP}:3000" echo " Backend: http://${SERVER_IP}:8000" echo " API Docs: http://${SERVER_IP}:8000/docs" echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" echo "" echo "📖 Quick Start Guide:" echo " 1. Open http://${SERVER_IP}:3000 in your browser" echo " 2. Go to the 'Accounts' tab to create your first account" echo " 3. Go to the 'Import' tab to upload a Fidelity CSV file" echo " 4. View your dashboard with performance metrics" echo "" echo "🌱 To seed demo data (optional):" echo " docker compose exec backend python seed_demo_data.py" echo "" echo "📊 To view logs:" echo " docker compose logs -f" echo "" echo "🛑 To stop:" echo " ./stop.sh or docker compose down" echo ""