RTSDA-Website/astro-church-website/DEPLOYMENT.md
Benjamin Slingo f91f696334 Convert admin panel to Astro routes and remove thumbnail field
Major architecture cleanup following CLAUDE.md rules:

## Admin Panel Conversion (1843 lines → TypeScript routes)
- Remove public/admin/scripts/main.js (direct API calls violation)
- Add proper Astro admin routes with TypeScript API endpoints
- Add missing admin functions in church-core Rust crate
- Update bindings.js to expose new admin functions

## Thumbnail Field Removal
- Remove thumbnail upload section from event submission form
- Clean up thumbnail-related JavaScript code

## Architecture Compliance Achieved
 Frontend → bindings.js → Rust FFI → church-core → API
 Frontend → fetch() → External API (eliminated)

Files: +13 admin routes, -1843 line JS file, enhanced Rust core
2025-08-28 21:58:49 -04:00

3 KiB

Deployment Instructions

Files to Copy to Server

New/Modified Files:

src/pages/admin/index.astro          # Main admin dashboard page
src/components/admin/Login.astro     # Admin login component  
src/pages/bulletin/[id].astro        # Fixed bulletin detail page (SSR)
src/pages/admin/                     # New Astro admin routes (TypeScript)

Verify these files exist on server:

src/pages/admin/                     # New admin routes using Rust bindings

Deployment Steps

  1. Copy files to server:

    # Copy new admin components
    scp -r src/pages/admin/ user@server:/opt/rtsda/src/pages/
    scp -r src/components/admin/ user@server:/opt/rtsda/src/components/
    
    # Copy fixed bulletin page
    scp src/pages/bulletin/[id].astro user@server:/opt/rtsda/src/pages/bulletin/
    
    # Copy new admin API routes
    scp -r src/pages/admin/api/ user@server:/opt/rtsda/src/pages/admin/
    
  2. SSH into server:

    ssh user@server
    cd /opt/rtsda
    
  3. Build and restart:

    npm run build
    pm2 restart astro-app
    

Testing After Deployment

  1. Test bulletin fix:

    • Visit: https://yourdomain.com/bulletin/5bebfe94-71ca-4a72-b9a8-ecd1195c8182
    • Should show bulletin content, not "bulletin not found"
  2. Test admin dashboard:

    • Visit: https://yourdomain.com/admin/
    • Should show login screen
    • Login with admin credentials
    • Verify all sections work: Events, Bulletins, Schedules

Potential Issues & Solutions

Build Errors:

# If node version issues:
node --version  # Should be 20.x
npm --version

# If dependency issues:
rm -rf node_modules package-lock.json
npm install
npm run build

Permission Issues:

# Fix ownership
sudo chown -R $USER:$USER /opt/rtsda
chmod -R 755 /opt/rtsda

# Fix specific file permissions
chmod 644 src/pages/admin/index.astro
chmod 644 src/components/admin/Login.astro
chmod 644 src/pages/bulletin/[id].astro

Admin Route Not Working:

  • Check if /admin/ route is accessible
  • Verify admin files were copied correctly
  • Check PM2 logs: pm2 logs astro-app

Styles Not Loading:

  • Hard refresh browser (Ctrl+F5)
  • Check if build completed successfully
  • Verify no CSS compilation errors in build output

Rollback Plan

If something breaks:

# Quick rollback
git status
git checkout -- src/pages/bulletin/[id].astro
rm -rf src/pages/admin/
rm -rf src/components/admin/
npm run build
pm2 restart astro-app

Success Indicators

Build completes without errors
Bulletin pages show content instead of "not found"
/admin/ shows login screen
Admin dashboard fully functional after login
Site loads normally for regular visitors

Notes

  • Admin dashboard is completely hidden from public navigation
  • Only accessible via direct URL: /admin/
  • Requires valid JWT authentication
  • All original functionality preserved
  • Styling matches main site theme

"It should be simple, but it probably won't be." - Murphy's Law of Deployment