Web application bridging Paperless-NGX and OpenAI API for automated document analysis, OCR, and metadata enrichment.
- 📄 Retrieve documents from Paperless-NGX by tags
- 🤖 Send documents to OpenAI API for analysis and text extraction
- 🏷️ Automatic metadata enrichment and updating
- 🌐 Web interface for configuration and manual processing
- 🔒 Secure storage of API credentials in SQLite database
- Python 3.12 or higher (required by pypaperless)
- Paperless-NGX instance (v2.17+) with API access
- OpenAI API key
-
Clone the repository
git clone <repository-url> cd paperless_onS
-
Create virtual environment
python -m venv venv source venv/bin/activate # Linux/Mac # or: venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Configure environment
cp .env.example .env # Edit .env with your configuration -
Initialize database
python -m backend.database.init_db
-
Run the application
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000
-
Access web interface
Open http://localhost:8000 in your browser
Configuration can be done via:
- Environment variables in
.envfile - Web interface (Settings page)
Required settings:
- Paperless-NGX URL: Your Paperless instance URL
- Paperless API Token: Authentication token from Paperless-NGX
- OpenAI API Key: Your OpenAI API key
- Configure API credentials in the web interface Settings page
- Select a tag to filter documents from Paperless-NGX
- Review listed documents
- Click "Process" on individual documents to send to OpenAI for analysis
- Review and confirm metadata updates before applying to Paperless-NGX
For production use, deploy with systemd service management and automatic log rotation.
# Navigate to deployment directory
cd deployment
# Run installation script
sudo ./install-production.shThe script will:
- Install gunicorn with Uvicorn workers
- Create log directory
/var/log/paperless_ons - Install systemd service
- Configure automatic log rotation
- Optionally start and enable the service
If you prefer manual setup, see the detailed guide in deployment/README.md.
# Start service
sudo systemctl start paperless-ons
# Stop service
sudo systemctl stop paperless-ons
# Restart service
sudo systemctl restart paperless-ons
# Check status
sudo systemctl status paperless-ons
# Enable autostart on boot
sudo systemctl enable paperless-ons
# View live logs
sudo journalctl -u paperless-ons -fLogs are automatically rotated daily:
- Access logs:
/var/log/paperless_ons/access.log(14 days retention) - Error logs:
/var/log/paperless_ons/error.log(30 days retention) - System logs:
sudo journalctl -u paperless-ons
# View access log
tail -f /var/log/paperless_ons/access.log
# View error log
tail -f /var/log/paperless_ons/error.log
# View systemd journal
sudo journalctl -u paperless-ons -n 100For production, use a reverse proxy (nginx or Caddy) with SSL/TLS.
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl http2;
server_name your-domain.com;
ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;
location / {
proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}your-domain.com {
reverse_proxy localhost:8000
}
- Change SECRET_KEY in
.envfor production - Use HTTPS with valid SSL certificates
- Configure firewall to restrict access
- Regular backups of database file
- Keep system updated
See deployment/README.md for comprehensive production documentation including:
- Detailed installation steps
- Configuration options
- Monitoring and troubleshooting
- Performance tuning
- Backup strategies
paperless_onS/
├── backend/
│ ├── api/ # FastAPI endpoints
│ ├── clients/ # Paperless & OpenAI API clients
│ ├── database/ # SQLite models & schemas
│ ├── services/ # Business logic
│ └── config/ # Configuration management
├── frontend/
│ ├── static/ # CSS, JavaScript
│ └── templates/ # HTML templates
└── requirements.txt # Python dependencies
MIT License
For issues and questions, please open an issue in the repository.