An intelligent web application that uses machine learning to detect fake news articles in real-time. Built with React frontend, Express.js backend, and Python Flask ML API, this system provides accurate predictions with explanatory insights.
- Real-time Detection: Instant fake news classification
- Confidence Scoring: Probability-based predictions
- Explainable AI: Key indicators influencing decisions
- Similar Content: Matching with verified real news
- Responsive Design: Works on all devices
- Multi-dataset Training: Trained on diverse news datasets
- React 18.2.0 - Modern UI framework
- Axios - HTTP client for API communication
- Custom CSS - Responsive styling
- Express.js 5.1.0 - Web application framework
- CORS - Cross-origin resource sharing
- Node.js - Runtime environment
- Python Flask 3.0.3 - ML API framework
- Scikit-learn 1.5.2 - Machine learning library
- Multinomial Naive Bayes - Classification algorithm
- TF-IDF Vectorization - Text feature extraction
- NumPy & Pandas - Data processing
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
โ React App โ โ Express.js โ โ Flask ML โ
โ (Port 3000) โโโโโถโ (Port 5000) โโโโโถโ (Port 5001) โ
โ โ โ โ โ โ
โ โข User Interfaceโ โ โข API Gateway โ โ โข ML Processing โ
โ โข Visualizationsโ โ โข Request Proxy โ โ โข Predictions โ
โ โข Form Handling โ โ โข CORS Handling โ โ โข Explanations โ
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
- Node.js (v14+)
- Python (v3.8+)
- Git
- Clone the repository
git clone https://github.com/nihal07g/fake-news-detector-ml.git
cd fake-news-detector-ml- Setup Frontend
cd frontend
npm install- Setup Backend
cd backend
npm install- Setup Python ML API
cd python_api
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt- Train the Model
python train_model.pyStart all three services in separate terminals:
# Terminal 1: ML API
cd python_api
python app.py
# Terminal 2: Backend
cd backend
npm start
# Terminal 3: Frontend
cd frontend
npm startVisit http://localhost:3000 in your browser.
- Algorithm: Multinomial Naive Bayes
- Features: 3,000 TF-IDF features with bi-grams
- Datasets: WELFake, Custom News, LIAR (optional)
- Accuracy: Optimized through cross-validation
- Response Time: < 2 seconds
- Enter News Text: Paste or type news article content
- Click Analyze: Press "Check Authenticity" button
- View Results: See prediction with confidence scores
- Understand Decision: Review key indicators
- Compare Content: View similar real news (if fake detected)
fake-news-detector-ml/
โโโ frontend/ # React application
โ โโโ src/
โ โ โโโ App.js # Main component
โ โ โโโ App.css # Styles
โ โ โโโ index.js # Entry point
โ โโโ public/ # Static assets
โ โโโ package.json # Dependencies
โโโ backend/ # Express server
โ โโโ server.js # API gateway
โ โโโ package.json # Dependencies
โโโ python_api/ # ML processing
โ โโโ app.py # Flask API
โ โโโ train_model.py # Model training
โ โโโ preprocess_*.py # Data preprocessing
โ โโโ requirements.txt # Python deps
โ โโโ *.pkl # Model artifacts
โโโ .gitignore # Git ignore rules
โโโ README.md # Documentation
Create .env files for custom configurations:
# Backend (.env)
PORT=5000
PYTHON_API_URL=http://localhost:5001
# Python API (.env)
FLASK_PORT=5001
MODEL_PATH=./model.pkl- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
- Deep learning models (BERT, LSTM)
- Multi-language support
- User authentication
- Batch processing
- Advanced visualizations
- Mobile application
- Cloud deployment
- Large dataset files not included in repository
- Model retraining required for optimal performance
- CORS configuration for production deployment
This project is licensed under the MIT License - see the LICENSE file for details.
Nihal - GitHub
- WELFake Dataset contributors
- Scikit-learn community
- React development team
- Open source community
โญ Star this repository if you found it helpful!