Recently, an innovative sentiment analysis system based on the Reddit social platform has garnered attention. This system, utilizing artificial intelligence technology, tracks and analyzes the public opinion trends of the 2024 US Presidential Election candidates Donald Trump and Kamala Harris in real-time.

image.png

System Operation Principle

The analysis system automatically scrapes relevant discussions from the Reddit platform every 10 minutes. It focuses on content with significant influence, selecting only posts that were published within the last hour and have received more than 10 upvotes. To ensure data timeliness, the system maintains the latest 50 posts for analysis.

During the sentiment analysis phase, the system utilizes OpenAI's GPT-4-turbo model to perform in-depth analysis on each post, providing a quantitative score from 0 to 100. These scores are promptly updated to the database through a callback mechanism. The system conducts an overall score for the candidates every hour, calculating the average sentiment score based on the latest 50 posts, and retains the last 100 time points of scores for each candidate.

Technological Innovation Highlights

The system incorporates several advanced technological solutions in its architecture:

  • Utilizes QStash for task scheduling and callbacks
  • Employs Upstash Redis as the data storage system
  • Integrates OpenAI's latest language model technology

To ensure system reliability, the development team has implemented multiple safeguards:

  • Designed a retry mechanism for failures
  • Adopts a callback mechanism to ensure consistency in score updates
  • Implements a reasonable data retention strategy

User-Friendly Visual Interface

The system offers an intuitive data visualization interface, including:

  • Dynamic line charts displaying the trend in candidate support
  • Real-time display of the latest post content
  • Quick access to the original Reddit post links

The project has been open-sourced, and interested users can experience its functionality through an online demo system (https://elections-sentiment-analysis.vercel.app/), while developers can contribute to the project on GitHub (https://github.com/upstash/elections-sentiment-analysis). This innovative system provides new technological insights for election sentiment analysis, showcasing the potential of artificial intelligence in political sentiment analysis.