|
| 1 | +# π Netlify Deployment Guide for CODEEX AI |
| 2 | + |
| 3 | +Complete guide to deploy CODEEX AI to Netlify with all features working. |
| 4 | + |
| 5 | +## π Prerequisites |
| 6 | + |
| 7 | +- GitHub repository with CODEEX AI code |
| 8 | +- Netlify account (free tier works) |
| 9 | +- API keys for AI providers (all free) |
| 10 | + |
| 11 | +## π Required Environment Variables |
| 12 | + |
| 13 | +Set these in Netlify Dashboard β Site Settings β Environment Variables: |
| 14 | + |
| 15 | +### AI Provider Keys (Required) |
| 16 | +```bash |
| 17 | +# Groq (Fast inference - 14,400 req/day) |
| 18 | +GROQ_API_KEY=your_groq_api_key_here |
| 19 | + |
| 20 | +# Hugging Face (Router API - FREE) |
| 21 | +HUGGINGFACE_API_KEY=your_huggingface_api_key_here |
| 22 | + |
| 23 | +# Google Gemini (FREE - 15 req/min, 1500 req/day) |
| 24 | +GOOGLE_API_KEY=your_google_api_key_here |
| 25 | +``` |
| 26 | + |
| 27 | +### Firebase Configuration (Required) |
| 28 | +```bash |
| 29 | +NEXT_PUBLIC_FIREBASE_API_KEY=your_firebase_api_key |
| 30 | +NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com |
| 31 | +NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id |
| 32 | +NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.appspot.com |
| 33 | +NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id |
| 34 | +NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id |
| 35 | +``` |
| 36 | + |
| 37 | +### Build Configuration (Required) |
| 38 | +```bash |
| 39 | +NODE_VERSION=20 |
| 40 | +NPM_FLAGS=--legacy-peer-deps |
| 41 | +NEXT_TELEMETRY_DISABLED=1 |
| 42 | +SKIP_ENV_VALIDATION=true |
| 43 | +``` |
| 44 | + |
| 45 | +### Optional Variables |
| 46 | +```bash |
| 47 | +NEXT_PUBLIC_APP_URL=https://your-site.netlify.app |
| 48 | +NEXT_PUBLIC_EMAILJS_SERVICE_ID=your_emailjs_service |
| 49 | +NEXT_PUBLIC_EMAILJS_TEMPLATE_ID=your_template_id |
| 50 | +NEXT_PUBLIC_EMAILJS_USER_ID=your_user_id |
| 51 | +``` |
| 52 | + |
| 53 | +## π Deployment Steps |
| 54 | + |
| 55 | +### 1. Connect Repository |
| 56 | +1. Go to [Netlify Dashboard](https://app.netlify.com) |
| 57 | +2. Click "New site from Git" |
| 58 | +3. Connect your GitHub account |
| 59 | +4. Select the CODEEX AI repository |
| 60 | + |
| 61 | +### 2. Configure Build Settings |
| 62 | +- **Build command**: `npm run build:netlify` |
| 63 | +- **Publish directory**: `.next` |
| 64 | +- **Node version**: `20` |
| 65 | + |
| 66 | +### 3. Set Environment Variables |
| 67 | +1. Go to Site Settings β Environment Variables |
| 68 | +2. Add all required variables listed above |
| 69 | +3. Save changes |
| 70 | + |
| 71 | +### 4. Deploy |
| 72 | +1. Click "Deploy site" |
| 73 | +2. Wait for build to complete (5-10 minutes) |
| 74 | +3. Site will be available at `https://your-site-name.netlify.app` |
| 75 | + |
| 76 | +## β
Verification |
| 77 | + |
| 78 | +After deployment, verify everything works: |
| 79 | + |
| 80 | +### Automatic Verification |
| 81 | +```bash |
| 82 | +npm run verify:deployment |
| 83 | +``` |
| 84 | + |
| 85 | +### Manual Verification |
| 86 | +1. **Health Check**: Visit `/api/health` |
| 87 | +2. **Main App**: Visit `/` |
| 88 | +3. **Chat Interface**: Visit `/chat` |
| 89 | +4. **Documentation**: Visit `/documentation` |
| 90 | + |
| 91 | +## π§ Build Optimization |
| 92 | + |
| 93 | +The app includes several Netlify optimizations: |
| 94 | + |
| 95 | +### Next.js Configuration |
| 96 | +- PWA support with service worker |
| 97 | +- Image optimization |
| 98 | +- Compression enabled |
| 99 | +- TypeScript/ESLint error handling |
| 100 | + |
| 101 | +### Netlify Configuration |
| 102 | +- Next.js plugin for optimal performance |
| 103 | +- Security headers |
| 104 | +- Caching strategies |
| 105 | +- API route optimization |
| 106 | + |
| 107 | +### Build Process |
| 108 | +- Custom build script with error handling |
| 109 | +- Dependency optimization |
| 110 | +- Environment validation |
| 111 | +- Build verification |
| 112 | + |
| 113 | +## π Troubleshooting |
| 114 | + |
| 115 | +### Build Fails |
| 116 | +1. Check environment variables are set |
| 117 | +2. Verify Node version is 20 |
| 118 | +3. Check build logs for specific errors |
| 119 | + |
| 120 | +### API Routes Not Working |
| 121 | +1. Verify environment variables |
| 122 | +2. Check function logs in Netlify dashboard |
| 123 | +3. Test individual endpoints |
| 124 | + |
| 125 | +### PWA Not Installing |
| 126 | +1. Check service worker registration |
| 127 | +2. Verify manifest.json is accessible |
| 128 | +3. Test on HTTPS (required for PWA) |
| 129 | + |
| 130 | +## π Performance |
| 131 | + |
| 132 | +Expected performance metrics: |
| 133 | +- **Build Time**: 5-10 minutes |
| 134 | +- **Cold Start**: < 2 seconds |
| 135 | +- **Page Load**: < 3 seconds |
| 136 | +- **Lighthouse Score**: 95+ |
| 137 | + |
| 138 | +## π Updates |
| 139 | + |
| 140 | +To update the deployment: |
| 141 | +1. Push changes to GitHub |
| 142 | +2. Netlify auto-deploys from main branch |
| 143 | +3. Monitor build in Netlify dashboard |
| 144 | + |
| 145 | +## π Support |
| 146 | + |
| 147 | +If you encounter issues: |
| 148 | +1. Check Netlify build logs |
| 149 | +2. Verify environment variables |
| 150 | +3. Test locally first with `npm run build` |
| 151 | +4. Check the health endpoint `/api/health` |
| 152 | + |
| 153 | +--- |
| 154 | + |
| 155 | +**Ready to deploy!** π |
| 156 | + |
| 157 | +Your CODEEX AI app will be live with all 8 AI models working perfectly. |
0 commit comments