A Replit-ready Python application that continuously watches a folder for new candidate profile files (PDF/DOCX), parses them using a hybrid LLaMA-based extractor, and pushes structured data to Google Sheets and SV Admin Portal.
- π Folder Watching: Automatically detects new candidate files using
watchdog - π Multi-format Support: Parses PDF and DOCX files with OCR fallback
- π€ Hybrid Extraction: Combines deterministic regex patterns with LLaMA-based parsing
- π Google Sheets Integration: Appends parsed data to Google Sheets
- π SV Portal Integration: Uploads data via API or Playwright automation
- π« Duplicate Detection: Tracks processed files using SHA256 hashing
- π Comprehensive Logging: Timestamped logs for all operations
- π Keep-Alive Endpoint: Flask server for Replit's 24/7 operation
candidate-parser/
βββ main.py # Main orchestrator
βββ config.py # Configuration loader
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ parser/
β βββ __init__.py
β βββ llama_parser.py # LLaMA-based parser
βββ integrations/
β βββ __init__.py
β βββ sheets.py # Google Sheets writer
β βββ sv_portal.py # SV Portal uploader
βββ example_output.json # Example parsed output
βββ README.md # This file
pip install -r requirements.txtOn Ubuntu/Debian:
sudo apt-get update
sudo apt-get install tesseract-ocr poppler-utilsOn macOS:
brew install tesseract popplerOn Windows:
- Download Tesseract from: https://github.com/UB-Mannheim/tesseract/wiki
- Download Poppler from: https://github.com/oschwartz10612/poppler-windows/releases
- Add to PATH
playwright install chromiumCopy .env.example to .env and fill in your values:
cp .env.example .envEdit .env with your configuration:
WATCH_FOLDER=/data/candidates
GOOGLE_SHEET_ID=your_sheet_id_here
GOOGLE_SERVICE_ACCOUNT_JSON=path/to/service-account.json
SV_PORTAL_URL=https://admin.example.com
SV_ADMIN_EMAIL=admin@example.com
SV_ADMIN_PASSWORD=your_password_here- Create a Google Cloud Project
- Enable Google Sheets API
- Create a Service Account
- Download the service account JSON key
- Share your Google Sheet with the service account email
- Set
GOOGLE_SERVICE_ACCOUNT_JSONto the JSON file path or JSON string
The application works without a LLaMA model (using deterministic extraction only). To use LLaMA:
- Download a compatible
.ggufmodel (e.g., from Hugging Face) - Place it in
models/directory - Set
LLAMA_MODEL_PATHin.env
Example models:
llama-2-7b-chat.ggufmistral-7b-instruct-v0.1.gguf
python main.pyThe application will:
- Start watching the configured folder
- Process any existing files
- Process new files as they appear
- Start Flask server on port 8080
- Upload all files to Replit
- Install dependencies:
pip install -r requirements.txt - Set environment variables in Replit Secrets
- Run:
python main.py
The Flask keep_alive endpoint at /keep_alive will keep the app running on Replit's Core plan.
Visit http://localhost:8080/health to check if the service is running.
GET /- Service statusGET /health- Health checkGET /keep_alive- Keep-alive for Replit
The parser extracts structured JSON data:
{
"identity": {
"candidate_id": "A1B2C3D4",
"name": "John Doe",
"designation": "Software Engineer",
"email": "john.doe@example.com",
"phone": "+919876543210",
"dob": "1990-05-15",
"gender": "Male",
"nationality": "Indian"
},
"documents": {
"pan_number": "ABCDE1234F",
"uan_number": "123456789012",
"passport_number": "A1234567",
"valid_from": "2020-01-01",
"valid_to": "2030-01-01"
},
"education": [...],
"experience": [...],
"addresses": {
"current": "...",
"permanent": "..."
}
}See example_output.json for a complete example.
Logs are written to:
- Console output
- File:
candidate_parser.log(configurable viaLOG_FILE)
Each log entry includes:
- Timestamp
- Filename
- Success/error status
- Detailed error messages
The application uses SHA256 hashing to track processed files. Processed hashes are stored in processed_hashes.json. This prevents:
- Re-processing the same file
- Processing files that are still being written
- Verify service account JSON is correct
- Ensure sheet is shared with service account email
- Check sheet ID is correct (from URL:
https://docs.google.com/spreadsheets/d/{SHEET_ID}/edit)
- API upload: Check portal URL and authentication
- Playwright upload: Verify login credentials and form structure
- Check logs for detailed error messages
- Verify model path is correct
- Ensure model file is
.ggufformat - Check available disk space and memory
- Application will fall back to deterministic extraction
- Install Tesseract OCR system package
- Set
TESSDATA_PREFIXenvironment variable if needed - Verify PDF contains images (OCR only used when text extraction fails)
- Place a test PDF/DOCX in the watch folder
- Monitor logs for processing
- Check Google Sheets for new row
- Verify SV Portal upload
Edit parser/llama_parser.py:
- Add regex patterns in
deterministic_extract() - Update LLaMA prompt in
llama_extract() - Update output schema
- Add new uploaders in
integrations/ - Import and use in
main.py - Update configuration as needed
This project is provided as-is for internal use.
For issues or questions, check the logs in candidate_parser.log for detailed error messages.