FactRadar is an advanced AI-powered application designed to detect fake news and misinformation in text content. It uses multiple machine learning models and AI verification to provide accurate analysis of news articles, social media posts, and other text sources.
FactRadar/
βββ π app/ # Next.js app directory
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Main application page
βββ π backend/ # Python Flask backend
β βββ app.py # Main Flask application
β βββ requirements.txt # Python dependencies
β βββ π models/ # ML models directory
β β βββ best_model_gradient_boosting.pkl
β β βββ best_model_metadata.json
β β βββ cnn_model.h5
β β βββ lstm_model.h5
β β βββ tfidf_vectorizer_full.pkl
βββ π components/ # React components
β βββ FakeNewsDetector.tsx # Main detection component
β βββ theme-provider.tsx # Theme management
β βββ theme-switcher.tsx # Theme toggle component
β βββ theme-toggle.tsx # Alternative theme toggle
β βββ π ui/ # Shadcn/ui components
βββ π fake-and-real-news-dataset/ # Training datasets
β βββ Fake.csv
β βββ True.csv
βββ π hooks/ # Custom React hooks
β βββ use-mobile.tsx
β βββ use-toast.ts
β βββ useFactCheck.ts # Main fact-checking hook
βββ π lib/ # Utility libraries
β βββ formatReasoning.tsx # Reasoning formatting utilities
β βββ openrouter.ts # OpenRouter API client
β βββ utils.ts # General utilities
βββ π public/ # Static assets
β βββ index.html
β βββ placeholder-logo.png
β βββ placeholder-logo.svg
β βββ placeholder-user.jpg
β βββ placeholder.jpg
β βββ placeholder.svg
β βββ script.js
β βββ style.css
β βββ π models/ # Frontend ML models
β βββ preprocessing_config.json
β βββ vocabulary.json
βββ π src/ # Source files
β βββ prediction.js
β βββ preprocessing.js
β βββ utils.js
βββ π styles/ # Additional styles
β βββ globals.css
βββ π training/ # Model training infrastructure
β βββ π data/
β β βββ π processed/
β β β βββ feature_summary.json
β β β βββ fully_processed_dataset.csv
β β β βββ real_dataset_processed.csv
β β β βββ tfidf_vectorizer_full.pkl
β β β βββ π models/
β β β βββ best_model_gradient_boosting.pkl
β β β βββ best_model_metadata.json
β β β βββ cnn_model.h5
β β β βββ keras_tokenizer.pkl
β β β βββ lstm_model.h5
β β β βββ π version 2/
β β βββ π raw/
β βββ π notebooks/
β β βββ data_exploration.ipynb
β β βββ model_training.ipynb
β β βββ preprocessing.ipynb
β βββ π scripts/
β βββ load_real_datasets.py
β βββ quick_data_check.py
β βββ setup_project.py
β βββ test_notebook_fix.py
βββ π .env.example # Environment variables template
βββ π .gitignore # Git ignore rules
βββ π CHANGELOG.md # Version history
βββ π components.json # Shadcn/ui configuration
βββ π README.md # This file
βββ π netlify.toml # Netlify deployment config
βββ π next.config.mjs # Next.js configuration
βββ π package.json # Frontend dependencies
βββ π pnpm-lock.yaml # Package lock file
βββ π postcss.config.mjs # PostCSS configuration
βββ π requirements.txt # Python dependencies
βββ π tailwind.config.ts # Tailwind CSS configuration
βββ π tsconfig.json # TypeScript configuration
- Multiple Model Support: Choose between different AI models for analysis:
- Gradient Boosting (traditional ML)
- LSTM (deep learning)
- CNN (deep learning)
- Real-time Analysis: Get instant feedback on the authenticity of text content
- AI Cross-Verification: Uses OpenRouter Mistral AI to provide additional verification
- Detailed Reasoning: View the AI's reasoning process for more transparent results
- Modern UI: Clean, responsive interface with glass-morphism design elements
- Privacy-First: Analysis happens directly in your browser
Check out the live demo on X (formerly Twitter): FactRadar Demo
- Node.js (v18 or higher)
- Python (v3.8 or higher)
- pip (for Python package management)
-
Clone the repository:
git clone https://github.com/yourusername/factradar.git cd factradar -
Install frontend dependencies:
npm install --legacy-peer-deps
-
Install backend dependencies:
cd backend pip install -r requirements.txt -
Set up environment variables: Copy
.env.exampleto.env.localand fill in your OpenRouter API key:cp .env.example .env.local # Edit .env.local with your actual API key
-
Start the backend server (Terminal 1):
cd backend python app.py -
Start the frontend (Terminal 2):
npm run dev
-
Open your browser and navigate to
http://localhost:3000
FactRadar uses a combination of traditional machine learning and deep learning techniques to analyze text content:
- Text Preprocessing: Cleans and normalizes the input text
- Feature Extraction: Extracts relevant features from the text
- Model Analysis: Processes the features through the selected AI model
- AI Cross-Verification: Sends the text to OpenRouter Mistral for additional verification
- Result Presentation: Displays the analysis results with confidence scores
Traditional ML model with high accuracy on structured features. Uses TF-IDF vectorization and engineered features.
Performance Metrics:
- Test Accuracy: 99.67%
- Test Precision: 100%
- Test Recall: 99.33%
- Test F1-Score: 99.67%
Deep learning model good at capturing sequential patterns in text data.
Deep learning model effective at capturing local patterns and features in text.
- Framework: Next.js 15 with React 19
- Styling: Tailwind CSS + Shadcn/ui
- Language: TypeScript
- State Management: React Hooks
- HTTP Client: Fetch API
- Framework: Flask (Python)
- ML Libraries: scikit-learn, TensorFlow, XGBoost
- NLP: NLTK
- API: RESTful endpoints
- Traditional ML: Gradient Boosting, XGBoost
- Deep Learning: LSTM, CNN
- Feature Engineering: TF-IDF, sentiment analysis, linguistic features
The models were trained on:
- Total Samples: 3,998 (1,999 real + 1,999 fake)
- Training Set: 2,798 samples
- Validation Set: 600 samples
- Test Set: 600 samples
- Features: 10,012 total features (10,000 TF-IDF + 12 engineered)
Frontend:
npm run dev # Start development server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLintBackend:
python app.py # Start Flask serverCreate a .env.local file with:
NEXT_PUBLIC_OPENROUTER_API_KEY=your_openrouter_api_key_here
BACKEND_URL=http://localhost:5000
NEXT_PUBLIC_FRONTEND_URL=http://localhost:3000Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Follow the existing code style
- Add tests for new features
- Update documentation as needed
- Ensure all tests pass before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
- OpenRouter for providing AI verification capabilities
- Shadcn/ui for the beautiful UI components
- The open-source community for the amazing tools and libraries
For support, please open an issue on GitHub or contact the development team.