customeragent-api / server /README_DEPLOYMENT.md
anasraza526's picture
Clean deploy to Hugging Face
ac90985

Customer Agent - Free Tier Deployment Guide

πŸš€ Quick Start (Free Tier)

Local Development

# 1. Install dependencies
python3 install_deps.py

# 2. Set environment variables
export SECRET_KEY="your-secret-key-here"
export DATABASE_URL="sqlite:///./customeragent.db"

# 3. Run the server
python3 run_tests.py

Render Deployment

  1. Connect Repository

    • Link your GitHub repo to Render
    • Select "Web Service"
  2. Environment Variables

    SECRET_KEY=your-secret-key-here
    DATABASE_URL=postgresql://...
    ALLOWED_ORIGINS=https://yourdomain.com
    
  3. Build Settings

    • Build Command: ./render-build.sh
    • Start Command: uvicorn app.main:app --host 0.0.0.0 --port $PORT
  4. Database

    • Add PostgreSQL database
    • Copy connection URL to DATABASE_URL

πŸ§ͺ Testing

Manual Testing

# Test health endpoint
curl http://localhost:8000/health

# Test API docs
open http://localhost:8000/docs

QA Test Suite

python3 test_api.py

πŸ“Š Features Included (Free Tier)

βœ… Core Features:

  • AI-powered chat responses
  • Website content scraping
  • Real-time WebSocket chat
  • Industry-specific tones
  • Analytics dashboard
  • Security middleware
  • Caching system

βœ… Security:

  • Rate limiting
  • XSS protection
  • SQL injection prevention
  • Secure headers
  • Adult content filtering
  • Abusive language blocking

βœ… Monitoring:

  • Health checks
  • Performance metrics
  • Error tracking
  • Response time monitoring

❌ Removed for Free Tier:

  • Subscription system
  • Usage limits
  • Payment integration
  • Premium features

πŸ”§ Configuration

Required Environment Variables

  • SECRET_KEY: JWT secret key
  • DATABASE_URL: Database connection string

Optional Environment Variables

  • REDIS_URL: Redis for caching (optional)
  • OPENAI_API_KEY: For AI responses
  • SENTRY_DSN: Error monitoring
  • ALLOWED_ORIGINS: CORS origins

πŸ“ˆ Scaling

The free tier is designed to handle:

  • 1000+ concurrent users
  • 10,000+ messages per day
  • Multiple websites per user
  • Real-time chat sessions

πŸ› Troubleshooting

Common Issues

  1. Import Errors: Run python3 install_deps.py
  2. Database Errors: Check DATABASE_URL
  3. CORS Issues: Set ALLOWED_ORIGINS
  4. Rate Limiting: Redis optional for free tier
  5. Content Filtering: Test with python3 test_content_filter.py

Logs

  • Check Render logs for deployment issues
  • Use /health endpoint for status
  • Use /metrics endpoint for performance

πŸš€ Production Checklist

  • Set strong SECRET_KEY
  • Configure DATABASE_URL
  • Set ALLOWED_ORIGINS
  • Enable HTTPS
  • Monitor /health endpoint
  • Set up error tracking
  • Test all API endpoints
  • Verify WebSocket connections