A full-stack project to detect whether news content is likely REAL or FAKE using text classification and image OCR.
- Website (GitHub Pages):
https://ankit-xo.github.io/FakeNewsDetection/home
| Home | Text Check |
|---|---|
![]() |
![]() |
| Image Check | About |
|---|---|
![]() |
![]() |
- Text news prediction with confidence score
- Image-based prediction using OCR + model inference
- Why-this-result explanation + fact-check tips
- API health indicator and retry UX
- Context-aware retry flow for both prediction and feedback failures
- Recent checks history (last 5 via localStorage)
- Feedback collection and contact email
- Mobile-optimized header/footer and responsive layout
| Metric | Value |
|---|---|
| Accuracy | 98.5% |
| Precision | 99.7% |
| Recall | 96.9% |
| F1 Score | 98.3% |
| Dataset Size | 38.8K+ records |
| Last Trained | 7 Apr 2026 |
Confusion matrix (validation split, positive class = FAKE):
| Actual \ Predicted | FAKE | REAL |
|---|---|---|
| FAKE | 3470 | 110 |
| REAL | 9 | 4176 |
Frontend sends text/image input to FastAPI. Backend preprocesses text/OCR output, runs the model, and returns result + confidence + insights.
- Frontend: React + Vite
- Backend: FastAPI
- ML: scikit-learn
- OCR: pytesseract + Pillow
FakeNewsDetection/
├── backend/
│ ├── core/
│ │ ├── main.py # FastAPI app + API routes
│ │ └── train.py # ML training pipeline
│ ├── models/ # trained model files
│ └── feedback/ # user feedback logs
├── dataset/ # datasets (Git LFS)
├── frontend/
│ ├── public/assets/ # logo, favicon, architecture diagram
│ ├── src/
│ ├── package.json
│ └── vite.config.js
├── docs/
│ └── screenshots/ # README website screenshots
├── Dockerfile # Render backend container
├── render.yaml # Render Blueprint config
├── Testing.md # QA checklist and test cases
├── requirements.txt
└── README.md
- Python 3.9+
- Node.js 18+
- npm
- Tesseract OCR installed
git clone https://github.com/ankit-xo/FakeNewsDetection.git
cd FakeNewsDetectionAfter installing Python dependencies and frontend packages once, start both backend and frontend together from the project root:
python3 run_dev.pyThis starts:
- Frontend:
http://localhost:3000/home - Backend docs:
http://localhost:8000/docs
If you already have a local venv/, the script will use it automatically.
macOS / Linux:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn backend.core.main:app --host 0.0.0.0 --port 8000 --reloadWindows PowerShell:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
uvicorn backend.core.main:app --host 0.0.0.0 --port 8000 --reloadcd frontend
npm install
npm run dev- Frontend:
http://localhost:3000/home - Backend docs:
http://localhost:8000/docs
- API health:
http://localhost:8000/api/health - Frontend health pill should show:
API Online • Model Ready
- Open
Text Checkand clickLoad Sample News. - Click
Predictand review:- result badge,
- confidence bar,
Why this result?,Fact-check tips.
- Open
Image Check, upload sample image, run prediction. - Test
Feedbackbuttons (Real/Fake). - Disconnect backend briefly to verify error + retry UX.
Set backend base URL before deploy:
macOS / Linux:
cd frontend
VITE_API_BASE_URL=https://your-backend-url.com npm run deployWindows PowerShell:
cd frontend
$env:VITE_API_BASE_URL="https://your-backend-url.com"
npm run deploycd frontend
npm install
npm run deployThis repository already includes Dockerfile and render.yaml.
- Push latest code to GitHub.
- In Render, create a new
BlueprintorWeb Service. - Use:
- Runtime: Docker
- Branch:
main - Health Check Path:
/api/health
- Set env var:
CORS_ALLOW_ORIGINS=https://ankit-xo.github.io,http://localhost:3000,http://127.0.0.1:3000
- Deploy and verify:
https://fake-news-detection-api-8zp1.onrender.com
GET /api/healthPOST /api/predictPOST /api/predict-imagePOST /api/feedback
- Threshold for REAL classification:
0.50(PROB_THRESHOLD) - Dataset CSV files are tracked with Git LFS
- Render free plan may sleep after inactivity
Ankit Anand
- GitHub: @ankit-xo
- Feedback email: ankitanand.works@gmail.com



