aegisai / setup.sh
setup.sh
Raw
#!/bin/bash
# ============================================================================
# AegisAI Setup Script
# Automates the complete installation process
# ============================================================================

set -e  # Exit on error

echo "๐Ÿ›ก๏ธ  AegisAI Setup Script"
echo "=========================="
echo ""

# Colors
GREEN='\033[0;32m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color

# Check Python
echo "๐Ÿ” Checking Python..."
if ! command -v python3 &> /dev/null; then
    echo -e "${RED}โŒ Python 3 not found. Please install Python 3.9+${NC}"
    exit 1
fi
PYTHON_VERSION=$(python3 --version | cut -d' ' -f2)
echo -e "${GREEN}โœ… Python $PYTHON_VERSION found${NC}"

# Check Node.js
echo "๐Ÿ” Checking Node.js..."
if ! command -v node &> /dev/null; then
    echo -e "${RED}โŒ Node.js not found. Please install Node.js 18+${NC}"
    exit 1
fi
NODE_VERSION=$(node --version)
echo -e "${GREEN}โœ… Node.js $NODE_VERSION found${NC}"

echo ""
echo "๐Ÿ“ฆ Setting up Backend..."
echo "========================"

# Backend setup
cd backend

# Create virtual environment
if [ ! -d "venv" ]; then
    echo "Creating virtual environment..."
    python3 -m venv venv
fi

# Activate virtual environment
echo "Activating virtual environment..."
source venv/bin/activate

# Install dependencies
echo "Installing Python dependencies..."
pip install --upgrade pip
pip install -r requirements.txt

cd ..

echo -e "${GREEN}โœ… Backend setup complete${NC}"

echo ""
echo "๐Ÿ“ฆ Setting up Frontend..."
echo "========================"

# Frontend setup
cd frontend

# Install dependencies
echo "Installing Node.js dependencies..."
npm install

cd ..

echo -e "${GREEN}โœ… Frontend setup complete${NC}"

echo ""
echo "โš™๏ธ  Configuration..."
echo "==================="

# Create .env if it doesn't exist
if [ ! -f ".env" ]; then
    echo "Creating .env file..."
    cp .env.example .env
    echo -e "${BLUE}๐Ÿ“ Please edit .env and add your GEMINI_API_KEY${NC}"
else
    echo -e "${GREEN}โœ… .env file already exists${NC}"
fi

# Create frontend .env.local if it doesn't exist
if [ ! -f "frontend/.env.local" ]; then
    echo "Creating frontend/.env.local..."
    echo "VITE_GEMINI_API_KEY=your_key_here" > frontend/.env.local
    echo -e "${BLUE}๐Ÿ“ Please edit frontend/.env.local and add your GEMINI_API_KEY${NC}"
else
    echo -e "${GREEN}โœ… frontend/.env.local already exists${NC}"
fi

# Create directories
mkdir -p evidence
mkdir -p logs
mkdir -p data

echo ""
echo "โœ… Setup Complete!"
echo "=================="
echo ""
echo "๐Ÿ“‹ Next Steps:"
echo "1. Edit .env and add your GEMINI_API_KEY"
echo "2. Edit frontend/.env.local and add your GEMINI_API_KEY"
echo "3. Run the application:"
echo ""
echo "   Option 1 - Frontend Only:"
echo "   $ cd frontend && npm run dev"
echo ""
echo "   Option 2 - Full Stack:"
echo "   Terminal 1: $ cd backend && source venv/bin/activate && python main.py"
echo "   Terminal 2: $ cd frontend && npm run dev"
echo ""
echo "   Option 3 - Docker:"
echo "   $ docker-compose up"
echo ""
echo "๐ŸŽ‰ Happy Monitoring!"