#!/bin/bash echo "🚀 Setting up PDF Q&A Chatbot System..." # Check if Python is installed if ! command -v python3 &> /dev/null; then echo "❌ Python 3 is required but not installed. Please install Python 3.8+ and try again." exit 1 fi # Check if Node.js is installed if ! command -v node &> /dev/null; then echo "❌ Node.js is required but not installed. Please install Node.js 18+ and try again." exit 1 fi # Check if npm is installed if ! command -v npm &> /dev/null; then echo "❌ npm is required but not installed. Please install npm and try again." exit 1 fi echo "✅ Prerequisites check passed" # Backend setup echo "📦 Setting up backend..." cd backend # Create virtual environment echo "Creating Python virtual environment..." python3 -m venv venv # Activate virtual environment if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then source venv/Scripts/activate else source venv/bin/activate fi # Install dependencies echo "Installing Python dependencies..." pip install -r requirements.txt # Create .env file if it doesn't exist if [ ! -f .env ]; then echo "Creating .env file..." cp .env.example .env echo "⚠️ Please edit backend/.env and add your API keys (OpenAI or Anthropic)" fi cd .. # Frontend setup echo "📦 Setting up frontend..." cd frontend # Install dependencies echo "Installing Node.js dependencies..." npm install # Create .env file if it doesn't exist if [ ! -f .env ]; then echo "Creating .env file..." cp .env.example .env fi cd .. echo "" echo "🎉 Setup completed successfully!" echo "" echo "📋 Next steps:" echo "1. Edit backend/.env and add your API keys:" echo " - OPENAI_API_KEY or ANTHROPIC_API_KEY" echo "" echo "2. Start the backend server:" echo " cd backend" echo " source venv/bin/activate # On Windows: venv\\Scripts\\activate" echo " uvicorn main:app --reload" echo "" echo "3. Start the frontend server (in a new terminal):" echo " cd frontend" echo " npm run dev" echo "" echo "4. Open your browser and go to: http://localhost:3000" echo "" echo "🐳 Alternatively, you can use Docker:" echo " docker-compose up --build" echo "" echo "📚 For more information, see the README.md file"