From e732256cbf40301992963843c3ddfede679e250f Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Thu, 15 Jan 2026 19:38:44 -0700 Subject: [PATCH] Stuff --- .env.example | 8 ++++++++ scripts/setup-prod.sh | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 343f7c2..48dbc56 100644 --- a/.env.example +++ b/.env.example @@ -42,3 +42,11 @@ AUTHENTIK_BOOTSTRAP_TOKEN= # OPTIONAL - Logging # ============================================================================== LOG_REQUESTS=false + +# ============================================================================== +# OPTIONAL - System AI (Gemini API Key for quiz generation) +# If set, users can generate quizzes without providing their own API key. +# Get a key at: https://aistudio.google.com/apikey +# WARNING: This key is embedded in the frontend and visible to users. +# ============================================================================== +VITE_API_KEY= diff --git a/scripts/setup-prod.sh b/scripts/setup-prod.sh index 00b08d6..b70228f 100755 --- a/scripts/setup-prod.sh +++ b/scripts/setup-prod.sh @@ -36,6 +36,7 @@ print_header KABOOT_DOMAIN="" AUTH_DOMAIN="" +GEMINI_API_KEY="" while [[ $# -gt 0 ]]; do case $1 in @@ -47,12 +48,17 @@ while [[ $# -gt 0 ]]; do AUTH_DOMAIN="$2" shift 2 ;; + --gemini-key) + GEMINI_API_KEY="$2" + shift 2 + ;; --help|-h) echo "Usage: $0 [OPTIONS]" echo "" echo "Options:" echo " --domain DOMAIN Main application domain (e.g., kaboot.example.com)" echo " --auth-domain DOMAIN Authentication domain (e.g., auth.example.com)" + echo " --gemini-key KEY Gemini API key for system AI (optional)" echo " --help, -h Show this help message" echo "" echo "If options are not provided, you will be prompted for them." @@ -98,6 +104,18 @@ if [ -z "$AUTH_DOMAIN" ]; then AUTH_DOMAIN=${AUTH_DOMAIN:-$DEFAULT_AUTH} fi +echo "" +echo -e "${BOLD}System AI Configuration (Optional)${NC}" +echo "────────────────────────────────────────────────────────────" +echo "You can provide a Gemini API key to enable AI quiz generation" +echo "for all users without requiring them to set up their own key." +echo -e "${YELLOW}Note: This key will be embedded in the frontend and visible to users.${NC}" +echo "" + +if [ -z "$GEMINI_API_KEY" ]; then + read -p "Enter Gemini API key (or press Enter to skip): " GEMINI_API_KEY +fi + echo "" print_step "Generating secrets..." @@ -137,6 +155,9 @@ OIDC_JWKS_URI=https://${AUTH_DOMAIN}/application/o/kaboot/jwks/ CORS_ORIGIN=https://${KABOOT_DOMAIN} NODE_ENV=production LOG_REQUESTS=true + +# System AI (optional - for quiz generation without user's own key) +VITE_API_KEY=${GEMINI_API_KEY} EOF print_success "Created .env" @@ -195,9 +216,16 @@ fi print_step "Building frontend with production URLs..." -VITE_API_URL="https://${KABOOT_DOMAIN}/api" \ -VITE_AUTHENTIK_URL="https://${AUTH_DOMAIN}" \ -npm run build --silent 2>/dev/null || npm run build +BUILD_ENV="VITE_API_URL=https://${KABOOT_DOMAIN} VITE_AUTHENTIK_URL=https://${AUTH_DOMAIN} VITE_OIDC_CLIENT_ID=kaboot-spa VITE_OIDC_APP_SLUG=kaboot" + +if [ -n "$GEMINI_API_KEY" ]; then + BUILD_ENV="$BUILD_ENV VITE_API_KEY=$GEMINI_API_KEY" + print_success "System AI enabled with provided Gemini key" +else + print_warning "No Gemini API key provided - users must configure their own" +fi + +eval "$BUILD_ENV npm run build --silent 2>/dev/null || $BUILD_ENV npm run build" print_success "Frontend built" @@ -210,6 +238,11 @@ echo -e "${BOLD}Configuration Summary${NC}" echo "────────────────────────────────────────────────────────────" echo -e " Main Domain: ${BLUE}https://${KABOOT_DOMAIN}${NC}" echo -e " Auth Domain: ${BLUE}https://${AUTH_DOMAIN}${NC}" +if [ -n "$GEMINI_API_KEY" ]; then + echo -e " System AI: ${GREEN}Enabled${NC}" +else + echo -e " System AI: ${YELLOW}Disabled (users need own API key)${NC}" +fi echo "" echo -e "${BOLD}Authentik Admin${NC}" echo "────────────────────────────────────────────────────────────"