-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev
More file actions
executable file
·82 lines (65 loc) · 1.94 KB
/
dev
File metadata and controls
executable file
·82 lines (65 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
set -euo pipefail
# Local development launcher for Study Palette
# Starts the FastAPI backend and Vite React frontend with hot reload.
# Ctrl+C stops both.
ROOT="$(cd "$(dirname "$0")" && pwd)"
API_PORT="${API_PORT:-8000}"
UI_PORT="${UI_PORT:-3000}"
RED='\033[0;31m'
BLUE='\033[0;34m'
GREEN='\033[0;32m'
DIM='\033[2m'
RESET='\033[0m'
cleanup() {
echo ""
echo -e "${DIM}Shutting down...${RESET}"
kill 0 2>/dev/null
wait 2>/dev/null
}
trap cleanup EXIT
# --- Check prerequisites ---
check_cmd() {
if ! command -v "$1" &>/dev/null; then
echo -e "${RED}Missing: $1${RESET}"
echo " $2"
exit 1
fi
}
check_cmd python3 "Install Python 3.11+ (mise install python)"
check_cmd uv "Install uv (mise install uv)"
check_cmd bun "Install bun (mise install bun)"
# --- Python backend setup ---
VENV_DIR="$ROOT/.venv"
if [[ ! -d "$VENV_DIR" ]]; then
echo -e "${BLUE}[api]${RESET} Setting up Python environment..."
uv sync --project "$ROOT"
fi
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
PYTHON="$VIRTUAL_ENV/bin/python"
elif [[ -f "$VENV_DIR/bin/python" ]]; then
PYTHON="$VENV_DIR/bin/python"
else
echo -e "${RED}No Python venv found. Run 'activate' or 'uv sync' first.${RESET}"
exit 1
fi
# --- UI setup ---
if [[ ! -d "$ROOT/ui/node_modules" ]]; then
echo -e "${BLUE}[ui]${RESET} Installing frontend dependencies..."
cd "$ROOT/ui"
bun install
cd - >/dev/null
fi
# --- Launch ---
echo -e "${GREEN}Starting Study Palette${RESET}"
echo -e " ${BLUE}API${RESET} → http://localhost:${API_PORT}"
echo -e " ${BLUE}UI${RESET} → http://localhost:${UI_PORT}"
echo -e " ${DIM}Ctrl+C to stop${RESET}"
echo ""
# Start API
(cd "$ROOT" && "$PYTHON" -m uvicorn api.main:app --reload --port "$API_PORT" 2>&1 \
| sed "s/^/$(printf "${BLUE}[api]${RESET} ")/") &
# Start UI
(cd "$ROOT/ui" && bun run dev --port "$UI_PORT" 2>&1 \
| sed "s/^/$(printf "${GREEN}[ui]${RESET} ")/") &
wait