AI-Powered News Analysis Platform for Bias Detection and Misinformation Identification
Watch the Full Demo - See Newsly in action with live article analysis and bias detection!
Newsly is an innovative news analysis platform that leverages advanced artificial intelligence to help users critically evaluate news content. The platform combines state-of-the-art natural language processing models to detect political bias, identify logical fallacies, and provide contextual analysis of news articles. Through a React Native mobile application and FastAPI backend, users can analyze articles from any URL or browse a curated feed of analyzed news content.
The system employs specialized AI models including Political Bias BERT for bias detection, Facebook BART for summarization, and Llama 3.1 for topic extraction and contextualization. By identifying nine different types of logical fallacies and providing detailed explanations, Newsly empowers users to become more discerning news consumers in an era of information overload and misinformation.
- Political Bias Detection: AI-powered classification of articles as left, center, or right-leaning with confidence scores
- Logical Fallacy Identification: Detection of 9 types of logical fallacies including:
- Ad Hominem attacks
- Fear mongering
- False dichotomy
- Emotion-based fallacies
- Non sequitur arguments
- Scapegoating
- Discrediting sources
- And more...
- AI Summarization: Intelligent article summaries using BART models
- Topic Extraction: Automatic identification and categorization of main topics
- Contextualization: Historical and cultural context for better understanding
- Source Credibility Assessment: Evaluation of article sources and their reliability
- News Feed: Browse curated, pre-analyzed articles with filtering by category
- URL Analysis: Paste any news URL for real-time analysis
- User Profiles: Personal accounts with authentication via Supabase
- Bookmarking System: Save articles for later reading
- Search & Filtering: Find articles by topic, author, or keywords
- Dark/Light Mode: Adaptive UI with user preference support
- Analytics Integration: User behavior tracking with PostHog
fastapi-backend/
βββ app/
β βββ main.py # FastAPI application entry point
β βββ server.py # Article processing logic
β βββ ml_newsly.py # Local ML model implementations
β βββ ml_modal.py # Modal GPU-accelerated functions
β βββ db.py # Supabase database operations
β βββ newsly_types.py # Data models and type definitions
β βββ prompts.py # LLM prompts for analysis
β βββ utils.py # Utility functions
β βββ clients.py # External API clients
βββ cli.py # Command-line interface
βββ requirements.txt # Python dependencies
βββ Dockerfile # Container configuration
newsly-frontend/
βββ app/
β βββ tabs/
β β βββ feed/ # News feed screens
β β βββ urlSearch/ # URL analysis interface
β β βββ profile/ # User profile management
β βββ _layout.tsx # Root layout and navigation
βββ components/
β βββ Auth.tsx # Authentication components
β βββ NewsCard.tsx # Article display components
βββ lib/
β βββ articles.ts # Article data models and API
β βββ supabase.ts # Database client
β βββ analytics.ts # PostHog analytics
βββ assets/ # Images, fonts, and static files
Backend Technologies:
- FastAPI: Modern Python web framework for building APIs
- Modal: Cloud platform for running GPU-accelerated ML models
- Supabase: PostgreSQL database with real-time capabilities
- Hugging Face Transformers: Pre-trained AI models for NLP tasks
- Newspaper4k: Web scraping library for article extraction
Frontend Technologies:
- React Native: Cross-platform mobile development
- Expo: Development platform and toolchain
- TypeScript: Type-safe JavaScript development
- React Navigation: Navigation library for mobile screens
AI/ML Models:
- Political Bias BERT (
bucketresearch/politicalBiasBERT): Specialized model for political bias detection - BART Large CNN (
facebook/bart-large-cnn): Abstractive text summarization - Llama 3.1 8B Instruct (
meta-llama/Llama-3.1-8B-Instruct): Topic extraction and contextualization
Infrastructure:
- Modal: GPU computing platform for ML model deployment
- AWS App Runner: Containerized application hosting
- Supabase: Backend-as-a-Service for database and authentication
- PostHog: Product analytics and user tracking
- Python 3.10+
- Node.js 18+
- Expo CLI
- Supabase account
- Modal account (for ML models)
- Hugging Face account (for model access)
-
Clone and navigate to the backend directory:
cd fastapi-backend -
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables:
cp .env.template .env
Fill in the required environment variables in
.env:SUPABASE_URL: Your Supabase project URLSUPABASE_SERVICE_KEY: Supabase service role keyHF_TOKEN: Hugging Face API tokenTOGETHER_API_KEY: Together AI API keyMODAL_TOKEN_IDandMODAL_TOKEN_SECRET: Modal authentication
-
Run the FastAPI server:
fastapi dev app/main.py
-
Deploy Modal functions (optional, for GPU acceleration):
modal deploy app/ml_modal.py
-
Navigate to the frontend directory:
cd newsly-frontend -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile with:EXPO_PUBLIC_SUPABASE_URL=your_supabase_url EXPO_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key EXPO_PUBLIC_POSTHOG_KEY=your_posthog_key -
Start the Expo development server:
npx expo start
-
Run on device:
- iOS:
npx expo start --ios(requires Xcode) - Android:
npx expo start --android(requires Android Studio) - Web:
npx expo start --web
- iOS:
Analyze Article:
POST /articles/analyze
Content-Type: application/json
{
"url": "https://example.com/news-article"
}Test Logical Fallacies:
POST /articles/analyze/logical-fallacies
Content-Type: application/json
{
"url": "https://example.com/news-article"
}The backend includes a powerful CLI tool for batch processing and testing:
# Analyze a single article
python3 cli.py process-article "https://example.com/news-article" --json-output
# Run in test mode (uses mock responses)
python3 cli.py process-article "https://example.com/news-article" --test
# Parse article without analysis
python3 cli.py parse "https://example.com/news-article"
# Get help
python3 cli.py --help- Browse Feed: View curated articles with analysis results
- Search Articles: Use the search functionality to find specific content
- Analyze URLs: Paste any news URL in the URL Search tab for real-time analysis
- User Account: Create an account to save bookmarks and track reading history
- Article Details: Tap on any article to view detailed analysis including bias scores, logical fallacies, and contextualization
- Web scraping using Newspaper4k library
- Content parsing and cleaning
- Metadata extraction (author, date, source)
The system runs multiple AI models simultaneously for efficiency:
- Summarization: BART model generates concise article summaries
- Bias Detection: Political Bias BERT classifies political lean with confidence scores
- Topic Extraction: Llama 3.1 identifies main topics and themes
- Logical Fallacy Detection: Specialized prompts identify 9 types of fallacies
- Contextualization: AI generates historical and cultural context
- Categorization: Articles are tagged into 13 predefined categories
All analysis results are combined into a comprehensive report including:
- Article summary and key topics
- Political bias score and explanation
- Detected logical fallacies with quotes and explanations
- Contextualization paragraph
- Source credibility assessment
The application uses Supabase (PostgreSQL) with the following main tables:
- articles: Stores article content and analysis results
- profiles: User profile information
- bookmarks: User-saved articles
- analytics_events: User interaction tracking
- Local Testing: Use
--testflag for mock responses - Modal Functions: Deploy ML models to Modal for GPU acceleration
- Database: Supabase provides real-time PostgreSQL with built-in auth
- Expo Dev Tools: Built-in debugging and testing capabilities
- Hot Reloading: Instant updates during development
- Cross-Platform: Single codebase for iOS, Android, and web
| Avi Udash | Adrian Gamarra Lafuente | Andrew Bempong | Sabino Hernandez | Elina Mirbaha |
This project was developed by Stanford CS194 Team 2:
- Adrian Gamarra Lafuente
- Andrew Bempong
- Avi Udash
- Sabino Hernandez
- Elina Mirbaha