A small Python application that estimates whether a job advertisement may be fraudulent. It uses a scikit-learn text classifier and saves submitted advertisements and results to MongoDB.
- Python 3.10 or newer
- MongoDB running locally, or a MongoDB connection URI
From the project directory, create and activate a virtual environment, then install dependencies:
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -r requirements.txtTrain the model using the included demonstration dataset:
python train_model.pyStart MongoDB in Docker (the named volume keeps data between container restarts), then run the web app:
docker run -d --name fake-job-detector-mongodb --restart unless-stopped -p 127.0.0.1:27017:27017 -v fake-job-detector-mongo-data:/data/db mongo:6.0
python app.pyIf the MongoDB container already exists but is stopped, start it with docker start fake-job-detector-mongodb. Open http://127.0.0.1:5000 in a browser. Use this Flask address rather than VS Code Live Server: Flask serves the page and its prediction endpoint together. The checker accepts pasted text, PNG/JPG/JPEG/WebP images (drag and drop or browse, up to 8 MB), or public HTTP/HTTPS job-post URLs. Selecting an image immediately hides the input dashboard, shows a local image preview, and starts OCR analysis; the image is not uploaded to permanent storage. Results use Critical (55%+ estimated fraud risk), Average (30–54.9%), or Legit (under 30%). These are model risk bands, not a determination of whether an employer is genuinely verified; even the Legit result requires independent verification. URL checks support readable HTML and plain text only; pages that require sign-in, redirect, or return other file types are not supported. For safety, URLs resolving to private/local addresses are blocked, non-standard ports and redirects are not followed, and responses are limited to 2 MB. Extracted OCR/page text and analysis results are saved to MongoDB and can be reviewed in the result. A URL whose hostname does not resolve in public DNS cannot be fetched; check the spelling and public reachability of the address. Install the Tesseract OCR engine on Windows if it is not already installed:
winget install --id UB-Mannheim.TesseractOCR -eRestart the app after installing Tesseract. If it is installed in a non-standard location, set the TESSERACT_CMD environment variable to its executable path. MongoDB defaults to mongodb://localhost:27017 and database fake_job_detector. Configure MONGODB_URI and MONGODB_DATABASE environment variables to use a different MongoDB instance or database. If saving fails, the app shows an error in the page and logs the underlying MongoDB error to the Flask console.
Provide a UTF-8 CSV with text and label columns. Labels must be legitimate or fraudulent, and both classes must be present.
python train_model.py --dataset path\to\jobs.csv --output models\fake_job_model.pklThe included sample is synthetic and intended only to demonstrate the workflow. It is not a representative dataset and should not be used to assess real-world accuracy. Train and evaluate with a sufficiently large, representative, labeled dataset before relying on the classifier.
python -m unittest discover -s tests