diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1bef421 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Production Dockerfile for MenAssist +FROM node:18-alpine + +# Set working directory +WORKDIR /app + +# Copy package files +COPY package*.json ./ + +# Install dependencies +RUN npm ci --only=production + +# Copy application code +COPY . . + +# Build the application +RUN npm run build + +# Create non-root user +RUN addgroup -g 1001 -S nodejs +RUN adduser -S menassist -u 1001 + +# Change ownership of the app directory +RUN chown -R menassist:nodejs /app +USER menassist + +# Expose port +EXPOSE 5000 + +# Health check +HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ + CMD curl -f http://localhost:5000/health || exit 1 + +# Start the application +CMD ["npm", "run", "start:prod"] \ No newline at end of file diff --git a/PRODUCTION_DEPLOYMENT.md b/PRODUCTION_DEPLOYMENT.md new file mode 100644 index 0000000..e4b4f0d --- /dev/null +++ b/PRODUCTION_DEPLOYMENT.md @@ -0,0 +1,129 @@ +# MenAssist Production Deployment Guide + +## Pre-deployment Checklist + +### 1. Environment Setup +- [ ] Set NODE_ENV=production +- [ ] Configure DATABASE_URL with production PostgreSQL connection +- [ ] Set SESSION_SECRET to a secure random string +- [ ] Configure CORS_ORIGIN to your production domain + +### 2. Required API Keys +The following API keys must be configured in your deployment environment: +- `ANTHROPIC_API_KEY` - For AI chat and joke generation +- `OPENAI_API_KEY` - Alternative AI provider (optional) + +### 3. Database Migration +```bash +npm run db:push +``` + +### 4. Admin Account +- Email: admin@menassist.com +- Username: admin +- Password: password (change immediately after first login) + +## Deployment Steps + +### Option 1: Replit Deployments (Recommended) +1. Ensure all environment variables are set in Replit Secrets +2. Click the "Deploy" button in Replit +3. Configure custom domain if needed + +### Option 2: Docker Deployment +```bash +# Build the image +docker build -t menassist . + +# Run with environment variables +docker run -p 5000:5000 \ + -e DATABASE_URL="your_database_url" \ + -e SESSION_SECRET="your_session_secret" \ + -e ANTHROPIC_API_KEY="your_api_key" \ + menassist +``` + +### Option 3: Manual Deployment +```bash +# Install dependencies +npm ci --only=production + +# Build the application +npm run build + +# Start production server +npm run start +``` + +## Production Configuration + +### Security Features +- HTTPS enforcement +- Session security with httpOnly and secure flags +- CORS protection +- Rate limiting +- Helmet security headers + +### Performance Features +- Gzip compression +- Asset optimization +- Database connection pooling +- Request timeout handling + +### Monitoring +- Health check endpoint: `/health` +- Application logs in JSON format +- Error tracking and reporting + +## Environment Variables + +### Required +- `DATABASE_URL` - PostgreSQL connection string +- `SESSION_SECRET` - Secure random string for session encryption + +### Optional +- `PORT` (default: 5000) +- `CORS_ORIGIN` (default: current domain) +- `LOG_LEVEL` (default: info) +- `CACHE_TTL` (default: 3600) + +## Post-deployment Verification + +1. Check health endpoint: `https://your-domain.com/health` +2. Login with admin credentials +3. Test voice features (requires HTTPS) +4. Verify AI functionality +5. Test task and financial features + +## Troubleshooting + +### Voice Features Not Working +- Ensure deployment is served over HTTPS +- Check browser permissions for microphone access +- Verify Web Speech API support in target browsers + +### AI Features Not Working +- Verify API keys are correctly set +- Check API rate limits +- Review application logs for errors + +### Database Connection Issues +- Verify DATABASE_URL format +- Check SSL configuration +- Ensure database accepts connections from deployment IP + +## Security Recommendations + +1. Change admin password immediately +2. Enable 2FA if available +3. Regularly update dependencies +4. Monitor access logs +5. Use secure session configuration +6. Implement proper backup strategy + +## Scaling Considerations + +- Database: Use connection pooling and read replicas +- Voice Processing: Consider external speech services for high traffic +- AI Services: Implement caching for frequent requests +- Static Assets: Use CDN for better performance \ No newline at end of file diff --git a/client/src/hooks/useEnhancedVoice.tsx b/client/src/hooks/useEnhancedVoice.tsx index a309198..50538bb 100644 --- a/client/src/hooks/useEnhancedVoice.tsx +++ b/client/src/hooks/useEnhancedVoice.tsx @@ -37,7 +37,6 @@ export function useEnhancedVoice() { const { toast } = useToast(); const recognitionRef = useRef(null); - const timeoutRef = useRef(null); const commandQueueRef = useRef([]); const [settings, setSettings] = useState({ @@ -107,7 +106,7 @@ export function useEnhancedVoice() { if (result.isFinal) { finalTranscript += transcript; if (alternative.confidence >= settings.confidenceThreshold) { - processVoiceCommand(transcript, result[0].confidence); + processVoiceCommand(transcript, alternative.confidence); } } else { interimTranscript += transcript; diff --git a/cookies.txt b/cookies.txt new file mode 100644 index 0000000..c7992ff --- /dev/null +++ b/cookies.txt @@ -0,0 +1,5 @@ +# Netscape HTTP Cookie File +# https://curl.se/docs/http-cookies.html +# This file was generated by libcurl! Edit at your own risk. + +#HttpOnly_localhost FALSE / FALSE 1749450859 connect.sid s%3AGkyUc3MYFxJYozd55IC5WpjDjVLhy-uV.Z8mvyWLFIXCz%2FASbHDT34A%2BpG%2BveJgHUC2LM3IYUzRY diff --git a/server/routes.ts b/server/routes.ts index 49ff1ac..ffe718f 100644 --- a/server/routes.ts +++ b/server/routes.ts @@ -49,6 +49,16 @@ passport.deserializeUser(async (id: number, done) => { }); export async function registerRoutes(app: Express): Promise { + // Health check endpoint for production monitoring + app.get('/health', (req, res) => { + res.status(200).json({ + status: 'healthy', + timestamp: new Date().toISOString(), + uptime: process.uptime(), + version: process.env.APP_VERSION || '1.0.0', + environment: process.env.NODE_ENV || 'development' + }); + }); // Configure session middleware app.use(session({ secret: process.env.SESSION_SECRET || 'your-secret-key',