# Humanizer System Deployment Guide ## System Architecture - **Frontend**: Next.js on Vercel (`aquahumanizer.vercel.app`) - **Backend**: FastAPI on Hugging Face Spaces (Docker) - **Connection**: Frontend calls backend API ## Files Cleaned Up ✅ Removed old/unused files: - `humanizer.py` (old version) - `format_preserver.py` (old version) - Test files (user removed manually) ## Current Files Structure ``` ├── app.py # Main FastAPI application ├── config.py # Configuration (no .env needed) ├── main.py # Entry point for HF Spaces ├── Dockerfile # Docker configuration for HF Spaces ├── requirements.txt # Python dependencies ├── humanizer_three_pass.py # Three-pass humanizer engine ├── formatting_detector.py # Formatting preservation ├── markdown_converter.py # Markdown to plain text conversion ├── export_pipeline.py # DOCX/PDF export (optional) └── frontend/ # Next.js frontend (deployed separately) ``` ## Key Features Implemented 1. ✅ **No external AI APIs** - Uses internal three-pass humanizer 2. ✅ **Formatting preservation** - Preserves code blocks, lists, tables, URLs, etc. 3. ✅ **Markdown to plain text conversion** - Users get clean text for copy/download 4. ✅ **Config without .env file** - Works on Hugging Face Spaces 5. ✅ **Dockerfile fixed** - No syntax errors, proper main.py ## Deployment Steps ### 1. Backend (Hugging Face Spaces) 1. Push this code to GitHub 2. Go to [Hugging Face Spaces](https://huggingface.co/spaces) 3. Click "Create new Space" 4. Select: - **Space name**: `humanizer-backend` (or your choice) - **Space SDK**: `Docker` - **Visibility**: Public or Private 5. Connect your GitHub repository 6. Deploy ### 2. Frontend (Vercel) 1. The frontend is already at `aquahumanizer.vercel.app` 2. In Vercel dashboard, add environment variable: - `BACKEND_URL` = `https://[your-username]-humanizer-backend.hf.space` (Replace with your actual HF Spaces URL) ### 3. Environment Variables **Backend (HF Spaces)** - Uses defaults, no .env needed: - `PORT` = 7860 (default) - `PASSES` = 3 (default) - `LOG_LEVEL` = INFO (default) **Frontend (Vercel)**: - `BACKEND_URL` = Your HF Spaces backend URL ## Testing Locally ```bash # Install dependencies pip install -r requirements.txt # Run backend uvicorn main:app --host 0.0.0.0 --port 7860 # Frontend (separate terminal) cd frontend npm install npm run dev ``` ## API Endpoints - `POST /humanize` - Humanize text - `POST /humanize-document` - Process document files - `GET /health` - Health check - `GET /` - Redirects to frontend - `GET /info` - System information ## Notes - PDF export (`export_pipeline.py`) has weasyprint dependency issues on Windows but might work on HF Spaces (Linux) - If PDF export fails, DOCX and TXT export still work - The system handles 10,000+ word documents with formatting preservation - No external API calls - all processing is internal ## Troubleshooting 1. **Docker build fails on HF Spaces**: - Check Dockerfile syntax - Ensure all required files are in repository 2. **Frontend can't connect to backend**: - Verify `BACKEND_URL` environment variable in Vercel - Check CORS settings in `main.py` 3. **PDF export not working**: - WeasyPrint requires GTK3 on Linux - Consider removing weasyprint from `export_pipeline.py` if not needed ## Success Indicators ✅ Backend runs on HF Spaces (Docker container starts) ✅ Frontend connects to backend (API calls work) ✅ Text humanization works (three-pass system) ✅ Formatting preserved (code blocks, lists, etc.) ✅ Copy/download gives plain text (no Markdown syntax)