Skip to content

Repository files navigation

Real-time News Sentiment Analysis Dashboard

A beautiful, real-time web application for analyzing sentiment in news articles about AI and technology. Built with Node.js, Express, and modern web technologies.

🌟 Features

Core Functionality

  • 🔍 News Fetching: Fetch latest news articles from Google News based on customizable queries
  • 💭 Sentiment Analysis: Real-time sentiment analysis using advanced NLP algorithms
  • 📊 Data Visualization: Interactive charts showing sentiment distribution, keyword trends, and historical patterns
  • ⏰ Real-time Updates: Auto-update feature to continuously monitor sentiment trends
  • 🔮 Trend Prediction: Generate predictions based on historical sentiment data
  • 📱 Responsive Design: Beautiful UI that works on all devices

Visual Components

  1. Sentiment Summary Cards: Quick overview of positive, neutral, and negative sentiments
  2. Sentiment Distribution Chart: Donut chart showing sentiment breakdown
  3. Top Keywords: Horizontal bar chart of trending topics
  4. Sentiment Over Time: Line chart tracking sentiment history with prediction capability
  5. News Articles Display: Live feed of analyzed articles with sentiment labels

🚀 Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn

Installation

  1. Install dependencies:
   npm install
  1. Start the server:
   npm start
  1. Open your browser and navigate to:
http://localhost:3000

Development Mode

For auto-restart on file changes:

npm run dev

📖 Usage

Fetch News & Analyze Sentiment

  1. Enter a Search Query: Type your search term (e.g., "AI OR artificial intelligence")
  2. Set Number of Articles: Choose how many articles to analyze (5-50)
  3. Click "Fetch & Analyze": The system will:
    • Fetch latest news articles
    • Perform sentiment analysis on each article
    • Display visualizations and statistics

Real-time Monitoring

  1. Start Auto-Update: Click "Start Auto-Update" button
  2. Monitor Trends: The dashboard will automatically fetch and analyze news every 60 seconds
  3. Stop When Done: Click "Stop Auto-Update" to stop the monitoring

Generate Predictions

  1. Accumulate History: Build up sentiment history by running multiple analyses
  2. Click "Generate Prediction": Get forecasted sentiment trends based on historical data
  3. View Results: See predicted sentiment as a red dashed line on the history chart

Clear History

Click "Clear History" button to reset all sentiment tracking data.

🏗️ Architecture

Backend Services

  • src/services/newsFetcher.js: Handles fetching news from Google News RSS feeds
  • src/services/sentimentAnalyzer.js: Performs sentiment analysis using the Sentiment library
  • src/services/keywordExtractor.js: Extracts trending keywords from article titles

API Endpoints

  • GET /api/news - Fetch news articles
  • POST /api/analyze - Analyze sentiment of articles
  • POST /api/keywords - Extract keywords from articles
  • GET /api/history - Get sentiment history
  • POST /api/history/add - Add to history
  • DELETE /api/history - Clear history
  • GET /api/health - Server health check

Frontend

  • public/index.html: Modern, responsive UI with Tailwind CSS
  • public/js/dashboard.js: Dashboard logic with Chart.js visualizations

🎨 UI Features

Color Scheme

  • Positive Sentiment: Green gradients (#10b981)
  • Neutral Sentiment: Yellow/Amber (#f59e0b)
  • Negative Sentiment: Red/Pink (#ef4444)
  • Primary: Purple to Blue gradient (#667eea to #764ba2)

Interactive Elements

  • Hover effects on all cards
  • Real-time chart updates
  • Smooth transitions and animations
  • Responsive grid layouts
  • Live status indicators

🔧 Technologies Used

  • Backend: Node.js, Express
  • Frontend: HTML5, Tailwind CSS, Vanilla JavaScript
  • Charts: Chart.js
  • Sentiment Analysis: sentiment (Node.js library)
  • Web Scraping: axios, cheerio
  • Scheduling: node-cron (for future enhancements)

📊 Metrics Explained

Polarity Score

  • Range: -1 to +1
  • Positive (> 0): Article has positive sentiment
  • Neutral (~ 0): Article has neutral sentiment
  • Negative (< 0): Article has negative sentiment

Distribution Percentages

  • Shows percentage of articles in each sentiment category
  • Total always equals 100%

Average Polarity

  • Overall sentiment score across all articles
  • Visual representation with emoji and colored circle

🎯 Use Cases

  1. Market Research: Track public sentiment about products or brands
  2. Trend Monitoring: Monitor sentiment shifts over time
  3. Competitive Analysis: Compare sentiment across different topics
  4. Educational: Learn about NLP and sentiment analysis
  5. News Aggregation: Curate news based on sentiment

🔮 Future Enhancements

  • Export data to CSV/JSON
  • Email alerts for sentiment changes
  • Support for multiple languages
  • Advanced prediction models using Prophet or ML algorithms
  • Custom sentiment dictionary
  • Social media integration
  • Comparative analysis across multiple queries

📝 License

MIT License - Feel free to use and modify!

🙏 Credits

Built with ❤️ using:

  • Express.js
  • Chart.js
  • Tailwind CSS
  • Sentiment.js
  • Cheerio
  • Axios

Note: The application uses mock data for news articles in development. For production use, you may need to configure proper RSS feed access or use official news APIs.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages