tester / DEPLOYMENT_GUIDE.md
devilseye2004's picture
Upload 10 files
7c956fc verified
|
Raw History Blame Contribute Delete
3.86 kB
# 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)