diff --git a/docs/KOHA_PRODUCTION_DEPLOYMENT.md b/docs/KOHA_PRODUCTION_DEPLOYMENT.md new file mode 100644 index 00000000..d4e63abd --- /dev/null +++ b/docs/KOHA_PRODUCTION_DEPLOYMENT.md @@ -0,0 +1,540 @@ +# Koha Production Deployment Guide +## Deploy Without Live Stripe Integration + +**Date:** 2025-10-08 +**Status:** Pre-Stripe Deployment +**Goal:** Deploy all Koha infrastructure to production, but keep user-facing UI disabled until Stripe is configured + +--- + +## Overview + +This guide walks through deploying the Koha donation system to production in a "staging" mode - all code deployed, database initialized, but public access disabled until Stripe keys are configured. + +**Why Deploy Now:** +- Test production infrastructure before Stripe integration +- Verify database setup and migrations +- Ensure backend API works in production environment +- Frontend code ready for immediate activation when Stripe is configured + +**What's NOT Active:** +- Public navigation links to Koha pages +- Stripe payment processing +- Live donation functionality + +--- + +## Phase 1: Database Initialization + +### 1.1 SSH into Production Server + +```bash +ssh -i /home/theflow/.ssh/tractatus_deploy ubuntu@vps-93a693da.vps.ovh.net +``` + +### 1.2 Navigate to Project Directory + +```bash +cd /var/www/tractatus +``` + +### 1.3 Run Koha Database Initialization + +```bash +node scripts/init-koha.js +``` + +**Expected Output:** +``` +[KOHA] Initializing database... +✓ Collection 'koha_donations' exists +✓ Created index on status +✓ Created index on frequency +✓ Created index on stripe.subscription_id +✓ Created index on stripe.payment_intent_id +✓ Created index on donor.email +✓ Created index on created_at +✓ Created index on public_acknowledgement +[KOHA] Database initialization complete +``` + +### 1.4 Verify Collection Created + +```bash +mongosh tractatus_prod --eval "db.koha_donations.getIndexes()" +``` + +**Expected:** 10 indexes (7 custom + 3 default) + +--- + +## Phase 2: Environment Configuration + +### 2.1 Update Production .env + +Edit `/var/www/tractatus/.env` and add: + +```bash +# Koha Donation System (Placeholder - not active) +STRIPE_SECRET_KEY=sk_test_PLACEHOLDER_REPLACE_NEXT_WEEK +STRIPE_PUBLISHABLE_KEY=pk_test_PLACEHOLDER_REPLACE_NEXT_WEEK +STRIPE_KOHA_WEBHOOK_SECRET=whsec_PLACEHOLDER_REPLACE_NEXT_WEEK +STRIPE_KOHA_5_PRICE_ID=price_PLACEHOLDER_REPLACE_NEXT_WEEK +STRIPE_KOHA_15_PRICE_ID=price_PLACEHOLDER_REPLACE_NEXT_WEEK +STRIPE_KOHA_50_PRICE_ID=price_PLACEHOLDER_REPLACE_NEXT_WEEK + +# Frontend URL +FRONTEND_URL=https://agenticgovernance.digital +``` + +**Note:** These placeholder values will prevent Stripe operations from executing but allow the code to load. + +### 2.2 Verify Environment Variables + +```bash +grep STRIPE /var/www/tractatus/.env +``` + +--- + +## Phase 3: Deploy Code + +### 3.1 From Local Machine, rsync New Files + +```bash +# Deploy backend files +rsync -avz -e "ssh -i /home/theflow/.ssh/tractatus_deploy" \ + /home/theflow/projects/tractatus/src/config/currencies.config.js \ + /home/theflow/projects/tractatus/src/services/koha.service.js \ + /home/theflow/projects/tractatus/src/controllers/koha.controller.js \ + /home/theflow/projects/tractatus/src/models/Donation.model.js \ + /home/theflow/projects/tractatus/src/routes/koha.routes.js \ + ubuntu@vps-93a693da.vps.ovh.net:/var/www/tractatus/src/ + +# Deploy frontend files +rsync -avz -e "ssh -i /home/theflow/.ssh/tractatus_deploy" \ + /home/theflow/projects/tractatus/public/koha.html \ + /home/theflow/projects/tractatus/public/privacy.html \ + ubuntu@vps-93a693da.vps.ovh.net:/var/www/tractatus/public/ + +rsync -avz -e "ssh -i /home/theflow/.ssh/tractatus_deploy" \ + /home/theflow/projects/tractatus/public/koha/ \ + ubuntu@vps-93a693da.vps.ovh.net:/var/www/tractatus/public/koha/ + +rsync -avz -e "ssh -i /home/theflow/.ssh/tractatus_deploy" \ + /home/theflow/projects/tractatus/public/js/utils/currency.js \ + /home/theflow/projects/tractatus/public/js/components/currency-selector.js \ + /home/theflow/projects/tractatus/public/js/components/footer.js \ + ubuntu@vps-93a693da.vps.ovh.net:/var/www/tractatus/public/js/ + +# Deploy scripts +rsync -avz -e "ssh -i /home/theflow/.ssh/tractatus_deploy" \ + /home/theflow/projects/tractatus/scripts/init-koha.js \ + ubuntu@vps-93a693da.vps.ovh.net:/var/www/tractatus/scripts/ +``` + +### 3.2 Verify Files Deployed + +SSH into production and check: + +```bash +ssh -i /home/theflow/.ssh/tractatus_deploy ubuntu@vps-93a693da.vps.ovh.net \ + "ls -la /var/www/tractatus/src/config/currencies.config.js && \ + ls -la /var/www/tractatus/public/koha.html && \ + ls -la /var/www/tractatus/public/privacy.html" +``` + +--- + +## Phase 4: Add "Coming Soon" Overlay + +### 4.1 Create Coming Soon Overlay Component + +Create `/var/www/tractatus/public/js/components/coming-soon-overlay.js`: + +```javascript +/** + * Coming Soon Overlay + * Displays over Koha pages until Stripe is configured + */ + +(function() { + 'use strict'; + + // Check if we should show the overlay + const shouldShowOverlay = () => { + // Only show on Koha pages + const isKohaPage = window.location.pathname.includes('/koha'); + return isKohaPage; + }; + + // Create and inject overlay + if (shouldShowOverlay()) { + const overlayHTML = ` +
+ Coming Soon +
++ What is Koha? +
++ Koha (Māori for "gift") is our upcoming donation system to support the Tractatus Framework. + We're currently finalizing payment processing integration and will launch soon. +
++ Infrastructure deployed and ready. Payment processing activation in progress. +
+ + Return to Homepage + ++ Questions? Contact support@agenticgovernance.digital +
+