ClassLens / chatkit /run-local.sh
chih.yikuan
email-done
5ee5085
#!/bin/bash
# Run ClassLens locally (both backend and frontend)
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
echo "πŸš€ Starting ClassLens locally..."
echo ""
# Check for .env file
if [ ! -f "../.env" ]; then
echo "⚠️ No .env file found. Please create one from env.example"
exit 1
fi
# Function to cleanup on exit
cleanup() {
echo ""
echo "πŸ›‘ Stopping servers..."
pkill -f "uvicorn app.main" 2>/dev/null || true
pkill -f "vite" 2>/dev/null || true
exit 0
}
trap cleanup SIGINT SIGTERM
# Start backend
echo "πŸ“¦ Starting backend on http://127.0.0.1:8000"
cd backend
if [ ! -d ".venv" ]; then
echo "Creating Python virtual environment..."
python3 -m venv .venv
fi
source .venv/bin/activate
pip install -q -e . > /dev/null 2>&1
# Load environment variables
export $(grep -v '^#' ../.env | xargs)
# Start backend in background
uvicorn app.main:app --host 127.0.0.1 --port 8000 --reload > /tmp/classlens-backend.log 2>&1 &
BACKEND_PID=$!
# Wait a bit for backend to start
sleep 2
# Start frontend
echo "🎨 Starting frontend on http://localhost:3000"
cd ../frontend
# Install frontend dependencies if needed
if [ ! -d "node_modules" ]; then
echo "Installing frontend dependencies..."
npm install
fi
# Start frontend
npm run dev > /tmp/classlens-frontend.log 2>&1 &
FRONTEND_PID=$!
echo ""
echo "βœ… ClassLens is running!"
echo ""
echo " Backend: http://127.0.0.1:8000"
echo " Frontend: http://localhost:3000"
echo ""
echo " Backend logs: tail -f /tmp/classlens-backend.log"
echo " Frontend logs: tail -f /tmp/classlens-frontend.log"
echo ""
echo "Press Ctrl+C to stop both servers"
echo ""
# Wait for both processes
wait $BACKEND_PID $FRONTEND_PID