#!/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!"