github-portfolio

Real-time Social Media Sentiment Dashboard

Track sentiment trends about any topic using Twitter data and TextBlob sentiment analysis.

Overview

This Streamlit dashboard collects recent tweets about a specific topic, analyzes their sentiment using TextBlob’s natural language processing, and visualizes the results with interactive charts and metrics.

Features

Project Context

Use the Twitter API (via Tweepy) to collect recent posts about any topic and analyze sentiment using TextBlob. The dashboard updates with live sentiment scores, showing positive/negative trends and engagement patterns.

Setup Instructions

1. Install Dependencies

pip install -r requirements.txt

2. Get Twitter API Credentials

  1. Visit Twitter Developer Portal
  2. Create a new app or use an existing one
  3. Generate API credentials:
    • API Key (Consumer Key)
    • API Secret (Consumer Secret)
    • Access Token
    • Access Secret
    • Bearer Token (required for API v2)

3. Configure Credentials

Option A: For Local Development (Environment Variables)

export TWITTER_BEARER_TOKEN="your_bearer_token"
export TWITTER_API_KEY="your_api_key"
export TWITTER_API_SECRET="your_api_secret"
export TWITTER_ACCESS_TOKEN="your_access_token"
export TWITTER_ACCESS_SECRET="your_access_secret"

Option B: For Streamlit Cloud (Secrets)

Create .streamlit/secrets.toml:

TWITTER_BEARER_TOKEN = "your_bearer_token"
TWITTER_API_KEY = "your_api_key"
TWITTER_API_SECRET = "your_api_secret"
TWITTER_ACCESS_TOKEN = "your_access_token"
TWITTER_ACCESS_SECRET = "your_access_secret"

4. Run the Dashboard

streamlit run sentiment_dashboard.py

The dashboard will open in your browser at http://localhost:8501

Usage

  1. Enter a topic to analyze (e.g., “AI”, “Apple stock”, “Python”)
  2. Adjust the number of tweets to fetch (10-100)
  3. Click “Refresh Data” to fetch and analyze tweets
  4. View sentiment distribution, engagement metrics, and individual tweets

Project Structure

Real-time Social Media Sentiment Dashboard/
├── sentiment_dashboard.py    # Main Streamlit app
├── requirements.txt          # Python dependencies
└── README.md                # Documentation

Technical Stack

Sentiment Analysis Details

Polarity Scores

Metrics Tracked

Example Queries

Try analyzing sentiment for:

Limitations

Future Enhancements

Requirements

License

This project is part of a personal portfolio. Feel free to use and modify for learning purposes.