TruthLab is a fake-news verification web application. It combines a React frontend with a Flask API that can classify submitted news text or article URLs using a saved scikit-learn model and TF-IDF vectorizer.
- User signup and login with JWT-based authentication.
- Optional Google OAuth login flow.
- News verification from direct text or a URL.
- Verification history for authenticated users.
- FAQ question submission.
- Issue report submission.
- MongoDB-backed persistence for users, verification history, FAQ questions, and reports.
- React 19
- Vite
- React Router
- Tailwind CSS
- Lucide React icons
- Python Flask
- Flask-JWT-Extended
- Flask-Bcrypt
- Flask-CORS
- PyMongo
- scikit-learn and joblib
- BeautifulSoup and requests for URL article extraction
TruthLab/
|-- backend/
| |-- app.py
| |-- models.py
| |-- requirements.txt
| |-- middleware/
| |-- model/
| | |-- fake_news_model.pkl
| | `-- tfidf_vectorizer.pkl
| `-- routes/
`-- frontend/
|-- package.json
|-- vite.config.js
|-- public/
`-- src/
- Node.js and npm
- Python 3.10 or newer
- MongoDB Atlas database or a compatible MongoDB instance
From the project root:
cd backend
python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txtCreate a .env file in backend/:
MONGO_URI=mongodb+srv://<user>:<password>@<cluster>/<database>?retryWrites=true&w=majority
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=http://127.0.0.1:5000/auth/google/callback
FRONTEND_URL=http://localhost:5173Run the API:
python app.pyThe backend runs at:
http://127.0.0.1:5000
Open a second terminal from the project root:
cd frontend
npm install
npm run devThe Vite development server usually runs at:
http://localhost:5173
POST /auth/signupPOST /auth/loginGET /auth/google/loginGET /auth/google/callback
GET /verify/healthPOST /verify/predictGET /verify/history
POST /verify/predict accepts either:
{
"text": "Article or headline text"
}or:
{
"url": "https://example.com/news-article"
}POST /faq/submit-question
POST /report/submit-report
Frontend:
npm run dev
npm run build
npm run lint
npm run previewBackend:
python app.pybackend/models.pyimportspython-dotenv, butpython-dotenvis not currently listed inbackend/requirements.txt.backend/routes/faq_routes.pyandbackend/routes/report_routes.pycontain hardcoded MongoDB connection strings. Move these to environment variables before sharing or deploying the project.backend/routes/verify_routes.pyimportsutils.text_cleaner, but nobackend/utils/text_cleaner.pyfile is currently present in the repository.backend/routes/admin_routes.pyimportsmodel.user_model, but that module is not currently present in the repository.frontend/src/App.jsusesPrivateRoute, but it is not currently imported or defined.- The login, signup, and verification form UI currently appears to be mostly static; some frontend components do not yet call the backend API.