# After Push Setup Guide After pulling this dev branch, follow these steps to get everything working. ## 🚀 Quick Setup (5 minutes) ### 1. Install Dependencies ```bash npm install ``` ### 2. Setup Database (REQUIRED) The new `activity_status` table is required for the activity feed to work without errors. **Option A: Automatic (Recommended)** ```bash chmod +x prisma/migrations/quick-fix.sh ./prisma/migrations/quick-fix.sh ``` **Option B: Manual** ```bash psql -d portfolio -f prisma/migrations/create_activity_status.sql ``` **Option C: Using pgAdmin/GUI** 1. Open your database tool 2. Connect to `portfolio` database 3. Open the Query Tool 4. Copy contents of `prisma/migrations/create_activity_status.sql` 5. Execute the query ### 3. Verify Setup ```bash # Check if table exists psql -d portfolio -c "\d activity_status" # Should show table structure with columns: # - id, activity_type, activity_details, etc. ``` ### 4. Start Dev Server ```bash npm run dev ``` ### 5. Test Everything Visit these URLs and check for errors: - ✅ http://localhost:3000 - Home page (no hydration errors) - ✅ http://localhost:3000/manage - Admin login form (no redirect) - ✅ http://localhost:3000/api/n8n/status - Should return JSON (not error) **Check Browser Console:** - ❌ No "Hydration failed" errors - ❌ No "two children with same key" warnings - ❌ No "relation activity_status does not exist" errors ## ✨ What's New ### Fixed Issues 1. **Hydration Errors** - React SSR/CSR mismatches resolved 2. **Duplicate Keys** - All list items now have unique keys 3. **Navbar Overlap** - Header no longer covers hero section 4. **Admin Access** - `/manage` now shows login form (no redirect loop) 5. **Database Errors** - Activity feed works without errors ### New Features 1. **AI Image Generation System** - Automatic project cover images 2. **ActivityStatus Model** - Real-time activity tracking in database 3. **Enhanced APIs** - New endpoints for image generation ## 🤖 Optional: AI Image Generation Setup If you want to use the new AI image generation feature: ### Prerequisites - Stable Diffusion WebUI installed - n8n workflow automation - GPU recommended (or cloud GPU) ### Quick Start Guide See detailed instructions: `docs/ai-image-generation/QUICKSTART.md` ### Environment Variables Add to `.env.local`: ```bash # AI Image Generation (Optional) N8N_WEBHOOK_URL=http://localhost:5678/webhook N8N_SECRET_TOKEN=generate-a-secure-random-token SD_API_URL=http://localhost:7860 AUTO_GENERATE_IMAGES=false # Set to true when ready GENERATED_IMAGES_DIR=/path/to/portfolio/public/generated-images ``` Generate secure token: ```bash openssl rand -hex 32 ``` ## 🐛 Troubleshooting ### "relation activity_status does not exist" **Problem:** Database migration not applied **Solution:** ```bash ./prisma/migrations/quick-fix.sh # Then restart: npm run dev ``` ### "/manage redirects to home page" **Problem:** Browser cached old middleware behavior **Solution:** ```bash # Hard refresh: Ctrl+Shift+R (Windows/Linux) or Cmd+Shift+R (Mac) # Or use Incognito/Private window ``` ### Build Errors **Problem:** Dependencies out of sync **Solution:** ```bash rm -rf node_modules package-lock.json npm install npm run build ``` ### Hydration Errors Still Appearing **Problem:** Old build cached **Solution:** ```bash rm -rf .next npm run dev ``` ### Database Connection Failed **Problem:** PostgreSQL not running **Solution:** ```bash # Check status pg_isready # Start PostgreSQL # macOS: brew services start postgresql # Linux: sudo systemctl start postgresql # Docker: docker start postgres_container ``` ## 📚 Documentation ### Core Documentation - `CHANGELOG_DEV.md` - All changes in this release - `PRE_PUSH_CHECKLIST.md` - What was tested before push ### AI Image Generation - `docs/ai-image-generation/README.md` - Overview - `docs/ai-image-generation/SETUP.md` - Detailed setup (486 lines) - `docs/ai-image-generation/QUICKSTART.md` - 15-min setup - `docs/ai-image-generation/PROMPT_TEMPLATES.md` - Prompt engineering - `docs/ai-image-generation/ENVIRONMENT.md` - Environment variables ### Database - `prisma/migrations/README.md` - Migration guide - `prisma/migrations/create_activity_status.sql` - SQL script ## ✅ Verification Checklist After setup, verify: - [ ] `npm run dev` starts without errors - [ ] Home page loads: http://localhost:3000 - [ ] No hydration errors in browser console - [ ] No duplicate key warnings - [ ] Admin page accessible: http://localhost:3000/manage - [ ] Shows login form (not redirect) - [ ] API works: `curl http://localhost:3000/api/n8n/status` - [ ] Returns: `{"activity":null,"music":null,...}` - [ ] Database has `activity_status` table - [ ] Navbar doesn't overlap content ## 🔍 Quick Tests Run these commands to verify everything: ```bash # 1. Build test npm run build # 2. Lint test npm run lint # Should show: 0 errors, 8 warnings (warnings are OK) # 3. API test curl http://localhost:3000/api/n8n/status # Should return JSON, not HTML error page # 4. Database test psql -d portfolio -c "SELECT COUNT(*) FROM activity_status;" # Should return: count = 1 # 5. Page test curl -I http://localhost:3000/manage | grep "HTTP" # Should show: HTTP/1.1 200 OK (not 302/307) ``` ## 🎯 All Working? If all checks pass, you're ready to develop! 🎉 ### What You Can Do Now: 1. ✅ Develop new features without hydration errors 2. ✅ Access admin panel at `/manage` 3. ✅ Activity feed works without database errors 4. ✅ Use AI image generation (if setup complete) ### Need Help? - Check `CHANGELOG_DEV.md` for detailed changes - Review `docs/ai-image-generation/` for AI features - Check `prisma/migrations/README.md` for database issues ## 🚦 Next Steps 1. **Review Changes**: Read `CHANGELOG_DEV.md` 2. **Test Features**: Try the admin panel, create projects 3. **Optional AI Setup**: Follow `docs/ai-image-generation/QUICKSTART.md` 4. **Report Issues**: Document any problems found --- **Setup Time**: ~5 minutes **Status**: Ready to develop **Questions?**: Check documentation or create an issue